effect
stringclasses 48
values | original_source_type
stringlengths 0
23k
| opens_and_abbrevs
listlengths 2
92
| isa_cross_project_example
bool 1
class | source_definition
stringlengths 9
57.9k
| partial_definition
stringlengths 7
23.3k
| is_div
bool 2
classes | is_type
null | is_proof
bool 2
classes | completed_definiton
stringlengths 1
250k
| dependencies
dict | effect_flags
sequencelengths 0
2
| ideal_premises
sequencelengths 0
236
| mutual_with
sequencelengths 0
11
| file_context
stringlengths 0
407k
| interleaved
bool 1
class | is_simply_typed
bool 2
classes | file_name
stringlengths 5
48
| vconfig
dict | is_simple_lemma
null | source_type
stringlengths 10
23k
| proof_features
sequencelengths 0
1
| name
stringlengths 8
95
| source
dict | verbose_type
stringlengths 1
7.42k
| source_range
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Prims.Tot | val finish_sha384:finish_st SHA2_384 | [
{
"abbrev": false,
"full_module": "EverCrypt.Hash.Incremental.Macros",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let finish_sha384: finish_st SHA2_384 = F.mk_finish evercrypt_hash SHA2_384 (EverCrypt.Hash.state SHA2_384) (G.erased unit) | val finish_sha384:finish_st SHA2_384
let finish_sha384:finish_st SHA2_384 = | false | null | false | F.mk_finish evercrypt_hash SHA2_384 (EverCrypt.Hash.state SHA2_384) (G.erased unit) | {
"checked_file": "EverCrypt.Hash.Incremental.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.MD5.fsti.checked",
"Hacl.Hash.MD.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Hash.Blake2.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"EverCrypt.TargetConfig.fsti.checked",
"EverCrypt.Hash.Incremental.Macros.fst.checked",
"EverCrypt.Hash.fsti.checked",
"EverCrypt.Error.fsti.checked",
"EverCrypt.AutoConfig2.fsti.checked"
],
"interface_file": false,
"source_file": "EverCrypt.Hash.Incremental.fst"
} | [
"total"
] | [
"Hacl.Streaming.Functor.mk_finish",
"Spec.Hash.Definitions.fixed_len_alg",
"EverCrypt.Hash.Incremental.evercrypt_hash",
"Spec.Hash.Definitions.SHA2_384",
"EverCrypt.Hash.state",
"FStar.Ghost.erased",
"Prims.unit"
] | [] | module EverCrypt.Hash.Incremental
open FStar.Mul
// Watch out: keep the module declarations in sync between fsti and fst
// (otherwise interleaving issues may bite).
module B = LowStar.Buffer
module S = FStar.Seq
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module G = FStar.Ghost
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module Hash = EverCrypt.Hash
open FStar.HyperStack.ST
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
include Spec.Hash.Definitions
include Hacl.Hash.Definitions
open Spec.Hash.Lemmas
#set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0"
// Definitions for instantiating the streaming functor
// ---------------------------------------------------
inline_for_extraction noextract
let agile_state: stateful Hash.alg =
Stateful
EverCrypt.Hash.state
(fun #i h s -> EverCrypt.Hash.footprint s h)
EverCrypt.Hash.freeable
(fun #i h s -> EverCrypt.Hash.invariant s h)
Spec.Hash.Definitions.words_state
(fun i h s -> EverCrypt.Hash.repr s h)
(fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h)
(fun #i l s h0 h1 ->
EverCrypt.Hash.frame_invariant l s h0 h1;
EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1)
(fun #i l s h0 h1 -> ())
EverCrypt.Hash.alloca
EverCrypt.Hash.create_in
(fun i -> EverCrypt.Hash.free #i)
(fun i -> EverCrypt.Hash.copy #i)
include EverCrypt.Hash.Incremental.Macros
#push-options "--ifuel 1"
(* Adding some non-inlined definitions to factorize code. This one is public
because it's used by the WASM API, and is generally useful to callers. *)
let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) =
match a with
| MD5 -> md5_hash_len
| SHA1 -> sha1_hash_len
| SHA2_224 -> sha2_224_hash_len
| SHA2_256 -> sha2_256_hash_len
| SHA2_384 -> sha2_384_hash_len
| SHA2_512 -> sha2_512_hash_len
| SHA3_224 -> sha3_224_hash_len
| SHA3_256 -> sha3_256_hash_len
| SHA3_384 -> sha3_384_hash_len
| SHA3_512 -> sha3_512_hash_len
| Blake2S -> blake2s_hash_len
| Blake2B -> blake2b_hash_len
#pop-options
private
let block_len a = Hacl.Hash.Definitions.block_len a
inline_for_extraction noextract
let extra_state_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }):
Spec.Hash.Definitions.extra_state a
=
if is_blake a then
i
else
()
inline_for_extraction noextract
let prev_length_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }):
Spec.Hash.Incremental.prev_length_t a
=
if is_keccak a then
()
else
i
#push-options "--z3rlimit 500"
inline_for_extraction noextract
let evercrypt_hash : block Hash.alg =
Block
Erased
agile_state
(stateful_unused Hash.alg)
unit
Hacl.Hash.Definitions.max_input_len64
(fun a () -> Spec.Hash.Definitions.hash_length a)
block_len
block_len // No vectorization
(fun _ -> 0ul)
(fun _ _ -> S.empty)
(fun a _ -> Spec.Agile.Hash.init a)
(fun a s prevlen input ->
let prevlen = extra_state_of_nat a prevlen in
Spec.Agile.Hash.update_multi a s prevlen input)
(fun a s prevlen input ->
let prevlen = prev_length_of_nat a prevlen in
Spec.Hash.Incremental.update_last a s prevlen input)
(fun a _ s () -> Spec.Agile.Hash.finish a s ())
(fun a _ s () -> Spec.Agile.Hash.hash a s)
(fun a s prevlen ->
if is_blake a then
Spec.Hash.Lemmas.update_multi_zero_blake a prevlen s
else
Spec.Hash.Lemmas.update_multi_zero a s)
(* update_multi_associative *)
(fun a s prevlen1 prevlen2 input1 input2 ->
if is_blake a then
Spec.Hash.Lemmas.update_multi_associative_blake a s prevlen1 prevlen2 input1 input2
else
Spec.Hash.Lemmas.update_multi_associative a s input1 input2)
(* spec_is_incremental *)
(fun a _ input () ->
let input1 = S.append S.empty input in
assert (S.equal input1 input);
Spec.Hash.Incremental.hash_is_hash_incremental' a input ())
EverCrypt.Hash.alg_of_state
(fun i _ _ -> EverCrypt.Hash.init #i)
(fun i s prevlen blocks len -> EverCrypt.Hash.update_multi #i s prevlen blocks len)
(fun i s prevlen last last_len ->
EverCrypt.Hash.update_last #i s prevlen last last_len)
(fun i _ s dst _ -> EverCrypt.Hash.finish #i s dst)
#pop-options
let hash_state =
F.state_s evercrypt_hash SHA2_256 ((agile_state).s SHA2_256) (G.erased unit)
// Public API (streaming)
// ----------------------
[@@ Comment
"Allocate initial state for the agile hash. The argument `a` stands for the
choice of algorithm (see Hacl_Spec.h). This API will automatically pick the most
efficient implementation, provided you have called EverCrypt_AutoConfig2_init()
before. The state is to be freed by calling `free`."]
let create_in a = F.create_in evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) ()
[@@ Comment
"Reset an existing state to the initial hash state with empty data."]
let init (a: G.erased Hash.alg) = F.init evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) ()
[@@ Comment
"Feed an arbitrary amount of data into the hash. This function returns
EverCrypt_Error_Success for success, or EverCrypt_Error_MaximumLengthExceeded if
the combined length of all of the data passed to `update` (since the last call
to `init`) exceeds 2^61-1 bytes or 2^64-1 bytes, depending on the choice of
algorithm. Both limits are unlikely to be attained in practice."]
let update (i: G.erased Hash.alg)
(s:F.state evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit))
(data: B.buffer uint8)
(len: UInt32.t):
Stack EverCrypt.Error.error_code
(requires fun h0 -> F.update_pre evercrypt_hash i s data len h0)
(ensures fun h0 e h1 ->
match e with
| EverCrypt.Error.Success ->
S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i) /\
F.update_post evercrypt_hash i s data len h0 h1
| EverCrypt.Error.MaximumLengthExceeded ->
h0 == h1 /\
not (S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i))
| _ -> False)
=
match F.update evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit) s data len with
| Hacl.Streaming.Types.Success -> EverCrypt.Error.Success
| Hacl.Streaming.Types.MaximumLengthExceeded -> EverCrypt.Error.MaximumLengthExceeded
inline_for_extraction noextract
let finish_st a = F.finish_st evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit)
/// The wrapper pattern, to ensure that the stack-allocated state is properly
/// monomorphized.
private
let finish_md5: finish_st MD5 = F.mk_finish evercrypt_hash MD5 (EverCrypt.Hash.state MD5) (G.erased unit)
private
let finish_sha1: finish_st SHA1 = F.mk_finish evercrypt_hash SHA1 (EverCrypt.Hash.state SHA1) (G.erased unit)
private
let finish_sha224: finish_st SHA2_224 = F.mk_finish evercrypt_hash SHA2_224 (EverCrypt.Hash.state SHA2_224) (G.erased unit)
private
let finish_sha256: finish_st SHA2_256 = F.mk_finish evercrypt_hash SHA2_256 (EverCrypt.Hash.state SHA2_256) (G.erased unit)
private
let finish_sha3_224: finish_st SHA3_224 = F.mk_finish evercrypt_hash SHA3_224 (EverCrypt.Hash.state SHA3_224) (G.erased unit)
private
let finish_sha3_256: finish_st SHA3_256 = F.mk_finish evercrypt_hash SHA3_256 (EverCrypt.Hash.state SHA3_256) (G.erased unit)
private
let finish_sha3_384: finish_st SHA3_384 = F.mk_finish evercrypt_hash SHA3_384 (EverCrypt.Hash.state SHA3_384) (G.erased unit)
private
let finish_sha3_512: finish_st SHA3_512 = F.mk_finish evercrypt_hash SHA3_512 (EverCrypt.Hash.state SHA3_512) (G.erased unit) | false | false | EverCrypt.Hash.Incremental.fst | {
"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": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val finish_sha384:finish_st SHA2_384 | [] | EverCrypt.Hash.Incremental.finish_sha384 | {
"file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | EverCrypt.Hash.Incremental.finish_st Spec.Hash.Definitions.SHA2_384 | {
"end_col": 123,
"end_line": 217,
"start_col": 40,
"start_line": 217
} |
Prims.Tot | val finish_sha3_512:finish_st SHA3_512 | [
{
"abbrev": false,
"full_module": "EverCrypt.Hash.Incremental.Macros",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let finish_sha3_512: finish_st SHA3_512 = F.mk_finish evercrypt_hash SHA3_512 (EverCrypt.Hash.state SHA3_512) (G.erased unit) | val finish_sha3_512:finish_st SHA3_512
let finish_sha3_512:finish_st SHA3_512 = | false | null | false | F.mk_finish evercrypt_hash SHA3_512 (EverCrypt.Hash.state SHA3_512) (G.erased unit) | {
"checked_file": "EverCrypt.Hash.Incremental.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.MD5.fsti.checked",
"Hacl.Hash.MD.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Hash.Blake2.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"EverCrypt.TargetConfig.fsti.checked",
"EverCrypt.Hash.Incremental.Macros.fst.checked",
"EverCrypt.Hash.fsti.checked",
"EverCrypt.Error.fsti.checked",
"EverCrypt.AutoConfig2.fsti.checked"
],
"interface_file": false,
"source_file": "EverCrypt.Hash.Incremental.fst"
} | [
"total"
] | [
"Hacl.Streaming.Functor.mk_finish",
"Spec.Hash.Definitions.fixed_len_alg",
"EverCrypt.Hash.Incremental.evercrypt_hash",
"Spec.Hash.Definitions.SHA3_512",
"EverCrypt.Hash.state",
"FStar.Ghost.erased",
"Prims.unit"
] | [] | module EverCrypt.Hash.Incremental
open FStar.Mul
// Watch out: keep the module declarations in sync between fsti and fst
// (otherwise interleaving issues may bite).
module B = LowStar.Buffer
module S = FStar.Seq
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module G = FStar.Ghost
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module Hash = EverCrypt.Hash
open FStar.HyperStack.ST
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
include Spec.Hash.Definitions
include Hacl.Hash.Definitions
open Spec.Hash.Lemmas
#set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0"
// Definitions for instantiating the streaming functor
// ---------------------------------------------------
inline_for_extraction noextract
let agile_state: stateful Hash.alg =
Stateful
EverCrypt.Hash.state
(fun #i h s -> EverCrypt.Hash.footprint s h)
EverCrypt.Hash.freeable
(fun #i h s -> EverCrypt.Hash.invariant s h)
Spec.Hash.Definitions.words_state
(fun i h s -> EverCrypt.Hash.repr s h)
(fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h)
(fun #i l s h0 h1 ->
EverCrypt.Hash.frame_invariant l s h0 h1;
EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1)
(fun #i l s h0 h1 -> ())
EverCrypt.Hash.alloca
EverCrypt.Hash.create_in
(fun i -> EverCrypt.Hash.free #i)
(fun i -> EverCrypt.Hash.copy #i)
include EverCrypt.Hash.Incremental.Macros
#push-options "--ifuel 1"
(* Adding some non-inlined definitions to factorize code. This one is public
because it's used by the WASM API, and is generally useful to callers. *)
let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) =
match a with
| MD5 -> md5_hash_len
| SHA1 -> sha1_hash_len
| SHA2_224 -> sha2_224_hash_len
| SHA2_256 -> sha2_256_hash_len
| SHA2_384 -> sha2_384_hash_len
| SHA2_512 -> sha2_512_hash_len
| SHA3_224 -> sha3_224_hash_len
| SHA3_256 -> sha3_256_hash_len
| SHA3_384 -> sha3_384_hash_len
| SHA3_512 -> sha3_512_hash_len
| Blake2S -> blake2s_hash_len
| Blake2B -> blake2b_hash_len
#pop-options
private
let block_len a = Hacl.Hash.Definitions.block_len a
inline_for_extraction noextract
let extra_state_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }):
Spec.Hash.Definitions.extra_state a
=
if is_blake a then
i
else
()
inline_for_extraction noextract
let prev_length_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }):
Spec.Hash.Incremental.prev_length_t a
=
if is_keccak a then
()
else
i
#push-options "--z3rlimit 500"
inline_for_extraction noextract
let evercrypt_hash : block Hash.alg =
Block
Erased
agile_state
(stateful_unused Hash.alg)
unit
Hacl.Hash.Definitions.max_input_len64
(fun a () -> Spec.Hash.Definitions.hash_length a)
block_len
block_len // No vectorization
(fun _ -> 0ul)
(fun _ _ -> S.empty)
(fun a _ -> Spec.Agile.Hash.init a)
(fun a s prevlen input ->
let prevlen = extra_state_of_nat a prevlen in
Spec.Agile.Hash.update_multi a s prevlen input)
(fun a s prevlen input ->
let prevlen = prev_length_of_nat a prevlen in
Spec.Hash.Incremental.update_last a s prevlen input)
(fun a _ s () -> Spec.Agile.Hash.finish a s ())
(fun a _ s () -> Spec.Agile.Hash.hash a s)
(fun a s prevlen ->
if is_blake a then
Spec.Hash.Lemmas.update_multi_zero_blake a prevlen s
else
Spec.Hash.Lemmas.update_multi_zero a s)
(* update_multi_associative *)
(fun a s prevlen1 prevlen2 input1 input2 ->
if is_blake a then
Spec.Hash.Lemmas.update_multi_associative_blake a s prevlen1 prevlen2 input1 input2
else
Spec.Hash.Lemmas.update_multi_associative a s input1 input2)
(* spec_is_incremental *)
(fun a _ input () ->
let input1 = S.append S.empty input in
assert (S.equal input1 input);
Spec.Hash.Incremental.hash_is_hash_incremental' a input ())
EverCrypt.Hash.alg_of_state
(fun i _ _ -> EverCrypt.Hash.init #i)
(fun i s prevlen blocks len -> EverCrypt.Hash.update_multi #i s prevlen blocks len)
(fun i s prevlen last last_len ->
EverCrypt.Hash.update_last #i s prevlen last last_len)
(fun i _ s dst _ -> EverCrypt.Hash.finish #i s dst)
#pop-options
let hash_state =
F.state_s evercrypt_hash SHA2_256 ((agile_state).s SHA2_256) (G.erased unit)
// Public API (streaming)
// ----------------------
[@@ Comment
"Allocate initial state for the agile hash. The argument `a` stands for the
choice of algorithm (see Hacl_Spec.h). This API will automatically pick the most
efficient implementation, provided you have called EverCrypt_AutoConfig2_init()
before. The state is to be freed by calling `free`."]
let create_in a = F.create_in evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) ()
[@@ Comment
"Reset an existing state to the initial hash state with empty data."]
let init (a: G.erased Hash.alg) = F.init evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) ()
[@@ Comment
"Feed an arbitrary amount of data into the hash. This function returns
EverCrypt_Error_Success for success, or EverCrypt_Error_MaximumLengthExceeded if
the combined length of all of the data passed to `update` (since the last call
to `init`) exceeds 2^61-1 bytes or 2^64-1 bytes, depending on the choice of
algorithm. Both limits are unlikely to be attained in practice."]
let update (i: G.erased Hash.alg)
(s:F.state evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit))
(data: B.buffer uint8)
(len: UInt32.t):
Stack EverCrypt.Error.error_code
(requires fun h0 -> F.update_pre evercrypt_hash i s data len h0)
(ensures fun h0 e h1 ->
match e with
| EverCrypt.Error.Success ->
S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i) /\
F.update_post evercrypt_hash i s data len h0 h1
| EverCrypt.Error.MaximumLengthExceeded ->
h0 == h1 /\
not (S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i))
| _ -> False)
=
match F.update evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit) s data len with
| Hacl.Streaming.Types.Success -> EverCrypt.Error.Success
| Hacl.Streaming.Types.MaximumLengthExceeded -> EverCrypt.Error.MaximumLengthExceeded
inline_for_extraction noextract
let finish_st a = F.finish_st evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit)
/// The wrapper pattern, to ensure that the stack-allocated state is properly
/// monomorphized.
private
let finish_md5: finish_st MD5 = F.mk_finish evercrypt_hash MD5 (EverCrypt.Hash.state MD5) (G.erased unit)
private
let finish_sha1: finish_st SHA1 = F.mk_finish evercrypt_hash SHA1 (EverCrypt.Hash.state SHA1) (G.erased unit)
private
let finish_sha224: finish_st SHA2_224 = F.mk_finish evercrypt_hash SHA2_224 (EverCrypt.Hash.state SHA2_224) (G.erased unit)
private
let finish_sha256: finish_st SHA2_256 = F.mk_finish evercrypt_hash SHA2_256 (EverCrypt.Hash.state SHA2_256) (G.erased unit)
private
let finish_sha3_224: finish_st SHA3_224 = F.mk_finish evercrypt_hash SHA3_224 (EverCrypt.Hash.state SHA3_224) (G.erased unit)
private
let finish_sha3_256: finish_st SHA3_256 = F.mk_finish evercrypt_hash SHA3_256 (EverCrypt.Hash.state SHA3_256) (G.erased unit)
private
let finish_sha3_384: finish_st SHA3_384 = F.mk_finish evercrypt_hash SHA3_384 (EverCrypt.Hash.state SHA3_384) (G.erased unit) | false | false | EverCrypt.Hash.Incremental.fst | {
"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": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val finish_sha3_512:finish_st SHA3_512 | [] | EverCrypt.Hash.Incremental.finish_sha3_512 | {
"file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | EverCrypt.Hash.Incremental.finish_st Spec.Hash.Definitions.SHA3_512 | {
"end_col": 125,
"end_line": 215,
"start_col": 42,
"start_line": 215
} |
Prims.Tot | val finish_sha3_384:finish_st SHA3_384 | [
{
"abbrev": false,
"full_module": "EverCrypt.Hash.Incremental.Macros",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let finish_sha3_384: finish_st SHA3_384 = F.mk_finish evercrypt_hash SHA3_384 (EverCrypt.Hash.state SHA3_384) (G.erased unit) | val finish_sha3_384:finish_st SHA3_384
let finish_sha3_384:finish_st SHA3_384 = | false | null | false | F.mk_finish evercrypt_hash SHA3_384 (EverCrypt.Hash.state SHA3_384) (G.erased unit) | {
"checked_file": "EverCrypt.Hash.Incremental.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.MD5.fsti.checked",
"Hacl.Hash.MD.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Hash.Blake2.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"EverCrypt.TargetConfig.fsti.checked",
"EverCrypt.Hash.Incremental.Macros.fst.checked",
"EverCrypt.Hash.fsti.checked",
"EverCrypt.Error.fsti.checked",
"EverCrypt.AutoConfig2.fsti.checked"
],
"interface_file": false,
"source_file": "EverCrypt.Hash.Incremental.fst"
} | [
"total"
] | [
"Hacl.Streaming.Functor.mk_finish",
"Spec.Hash.Definitions.fixed_len_alg",
"EverCrypt.Hash.Incremental.evercrypt_hash",
"Spec.Hash.Definitions.SHA3_384",
"EverCrypt.Hash.state",
"FStar.Ghost.erased",
"Prims.unit"
] | [] | module EverCrypt.Hash.Incremental
open FStar.Mul
// Watch out: keep the module declarations in sync between fsti and fst
// (otherwise interleaving issues may bite).
module B = LowStar.Buffer
module S = FStar.Seq
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module G = FStar.Ghost
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module Hash = EverCrypt.Hash
open FStar.HyperStack.ST
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
include Spec.Hash.Definitions
include Hacl.Hash.Definitions
open Spec.Hash.Lemmas
#set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0"
// Definitions for instantiating the streaming functor
// ---------------------------------------------------
inline_for_extraction noextract
let agile_state: stateful Hash.alg =
Stateful
EverCrypt.Hash.state
(fun #i h s -> EverCrypt.Hash.footprint s h)
EverCrypt.Hash.freeable
(fun #i h s -> EverCrypt.Hash.invariant s h)
Spec.Hash.Definitions.words_state
(fun i h s -> EverCrypt.Hash.repr s h)
(fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h)
(fun #i l s h0 h1 ->
EverCrypt.Hash.frame_invariant l s h0 h1;
EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1)
(fun #i l s h0 h1 -> ())
EverCrypt.Hash.alloca
EverCrypt.Hash.create_in
(fun i -> EverCrypt.Hash.free #i)
(fun i -> EverCrypt.Hash.copy #i)
include EverCrypt.Hash.Incremental.Macros
#push-options "--ifuel 1"
(* Adding some non-inlined definitions to factorize code. This one is public
because it's used by the WASM API, and is generally useful to callers. *)
let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) =
match a with
| MD5 -> md5_hash_len
| SHA1 -> sha1_hash_len
| SHA2_224 -> sha2_224_hash_len
| SHA2_256 -> sha2_256_hash_len
| SHA2_384 -> sha2_384_hash_len
| SHA2_512 -> sha2_512_hash_len
| SHA3_224 -> sha3_224_hash_len
| SHA3_256 -> sha3_256_hash_len
| SHA3_384 -> sha3_384_hash_len
| SHA3_512 -> sha3_512_hash_len
| Blake2S -> blake2s_hash_len
| Blake2B -> blake2b_hash_len
#pop-options
private
let block_len a = Hacl.Hash.Definitions.block_len a
inline_for_extraction noextract
let extra_state_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }):
Spec.Hash.Definitions.extra_state a
=
if is_blake a then
i
else
()
inline_for_extraction noextract
let prev_length_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }):
Spec.Hash.Incremental.prev_length_t a
=
if is_keccak a then
()
else
i
#push-options "--z3rlimit 500"
inline_for_extraction noextract
let evercrypt_hash : block Hash.alg =
Block
Erased
agile_state
(stateful_unused Hash.alg)
unit
Hacl.Hash.Definitions.max_input_len64
(fun a () -> Spec.Hash.Definitions.hash_length a)
block_len
block_len // No vectorization
(fun _ -> 0ul)
(fun _ _ -> S.empty)
(fun a _ -> Spec.Agile.Hash.init a)
(fun a s prevlen input ->
let prevlen = extra_state_of_nat a prevlen in
Spec.Agile.Hash.update_multi a s prevlen input)
(fun a s prevlen input ->
let prevlen = prev_length_of_nat a prevlen in
Spec.Hash.Incremental.update_last a s prevlen input)
(fun a _ s () -> Spec.Agile.Hash.finish a s ())
(fun a _ s () -> Spec.Agile.Hash.hash a s)
(fun a s prevlen ->
if is_blake a then
Spec.Hash.Lemmas.update_multi_zero_blake a prevlen s
else
Spec.Hash.Lemmas.update_multi_zero a s)
(* update_multi_associative *)
(fun a s prevlen1 prevlen2 input1 input2 ->
if is_blake a then
Spec.Hash.Lemmas.update_multi_associative_blake a s prevlen1 prevlen2 input1 input2
else
Spec.Hash.Lemmas.update_multi_associative a s input1 input2)
(* spec_is_incremental *)
(fun a _ input () ->
let input1 = S.append S.empty input in
assert (S.equal input1 input);
Spec.Hash.Incremental.hash_is_hash_incremental' a input ())
EverCrypt.Hash.alg_of_state
(fun i _ _ -> EverCrypt.Hash.init #i)
(fun i s prevlen blocks len -> EverCrypt.Hash.update_multi #i s prevlen blocks len)
(fun i s prevlen last last_len ->
EverCrypt.Hash.update_last #i s prevlen last last_len)
(fun i _ s dst _ -> EverCrypt.Hash.finish #i s dst)
#pop-options
let hash_state =
F.state_s evercrypt_hash SHA2_256 ((agile_state).s SHA2_256) (G.erased unit)
// Public API (streaming)
// ----------------------
[@@ Comment
"Allocate initial state for the agile hash. The argument `a` stands for the
choice of algorithm (see Hacl_Spec.h). This API will automatically pick the most
efficient implementation, provided you have called EverCrypt_AutoConfig2_init()
before. The state is to be freed by calling `free`."]
let create_in a = F.create_in evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) ()
[@@ Comment
"Reset an existing state to the initial hash state with empty data."]
let init (a: G.erased Hash.alg) = F.init evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) ()
[@@ Comment
"Feed an arbitrary amount of data into the hash. This function returns
EverCrypt_Error_Success for success, or EverCrypt_Error_MaximumLengthExceeded if
the combined length of all of the data passed to `update` (since the last call
to `init`) exceeds 2^61-1 bytes or 2^64-1 bytes, depending on the choice of
algorithm. Both limits are unlikely to be attained in practice."]
let update (i: G.erased Hash.alg)
(s:F.state evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit))
(data: B.buffer uint8)
(len: UInt32.t):
Stack EverCrypt.Error.error_code
(requires fun h0 -> F.update_pre evercrypt_hash i s data len h0)
(ensures fun h0 e h1 ->
match e with
| EverCrypt.Error.Success ->
S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i) /\
F.update_post evercrypt_hash i s data len h0 h1
| EverCrypt.Error.MaximumLengthExceeded ->
h0 == h1 /\
not (S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i))
| _ -> False)
=
match F.update evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit) s data len with
| Hacl.Streaming.Types.Success -> EverCrypt.Error.Success
| Hacl.Streaming.Types.MaximumLengthExceeded -> EverCrypt.Error.MaximumLengthExceeded
inline_for_extraction noextract
let finish_st a = F.finish_st evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit)
/// The wrapper pattern, to ensure that the stack-allocated state is properly
/// monomorphized.
private
let finish_md5: finish_st MD5 = F.mk_finish evercrypt_hash MD5 (EverCrypt.Hash.state MD5) (G.erased unit)
private
let finish_sha1: finish_st SHA1 = F.mk_finish evercrypt_hash SHA1 (EverCrypt.Hash.state SHA1) (G.erased unit)
private
let finish_sha224: finish_st SHA2_224 = F.mk_finish evercrypt_hash SHA2_224 (EverCrypt.Hash.state SHA2_224) (G.erased unit)
private
let finish_sha256: finish_st SHA2_256 = F.mk_finish evercrypt_hash SHA2_256 (EverCrypt.Hash.state SHA2_256) (G.erased unit)
private
let finish_sha3_224: finish_st SHA3_224 = F.mk_finish evercrypt_hash SHA3_224 (EverCrypt.Hash.state SHA3_224) (G.erased unit)
private
let finish_sha3_256: finish_st SHA3_256 = F.mk_finish evercrypt_hash SHA3_256 (EverCrypt.Hash.state SHA3_256) (G.erased unit) | false | false | EverCrypt.Hash.Incremental.fst | {
"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": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val finish_sha3_384:finish_st SHA3_384 | [] | EverCrypt.Hash.Incremental.finish_sha3_384 | {
"file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | EverCrypt.Hash.Incremental.finish_st Spec.Hash.Definitions.SHA3_384 | {
"end_col": 125,
"end_line": 213,
"start_col": 42,
"start_line": 213
} |
Prims.Tot | val finish_blake2b:finish_st Blake2B | [
{
"abbrev": false,
"full_module": "EverCrypt.Hash.Incremental.Macros",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let finish_blake2b: finish_st Blake2B = F.mk_finish evercrypt_hash Blake2B (EverCrypt.Hash.state Blake2B) (G.erased unit) | val finish_blake2b:finish_st Blake2B
let finish_blake2b:finish_st Blake2B = | false | null | false | F.mk_finish evercrypt_hash Blake2B (EverCrypt.Hash.state Blake2B) (G.erased unit) | {
"checked_file": "EverCrypt.Hash.Incremental.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.MD5.fsti.checked",
"Hacl.Hash.MD.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Hash.Blake2.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"EverCrypt.TargetConfig.fsti.checked",
"EverCrypt.Hash.Incremental.Macros.fst.checked",
"EverCrypt.Hash.fsti.checked",
"EverCrypt.Error.fsti.checked",
"EverCrypt.AutoConfig2.fsti.checked"
],
"interface_file": false,
"source_file": "EverCrypt.Hash.Incremental.fst"
} | [
"total"
] | [
"Hacl.Streaming.Functor.mk_finish",
"Spec.Hash.Definitions.fixed_len_alg",
"EverCrypt.Hash.Incremental.evercrypt_hash",
"Spec.Hash.Definitions.Blake2B",
"EverCrypt.Hash.state",
"FStar.Ghost.erased",
"Prims.unit"
] | [] | module EverCrypt.Hash.Incremental
open FStar.Mul
// Watch out: keep the module declarations in sync between fsti and fst
// (otherwise interleaving issues may bite).
module B = LowStar.Buffer
module S = FStar.Seq
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module G = FStar.Ghost
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module Hash = EverCrypt.Hash
open FStar.HyperStack.ST
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
include Spec.Hash.Definitions
include Hacl.Hash.Definitions
open Spec.Hash.Lemmas
#set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0"
// Definitions for instantiating the streaming functor
// ---------------------------------------------------
inline_for_extraction noextract
let agile_state: stateful Hash.alg =
Stateful
EverCrypt.Hash.state
(fun #i h s -> EverCrypt.Hash.footprint s h)
EverCrypt.Hash.freeable
(fun #i h s -> EverCrypt.Hash.invariant s h)
Spec.Hash.Definitions.words_state
(fun i h s -> EverCrypt.Hash.repr s h)
(fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h)
(fun #i l s h0 h1 ->
EverCrypt.Hash.frame_invariant l s h0 h1;
EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1)
(fun #i l s h0 h1 -> ())
EverCrypt.Hash.alloca
EverCrypt.Hash.create_in
(fun i -> EverCrypt.Hash.free #i)
(fun i -> EverCrypt.Hash.copy #i)
include EverCrypt.Hash.Incremental.Macros
#push-options "--ifuel 1"
(* Adding some non-inlined definitions to factorize code. This one is public
because it's used by the WASM API, and is generally useful to callers. *)
let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) =
match a with
| MD5 -> md5_hash_len
| SHA1 -> sha1_hash_len
| SHA2_224 -> sha2_224_hash_len
| SHA2_256 -> sha2_256_hash_len
| SHA2_384 -> sha2_384_hash_len
| SHA2_512 -> sha2_512_hash_len
| SHA3_224 -> sha3_224_hash_len
| SHA3_256 -> sha3_256_hash_len
| SHA3_384 -> sha3_384_hash_len
| SHA3_512 -> sha3_512_hash_len
| Blake2S -> blake2s_hash_len
| Blake2B -> blake2b_hash_len
#pop-options
private
let block_len a = Hacl.Hash.Definitions.block_len a
inline_for_extraction noextract
let extra_state_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }):
Spec.Hash.Definitions.extra_state a
=
if is_blake a then
i
else
()
inline_for_extraction noextract
let prev_length_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }):
Spec.Hash.Incremental.prev_length_t a
=
if is_keccak a then
()
else
i
#push-options "--z3rlimit 500"
inline_for_extraction noextract
let evercrypt_hash : block Hash.alg =
Block
Erased
agile_state
(stateful_unused Hash.alg)
unit
Hacl.Hash.Definitions.max_input_len64
(fun a () -> Spec.Hash.Definitions.hash_length a)
block_len
block_len // No vectorization
(fun _ -> 0ul)
(fun _ _ -> S.empty)
(fun a _ -> Spec.Agile.Hash.init a)
(fun a s prevlen input ->
let prevlen = extra_state_of_nat a prevlen in
Spec.Agile.Hash.update_multi a s prevlen input)
(fun a s prevlen input ->
let prevlen = prev_length_of_nat a prevlen in
Spec.Hash.Incremental.update_last a s prevlen input)
(fun a _ s () -> Spec.Agile.Hash.finish a s ())
(fun a _ s () -> Spec.Agile.Hash.hash a s)
(fun a s prevlen ->
if is_blake a then
Spec.Hash.Lemmas.update_multi_zero_blake a prevlen s
else
Spec.Hash.Lemmas.update_multi_zero a s)
(* update_multi_associative *)
(fun a s prevlen1 prevlen2 input1 input2 ->
if is_blake a then
Spec.Hash.Lemmas.update_multi_associative_blake a s prevlen1 prevlen2 input1 input2
else
Spec.Hash.Lemmas.update_multi_associative a s input1 input2)
(* spec_is_incremental *)
(fun a _ input () ->
let input1 = S.append S.empty input in
assert (S.equal input1 input);
Spec.Hash.Incremental.hash_is_hash_incremental' a input ())
EverCrypt.Hash.alg_of_state
(fun i _ _ -> EverCrypt.Hash.init #i)
(fun i s prevlen blocks len -> EverCrypt.Hash.update_multi #i s prevlen blocks len)
(fun i s prevlen last last_len ->
EverCrypt.Hash.update_last #i s prevlen last last_len)
(fun i _ s dst _ -> EverCrypt.Hash.finish #i s dst)
#pop-options
let hash_state =
F.state_s evercrypt_hash SHA2_256 ((agile_state).s SHA2_256) (G.erased unit)
// Public API (streaming)
// ----------------------
[@@ Comment
"Allocate initial state for the agile hash. The argument `a` stands for the
choice of algorithm (see Hacl_Spec.h). This API will automatically pick the most
efficient implementation, provided you have called EverCrypt_AutoConfig2_init()
before. The state is to be freed by calling `free`."]
let create_in a = F.create_in evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) ()
[@@ Comment
"Reset an existing state to the initial hash state with empty data."]
let init (a: G.erased Hash.alg) = F.init evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) ()
[@@ Comment
"Feed an arbitrary amount of data into the hash. This function returns
EverCrypt_Error_Success for success, or EverCrypt_Error_MaximumLengthExceeded if
the combined length of all of the data passed to `update` (since the last call
to `init`) exceeds 2^61-1 bytes or 2^64-1 bytes, depending on the choice of
algorithm. Both limits are unlikely to be attained in practice."]
let update (i: G.erased Hash.alg)
(s:F.state evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit))
(data: B.buffer uint8)
(len: UInt32.t):
Stack EverCrypt.Error.error_code
(requires fun h0 -> F.update_pre evercrypt_hash i s data len h0)
(ensures fun h0 e h1 ->
match e with
| EverCrypt.Error.Success ->
S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i) /\
F.update_post evercrypt_hash i s data len h0 h1
| EverCrypt.Error.MaximumLengthExceeded ->
h0 == h1 /\
not (S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i))
| _ -> False)
=
match F.update evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit) s data len with
| Hacl.Streaming.Types.Success -> EverCrypt.Error.Success
| Hacl.Streaming.Types.MaximumLengthExceeded -> EverCrypt.Error.MaximumLengthExceeded
inline_for_extraction noextract
let finish_st a = F.finish_st evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit)
/// The wrapper pattern, to ensure that the stack-allocated state is properly
/// monomorphized.
private
let finish_md5: finish_st MD5 = F.mk_finish evercrypt_hash MD5 (EverCrypt.Hash.state MD5) (G.erased unit)
private
let finish_sha1: finish_st SHA1 = F.mk_finish evercrypt_hash SHA1 (EverCrypt.Hash.state SHA1) (G.erased unit)
private
let finish_sha224: finish_st SHA2_224 = F.mk_finish evercrypt_hash SHA2_224 (EverCrypt.Hash.state SHA2_224) (G.erased unit)
private
let finish_sha256: finish_st SHA2_256 = F.mk_finish evercrypt_hash SHA2_256 (EverCrypt.Hash.state SHA2_256) (G.erased unit)
private
let finish_sha3_224: finish_st SHA3_224 = F.mk_finish evercrypt_hash SHA3_224 (EverCrypt.Hash.state SHA3_224) (G.erased unit)
private
let finish_sha3_256: finish_st SHA3_256 = F.mk_finish evercrypt_hash SHA3_256 (EverCrypt.Hash.state SHA3_256) (G.erased unit)
private
let finish_sha3_384: finish_st SHA3_384 = F.mk_finish evercrypt_hash SHA3_384 (EverCrypt.Hash.state SHA3_384) (G.erased unit)
private
let finish_sha3_512: finish_st SHA3_512 = F.mk_finish evercrypt_hash SHA3_512 (EverCrypt.Hash.state SHA3_512) (G.erased unit)
private
let finish_sha384: finish_st SHA2_384 = F.mk_finish evercrypt_hash SHA2_384 (EverCrypt.Hash.state SHA2_384) (G.erased unit)
private
let finish_sha512: finish_st SHA2_512 = F.mk_finish evercrypt_hash SHA2_512 (EverCrypt.Hash.state SHA2_512) (G.erased unit)
private
let finish_blake2s: finish_st Blake2S = F.mk_finish evercrypt_hash Blake2S (EverCrypt.Hash.state Blake2S) (G.erased unit) | false | false | EverCrypt.Hash.Incremental.fst | {
"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": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val finish_blake2b:finish_st Blake2B | [] | EverCrypt.Hash.Incremental.finish_blake2b | {
"file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | EverCrypt.Hash.Incremental.finish_st Spec.Hash.Definitions.Blake2B | {
"end_col": 121,
"end_line": 223,
"start_col": 40,
"start_line": 223
} |
Prims.Tot | val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224 | [
{
"abbrev": false,
"full_module": "EverCrypt.Hash.Incremental.Macros",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_224 input input_len dst =
let open EverCrypt.Hash in
Hacl.Hash.MD.mk_hash SHA2_224 Hacl.Hash.SHA2.alloca_224 update_multi_224
Hacl.Hash.SHA2.update_last_224 Hacl.Hash.SHA2.finish_224 input input_len dst | val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224
let hash_224 input input_len dst = | false | null | false | let open EverCrypt.Hash in
Hacl.Hash.MD.mk_hash SHA2_224
Hacl.Hash.SHA2.alloca_224
update_multi_224
Hacl.Hash.SHA2.update_last_224
Hacl.Hash.SHA2.finish_224
input
input_len
dst | {
"checked_file": "EverCrypt.Hash.Incremental.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.MD5.fsti.checked",
"Hacl.Hash.MD.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Hash.Blake2.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"EverCrypt.TargetConfig.fsti.checked",
"EverCrypt.Hash.Incremental.Macros.fst.checked",
"EverCrypt.Hash.fsti.checked",
"EverCrypt.Error.fsti.checked",
"EverCrypt.AutoConfig2.fsti.checked"
],
"interface_file": false,
"source_file": "EverCrypt.Hash.Incremental.fst"
} | [
"total"
] | [
"LowStar.Buffer.buffer",
"Lib.IntTypes.uint8",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"LowStar.Monotonic.Buffer.length",
"LowStar.Buffer.trivial_preorder",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Hacl.Hash.Definitions.hash_t",
"Spec.Hash.Definitions.SHA2_224",
"Hacl.Hash.MD.mk_hash",
"Hacl.Hash.SHA2.alloca_224",
"EverCrypt.Hash.update_multi_224",
"Hacl.Hash.SHA2.update_last_224",
"Hacl.Hash.SHA2.finish_224",
"Prims.unit"
] | [] | module EverCrypt.Hash.Incremental
open FStar.Mul
// Watch out: keep the module declarations in sync between fsti and fst
// (otherwise interleaving issues may bite).
module B = LowStar.Buffer
module S = FStar.Seq
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module G = FStar.Ghost
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module Hash = EverCrypt.Hash
open FStar.HyperStack.ST
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
include Spec.Hash.Definitions
include Hacl.Hash.Definitions
open Spec.Hash.Lemmas
#set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0"
// Definitions for instantiating the streaming functor
// ---------------------------------------------------
inline_for_extraction noextract
let agile_state: stateful Hash.alg =
Stateful
EverCrypt.Hash.state
(fun #i h s -> EverCrypt.Hash.footprint s h)
EverCrypt.Hash.freeable
(fun #i h s -> EverCrypt.Hash.invariant s h)
Spec.Hash.Definitions.words_state
(fun i h s -> EverCrypt.Hash.repr s h)
(fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h)
(fun #i l s h0 h1 ->
EverCrypt.Hash.frame_invariant l s h0 h1;
EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1)
(fun #i l s h0 h1 -> ())
EverCrypt.Hash.alloca
EverCrypt.Hash.create_in
(fun i -> EverCrypt.Hash.free #i)
(fun i -> EverCrypt.Hash.copy #i)
include EverCrypt.Hash.Incremental.Macros
#push-options "--ifuel 1"
(* Adding some non-inlined definitions to factorize code. This one is public
because it's used by the WASM API, and is generally useful to callers. *)
let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) =
match a with
| MD5 -> md5_hash_len
| SHA1 -> sha1_hash_len
| SHA2_224 -> sha2_224_hash_len
| SHA2_256 -> sha2_256_hash_len
| SHA2_384 -> sha2_384_hash_len
| SHA2_512 -> sha2_512_hash_len
| SHA3_224 -> sha3_224_hash_len
| SHA3_256 -> sha3_256_hash_len
| SHA3_384 -> sha3_384_hash_len
| SHA3_512 -> sha3_512_hash_len
| Blake2S -> blake2s_hash_len
| Blake2B -> blake2b_hash_len
#pop-options
private
let block_len a = Hacl.Hash.Definitions.block_len a
inline_for_extraction noextract
let extra_state_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }):
Spec.Hash.Definitions.extra_state a
=
if is_blake a then
i
else
()
inline_for_extraction noextract
let prev_length_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }):
Spec.Hash.Incremental.prev_length_t a
=
if is_keccak a then
()
else
i
#push-options "--z3rlimit 500"
inline_for_extraction noextract
let evercrypt_hash : block Hash.alg =
Block
Erased
agile_state
(stateful_unused Hash.alg)
unit
Hacl.Hash.Definitions.max_input_len64
(fun a () -> Spec.Hash.Definitions.hash_length a)
block_len
block_len // No vectorization
(fun _ -> 0ul)
(fun _ _ -> S.empty)
(fun a _ -> Spec.Agile.Hash.init a)
(fun a s prevlen input ->
let prevlen = extra_state_of_nat a prevlen in
Spec.Agile.Hash.update_multi a s prevlen input)
(fun a s prevlen input ->
let prevlen = prev_length_of_nat a prevlen in
Spec.Hash.Incremental.update_last a s prevlen input)
(fun a _ s () -> Spec.Agile.Hash.finish a s ())
(fun a _ s () -> Spec.Agile.Hash.hash a s)
(fun a s prevlen ->
if is_blake a then
Spec.Hash.Lemmas.update_multi_zero_blake a prevlen s
else
Spec.Hash.Lemmas.update_multi_zero a s)
(* update_multi_associative *)
(fun a s prevlen1 prevlen2 input1 input2 ->
if is_blake a then
Spec.Hash.Lemmas.update_multi_associative_blake a s prevlen1 prevlen2 input1 input2
else
Spec.Hash.Lemmas.update_multi_associative a s input1 input2)
(* spec_is_incremental *)
(fun a _ input () ->
let input1 = S.append S.empty input in
assert (S.equal input1 input);
Spec.Hash.Incremental.hash_is_hash_incremental' a input ())
EverCrypt.Hash.alg_of_state
(fun i _ _ -> EverCrypt.Hash.init #i)
(fun i s prevlen blocks len -> EverCrypt.Hash.update_multi #i s prevlen blocks len)
(fun i s prevlen last last_len ->
EverCrypt.Hash.update_last #i s prevlen last last_len)
(fun i _ s dst _ -> EverCrypt.Hash.finish #i s dst)
#pop-options
let hash_state =
F.state_s evercrypt_hash SHA2_256 ((agile_state).s SHA2_256) (G.erased unit)
// Public API (streaming)
// ----------------------
[@@ Comment
"Allocate initial state for the agile hash. The argument `a` stands for the
choice of algorithm (see Hacl_Spec.h). This API will automatically pick the most
efficient implementation, provided you have called EverCrypt_AutoConfig2_init()
before. The state is to be freed by calling `free`."]
let create_in a = F.create_in evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) ()
[@@ Comment
"Reset an existing state to the initial hash state with empty data."]
let init (a: G.erased Hash.alg) = F.init evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) ()
[@@ Comment
"Feed an arbitrary amount of data into the hash. This function returns
EverCrypt_Error_Success for success, or EverCrypt_Error_MaximumLengthExceeded if
the combined length of all of the data passed to `update` (since the last call
to `init`) exceeds 2^61-1 bytes or 2^64-1 bytes, depending on the choice of
algorithm. Both limits are unlikely to be attained in practice."]
let update (i: G.erased Hash.alg)
(s:F.state evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit))
(data: B.buffer uint8)
(len: UInt32.t):
Stack EverCrypt.Error.error_code
(requires fun h0 -> F.update_pre evercrypt_hash i s data len h0)
(ensures fun h0 e h1 ->
match e with
| EverCrypt.Error.Success ->
S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i) /\
F.update_post evercrypt_hash i s data len h0 h1
| EverCrypt.Error.MaximumLengthExceeded ->
h0 == h1 /\
not (S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i))
| _ -> False)
=
match F.update evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit) s data len with
| Hacl.Streaming.Types.Success -> EverCrypt.Error.Success
| Hacl.Streaming.Types.MaximumLengthExceeded -> EverCrypt.Error.MaximumLengthExceeded
inline_for_extraction noextract
let finish_st a = F.finish_st evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit)
/// The wrapper pattern, to ensure that the stack-allocated state is properly
/// monomorphized.
private
let finish_md5: finish_st MD5 = F.mk_finish evercrypt_hash MD5 (EverCrypt.Hash.state MD5) (G.erased unit)
private
let finish_sha1: finish_st SHA1 = F.mk_finish evercrypt_hash SHA1 (EverCrypt.Hash.state SHA1) (G.erased unit)
private
let finish_sha224: finish_st SHA2_224 = F.mk_finish evercrypt_hash SHA2_224 (EverCrypt.Hash.state SHA2_224) (G.erased unit)
private
let finish_sha256: finish_st SHA2_256 = F.mk_finish evercrypt_hash SHA2_256 (EverCrypt.Hash.state SHA2_256) (G.erased unit)
private
let finish_sha3_224: finish_st SHA3_224 = F.mk_finish evercrypt_hash SHA3_224 (EverCrypt.Hash.state SHA3_224) (G.erased unit)
private
let finish_sha3_256: finish_st SHA3_256 = F.mk_finish evercrypt_hash SHA3_256 (EverCrypt.Hash.state SHA3_256) (G.erased unit)
private
let finish_sha3_384: finish_st SHA3_384 = F.mk_finish evercrypt_hash SHA3_384 (EverCrypt.Hash.state SHA3_384) (G.erased unit)
private
let finish_sha3_512: finish_st SHA3_512 = F.mk_finish evercrypt_hash SHA3_512 (EverCrypt.Hash.state SHA3_512) (G.erased unit)
private
let finish_sha384: finish_st SHA2_384 = F.mk_finish evercrypt_hash SHA2_384 (EverCrypt.Hash.state SHA2_384) (G.erased unit)
private
let finish_sha512: finish_st SHA2_512 = F.mk_finish evercrypt_hash SHA2_512 (EverCrypt.Hash.state SHA2_512) (G.erased unit)
private
let finish_blake2s: finish_st Blake2S = F.mk_finish evercrypt_hash Blake2S (EverCrypt.Hash.state Blake2S) (G.erased unit)
private
let finish_blake2b: finish_st Blake2B = F.mk_finish evercrypt_hash Blake2B (EverCrypt.Hash.state Blake2B) (G.erased unit)
[@@ Comment
"Perform a run-time test to determine which algorithm was chosen for the given piece of state."]
let alg_of_state (a: G.erased Hash.alg) = F.index_of_state evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit)
[@@ Comment
"Write the resulting hash into `dst`, an array whose length is
algorithm-specific. You can use the macros defined earlier in this file to
allocate a destination buffer of the right length. The state remains valid after
a call to `finish`, meaning the user may feed more data into the hash via
`update`. (The finish function operates on an internal copy of the state and
therefore does not invalidate the client-held state.)"]
val finish: a:G.erased Hash.alg -> finish_st a
let finish a s dst l =
let a = alg_of_state a s in
match a with
| MD5 -> finish_md5 s dst l
| SHA1 -> finish_sha1 s dst l
| SHA2_224 -> finish_sha224 s dst l
| SHA2_256 -> finish_sha256 s dst l
| SHA2_384 -> finish_sha384 s dst l
| SHA2_512 -> finish_sha512 s dst l
| SHA3_224 -> finish_sha3_224 s dst l
| SHA3_256 -> finish_sha3_256 s dst l
| SHA3_384 -> finish_sha3_384 s dst l
| SHA3_512 -> finish_sha3_512 s dst l
| Blake2S -> finish_blake2s s dst l
| Blake2B -> finish_blake2b s dst l
[@@ Comment
"Free a state previously allocated with `create_in`."]
let free (i: G.erased Hash.alg) = F.free evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit)
// Private API (one-shot, multiplexing)
// ------------------------------------
private
val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256
// A full one-shot hash that relies on vale at each multiplexing point
let hash_256 input input_len dst =
let open EverCrypt.Hash in
// TODO: This function now only exists for SHA1 and MD5
Hacl.Hash.MD.mk_hash SHA2_256 Hacl.Hash.SHA2.alloca_256 update_multi_256
Hacl.Hash.SHA2.update_last_256 Hacl.Hash.SHA2.finish_256 input input_len dst
private
val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224 | false | true | EverCrypt.Hash.Incremental.fst | {
"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": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224 | [] | EverCrypt.Hash.Incremental.hash_224 | {
"file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Hash.Definitions.hash_st Spec.Hash.Definitions.SHA2_224 | {
"end_col": 80,
"end_line": 276,
"start_col": 2,
"start_line": 274
} |
FStar.HyperStack.ST.Stack | val update
(i: G.erased Hash.alg)
(s: F.state evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit))
(data: B.buffer uint8)
(len: UInt32.t)
: Stack EverCrypt.Error.error_code
(requires fun h0 -> F.update_pre evercrypt_hash i s data len h0)
(ensures
fun h0 e h1 ->
match e with
| EverCrypt.Error.Success ->
S.length (F.seen evercrypt_hash i h0 s) + U32.v len <=
U64.v (evercrypt_hash.max_input_len i) /\
F.update_post evercrypt_hash i s data len h0 h1
| EverCrypt.Error.MaximumLengthExceeded ->
h0 == h1 /\
not (S.length (F.seen evercrypt_hash i h0 s) + U32.v len <=
U64.v (evercrypt_hash.max_input_len i))
| _ -> False) | [
{
"abbrev": false,
"full_module": "EverCrypt.Hash.Incremental.Macros",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let update (i: G.erased Hash.alg)
(s:F.state evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit))
(data: B.buffer uint8)
(len: UInt32.t):
Stack EverCrypt.Error.error_code
(requires fun h0 -> F.update_pre evercrypt_hash i s data len h0)
(ensures fun h0 e h1 ->
match e with
| EverCrypt.Error.Success ->
S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i) /\
F.update_post evercrypt_hash i s data len h0 h1
| EverCrypt.Error.MaximumLengthExceeded ->
h0 == h1 /\
not (S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i))
| _ -> False)
=
match F.update evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit) s data len with
| Hacl.Streaming.Types.Success -> EverCrypt.Error.Success
| Hacl.Streaming.Types.MaximumLengthExceeded -> EverCrypt.Error.MaximumLengthExceeded | val update
(i: G.erased Hash.alg)
(s: F.state evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit))
(data: B.buffer uint8)
(len: UInt32.t)
: Stack EverCrypt.Error.error_code
(requires fun h0 -> F.update_pre evercrypt_hash i s data len h0)
(ensures
fun h0 e h1 ->
match e with
| EverCrypt.Error.Success ->
S.length (F.seen evercrypt_hash i h0 s) + U32.v len <=
U64.v (evercrypt_hash.max_input_len i) /\
F.update_post evercrypt_hash i s data len h0 h1
| EverCrypt.Error.MaximumLengthExceeded ->
h0 == h1 /\
not (S.length (F.seen evercrypt_hash i h0 s) + U32.v len <=
U64.v (evercrypt_hash.max_input_len i))
| _ -> False)
let update
(i: G.erased Hash.alg)
(s: F.state evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit))
(data: B.buffer uint8)
(len: UInt32.t)
: Stack EverCrypt.Error.error_code
(requires fun h0 -> F.update_pre evercrypt_hash i s data len h0)
(ensures
fun h0 e h1 ->
match e with
| EverCrypt.Error.Success ->
S.length (F.seen evercrypt_hash i h0 s) + U32.v len <=
U64.v (evercrypt_hash.max_input_len i) /\
F.update_post evercrypt_hash i s data len h0 h1
| EverCrypt.Error.MaximumLengthExceeded ->
h0 == h1 /\
not (S.length (F.seen evercrypt_hash i h0 s) + U32.v len <=
U64.v (evercrypt_hash.max_input_len i))
| _ -> False) = | true | null | false | match F.update evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit) s data len with
| Hacl.Streaming.Types.Success -> EverCrypt.Error.Success
| Hacl.Streaming.Types.MaximumLengthExceeded -> EverCrypt.Error.MaximumLengthExceeded | {
"checked_file": "EverCrypt.Hash.Incremental.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.MD5.fsti.checked",
"Hacl.Hash.MD.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Hash.Blake2.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"EverCrypt.TargetConfig.fsti.checked",
"EverCrypt.Hash.Incremental.Macros.fst.checked",
"EverCrypt.Hash.fsti.checked",
"EverCrypt.Error.fsti.checked",
"EverCrypt.AutoConfig2.fsti.checked"
],
"interface_file": false,
"source_file": "EverCrypt.Hash.Incremental.fst"
} | [] | [
"FStar.Ghost.erased",
"EverCrypt.Hash.alg",
"Hacl.Streaming.Functor.state",
"Spec.Hash.Definitions.fixed_len_alg",
"EverCrypt.Hash.Incremental.evercrypt_hash",
"FStar.Ghost.reveal",
"EverCrypt.Hash.state",
"Prims.unit",
"LowStar.Buffer.buffer",
"Hacl.Streaming.Interface.uint8",
"FStar.UInt32.t",
"EverCrypt.Error.Success",
"EverCrypt.Error.MaximumLengthExceeded",
"EverCrypt.Error.error_code",
"Hacl.Streaming.Types.error_code",
"Hacl.Streaming.Functor.update",
"FStar.Monotonic.HyperStack.mem",
"Hacl.Streaming.Functor.update_pre",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"FStar.Seq.Base.length",
"Hacl.Streaming.Functor.uint8",
"Hacl.Streaming.Functor.seen",
"FStar.UInt32.v",
"FStar.UInt64.v",
"Hacl.Streaming.Interface.__proj__Block__item__max_input_len",
"Hacl.Streaming.Functor.update_post",
"Prims.eq2",
"Prims.op_Negation",
"Prims.l_False"
] | [] | module EverCrypt.Hash.Incremental
open FStar.Mul
// Watch out: keep the module declarations in sync between fsti and fst
// (otherwise interleaving issues may bite).
module B = LowStar.Buffer
module S = FStar.Seq
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module G = FStar.Ghost
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module Hash = EverCrypt.Hash
open FStar.HyperStack.ST
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
include Spec.Hash.Definitions
include Hacl.Hash.Definitions
open Spec.Hash.Lemmas
#set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0"
// Definitions for instantiating the streaming functor
// ---------------------------------------------------
inline_for_extraction noextract
let agile_state: stateful Hash.alg =
Stateful
EverCrypt.Hash.state
(fun #i h s -> EverCrypt.Hash.footprint s h)
EverCrypt.Hash.freeable
(fun #i h s -> EverCrypt.Hash.invariant s h)
Spec.Hash.Definitions.words_state
(fun i h s -> EverCrypt.Hash.repr s h)
(fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h)
(fun #i l s h0 h1 ->
EverCrypt.Hash.frame_invariant l s h0 h1;
EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1)
(fun #i l s h0 h1 -> ())
EverCrypt.Hash.alloca
EverCrypt.Hash.create_in
(fun i -> EverCrypt.Hash.free #i)
(fun i -> EverCrypt.Hash.copy #i)
include EverCrypt.Hash.Incremental.Macros
#push-options "--ifuel 1"
(* Adding some non-inlined definitions to factorize code. This one is public
because it's used by the WASM API, and is generally useful to callers. *)
let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) =
match a with
| MD5 -> md5_hash_len
| SHA1 -> sha1_hash_len
| SHA2_224 -> sha2_224_hash_len
| SHA2_256 -> sha2_256_hash_len
| SHA2_384 -> sha2_384_hash_len
| SHA2_512 -> sha2_512_hash_len
| SHA3_224 -> sha3_224_hash_len
| SHA3_256 -> sha3_256_hash_len
| SHA3_384 -> sha3_384_hash_len
| SHA3_512 -> sha3_512_hash_len
| Blake2S -> blake2s_hash_len
| Blake2B -> blake2b_hash_len
#pop-options
private
let block_len a = Hacl.Hash.Definitions.block_len a
inline_for_extraction noextract
let extra_state_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }):
Spec.Hash.Definitions.extra_state a
=
if is_blake a then
i
else
()
inline_for_extraction noextract
let prev_length_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }):
Spec.Hash.Incremental.prev_length_t a
=
if is_keccak a then
()
else
i
#push-options "--z3rlimit 500"
inline_for_extraction noextract
let evercrypt_hash : block Hash.alg =
Block
Erased
agile_state
(stateful_unused Hash.alg)
unit
Hacl.Hash.Definitions.max_input_len64
(fun a () -> Spec.Hash.Definitions.hash_length a)
block_len
block_len // No vectorization
(fun _ -> 0ul)
(fun _ _ -> S.empty)
(fun a _ -> Spec.Agile.Hash.init a)
(fun a s prevlen input ->
let prevlen = extra_state_of_nat a prevlen in
Spec.Agile.Hash.update_multi a s prevlen input)
(fun a s prevlen input ->
let prevlen = prev_length_of_nat a prevlen in
Spec.Hash.Incremental.update_last a s prevlen input)
(fun a _ s () -> Spec.Agile.Hash.finish a s ())
(fun a _ s () -> Spec.Agile.Hash.hash a s)
(fun a s prevlen ->
if is_blake a then
Spec.Hash.Lemmas.update_multi_zero_blake a prevlen s
else
Spec.Hash.Lemmas.update_multi_zero a s)
(* update_multi_associative *)
(fun a s prevlen1 prevlen2 input1 input2 ->
if is_blake a then
Spec.Hash.Lemmas.update_multi_associative_blake a s prevlen1 prevlen2 input1 input2
else
Spec.Hash.Lemmas.update_multi_associative a s input1 input2)
(* spec_is_incremental *)
(fun a _ input () ->
let input1 = S.append S.empty input in
assert (S.equal input1 input);
Spec.Hash.Incremental.hash_is_hash_incremental' a input ())
EverCrypt.Hash.alg_of_state
(fun i _ _ -> EverCrypt.Hash.init #i)
(fun i s prevlen blocks len -> EverCrypt.Hash.update_multi #i s prevlen blocks len)
(fun i s prevlen last last_len ->
EverCrypt.Hash.update_last #i s prevlen last last_len)
(fun i _ s dst _ -> EverCrypt.Hash.finish #i s dst)
#pop-options
let hash_state =
F.state_s evercrypt_hash SHA2_256 ((agile_state).s SHA2_256) (G.erased unit)
// Public API (streaming)
// ----------------------
[@@ Comment
"Allocate initial state for the agile hash. The argument `a` stands for the
choice of algorithm (see Hacl_Spec.h). This API will automatically pick the most
efficient implementation, provided you have called EverCrypt_AutoConfig2_init()
before. The state is to be freed by calling `free`."]
let create_in a = F.create_in evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) ()
[@@ Comment
"Reset an existing state to the initial hash state with empty data."]
let init (a: G.erased Hash.alg) = F.init evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) ()
[@@ Comment
"Feed an arbitrary amount of data into the hash. This function returns
EverCrypt_Error_Success for success, or EverCrypt_Error_MaximumLengthExceeded if
the combined length of all of the data passed to `update` (since the last call
to `init`) exceeds 2^61-1 bytes or 2^64-1 bytes, depending on the choice of
algorithm. Both limits are unlikely to be attained in practice."]
let update (i: G.erased Hash.alg)
(s:F.state evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit))
(data: B.buffer uint8)
(len: UInt32.t):
Stack EverCrypt.Error.error_code
(requires fun h0 -> F.update_pre evercrypt_hash i s data len h0)
(ensures fun h0 e h1 ->
match e with
| EverCrypt.Error.Success ->
S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i) /\
F.update_post evercrypt_hash i s data len h0 h1
| EverCrypt.Error.MaximumLengthExceeded ->
h0 == h1 /\
not (S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i))
| _ -> False) | false | false | EverCrypt.Hash.Incremental.fst | {
"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": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update
(i: G.erased Hash.alg)
(s: F.state evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit))
(data: B.buffer uint8)
(len: UInt32.t)
: Stack EverCrypt.Error.error_code
(requires fun h0 -> F.update_pre evercrypt_hash i s data len h0)
(ensures
fun h0 e h1 ->
match e with
| EverCrypt.Error.Success ->
S.length (F.seen evercrypt_hash i h0 s) + U32.v len <=
U64.v (evercrypt_hash.max_input_len i) /\
F.update_post evercrypt_hash i s data len h0 h1
| EverCrypt.Error.MaximumLengthExceeded ->
h0 == h1 /\
not (S.length (F.seen evercrypt_hash i h0 s) + U32.v len <=
U64.v (evercrypt_hash.max_input_len i))
| _ -> False) | [] | EverCrypt.Hash.Incremental.update | {
"file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
i: FStar.Ghost.erased EverCrypt.Hash.alg ->
s:
Hacl.Streaming.Functor.state EverCrypt.Hash.Incremental.evercrypt_hash
(FStar.Ghost.reveal i)
(EverCrypt.Hash.state (FStar.Ghost.reveal i))
(FStar.Ghost.erased Prims.unit) ->
data: LowStar.Buffer.buffer Hacl.Streaming.Interface.uint8 ->
len: FStar.UInt32.t
-> FStar.HyperStack.ST.Stack EverCrypt.Error.error_code | {
"end_col": 87,
"end_line": 193,
"start_col": 2,
"start_line": 191
} |
Prims.Tot | val prev_length_of_nat (a: hash_alg) (i: nat{i % U32.v (block_len a) = 0})
: Spec.Hash.Incremental.prev_length_t a | [
{
"abbrev": false,
"full_module": "EverCrypt.Hash.Incremental.Macros",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let prev_length_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }):
Spec.Hash.Incremental.prev_length_t a
=
if is_keccak a then
()
else
i | val prev_length_of_nat (a: hash_alg) (i: nat{i % U32.v (block_len a) = 0})
: Spec.Hash.Incremental.prev_length_t a
let prev_length_of_nat (a: hash_alg) (i: nat{i % U32.v (block_len a) = 0})
: Spec.Hash.Incremental.prev_length_t a = | false | null | false | if is_keccak a then () else i | {
"checked_file": "EverCrypt.Hash.Incremental.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.MD5.fsti.checked",
"Hacl.Hash.MD.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Hash.Blake2.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"EverCrypt.TargetConfig.fsti.checked",
"EverCrypt.Hash.Incremental.Macros.fst.checked",
"EverCrypt.Hash.fsti.checked",
"EverCrypt.Error.fsti.checked",
"EverCrypt.AutoConfig2.fsti.checked"
],
"interface_file": false,
"source_file": "EverCrypt.Hash.Incremental.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.nat",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"FStar.UInt32.v",
"EverCrypt.Hash.Incremental.block_len",
"Spec.Hash.Definitions.is_keccak",
"Prims.bool",
"Spec.Hash.Incremental.Definitions.prev_length_t"
] | [] | module EverCrypt.Hash.Incremental
open FStar.Mul
// Watch out: keep the module declarations in sync between fsti and fst
// (otherwise interleaving issues may bite).
module B = LowStar.Buffer
module S = FStar.Seq
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module G = FStar.Ghost
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module Hash = EverCrypt.Hash
open FStar.HyperStack.ST
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
include Spec.Hash.Definitions
include Hacl.Hash.Definitions
open Spec.Hash.Lemmas
#set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0"
// Definitions for instantiating the streaming functor
// ---------------------------------------------------
inline_for_extraction noextract
let agile_state: stateful Hash.alg =
Stateful
EverCrypt.Hash.state
(fun #i h s -> EverCrypt.Hash.footprint s h)
EverCrypt.Hash.freeable
(fun #i h s -> EverCrypt.Hash.invariant s h)
Spec.Hash.Definitions.words_state
(fun i h s -> EverCrypt.Hash.repr s h)
(fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h)
(fun #i l s h0 h1 ->
EverCrypt.Hash.frame_invariant l s h0 h1;
EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1)
(fun #i l s h0 h1 -> ())
EverCrypt.Hash.alloca
EverCrypt.Hash.create_in
(fun i -> EverCrypt.Hash.free #i)
(fun i -> EverCrypt.Hash.copy #i)
include EverCrypt.Hash.Incremental.Macros
#push-options "--ifuel 1"
(* Adding some non-inlined definitions to factorize code. This one is public
because it's used by the WASM API, and is generally useful to callers. *)
let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) =
match a with
| MD5 -> md5_hash_len
| SHA1 -> sha1_hash_len
| SHA2_224 -> sha2_224_hash_len
| SHA2_256 -> sha2_256_hash_len
| SHA2_384 -> sha2_384_hash_len
| SHA2_512 -> sha2_512_hash_len
| SHA3_224 -> sha3_224_hash_len
| SHA3_256 -> sha3_256_hash_len
| SHA3_384 -> sha3_384_hash_len
| SHA3_512 -> sha3_512_hash_len
| Blake2S -> blake2s_hash_len
| Blake2B -> blake2b_hash_len
#pop-options
private
let block_len a = Hacl.Hash.Definitions.block_len a
inline_for_extraction noextract
let extra_state_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }):
Spec.Hash.Definitions.extra_state a
=
if is_blake a then
i
else
()
inline_for_extraction noextract
let prev_length_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }):
Spec.Hash.Incremental.prev_length_t a | false | false | EverCrypt.Hash.Incremental.fst | {
"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": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val prev_length_of_nat (a: hash_alg) (i: nat{i % U32.v (block_len a) = 0})
: Spec.Hash.Incremental.prev_length_t a | [] | EverCrypt.Hash.Incremental.prev_length_of_nat | {
"file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Hash.Definitions.hash_alg ->
i: Prims.nat{i % FStar.UInt32.v (EverCrypt.Hash.Incremental.block_len a) = 0}
-> Spec.Hash.Incremental.Definitions.prev_length_t a | {
"end_col": 5,
"end_line": 96,
"start_col": 2,
"start_line": 93
} |
Prims.Tot | val extra_state_of_nat (a: hash_alg) (i: nat{i % U32.v (block_len a) = 0})
: Spec.Hash.Definitions.extra_state a | [
{
"abbrev": false,
"full_module": "EverCrypt.Hash.Incremental.Macros",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let extra_state_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }):
Spec.Hash.Definitions.extra_state a
=
if is_blake a then
i
else
() | val extra_state_of_nat (a: hash_alg) (i: nat{i % U32.v (block_len a) = 0})
: Spec.Hash.Definitions.extra_state a
let extra_state_of_nat (a: hash_alg) (i: nat{i % U32.v (block_len a) = 0})
: Spec.Hash.Definitions.extra_state a = | false | null | false | if is_blake a then i | {
"checked_file": "EverCrypt.Hash.Incremental.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.MD5.fsti.checked",
"Hacl.Hash.MD.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Hash.Blake2.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"EverCrypt.TargetConfig.fsti.checked",
"EverCrypt.Hash.Incremental.Macros.fst.checked",
"EverCrypt.Hash.fsti.checked",
"EverCrypt.Error.fsti.checked",
"EverCrypt.AutoConfig2.fsti.checked"
],
"interface_file": false,
"source_file": "EverCrypt.Hash.Incremental.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.hash_alg",
"Prims.nat",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"FStar.UInt32.v",
"EverCrypt.Hash.Incremental.block_len",
"Spec.Hash.Definitions.is_blake",
"Prims.bool",
"Spec.Hash.Definitions.extra_state"
] | [] | module EverCrypt.Hash.Incremental
open FStar.Mul
// Watch out: keep the module declarations in sync between fsti and fst
// (otherwise interleaving issues may bite).
module B = LowStar.Buffer
module S = FStar.Seq
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module G = FStar.Ghost
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module Hash = EverCrypt.Hash
open FStar.HyperStack.ST
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
include Spec.Hash.Definitions
include Hacl.Hash.Definitions
open Spec.Hash.Lemmas
#set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0"
// Definitions for instantiating the streaming functor
// ---------------------------------------------------
inline_for_extraction noextract
let agile_state: stateful Hash.alg =
Stateful
EverCrypt.Hash.state
(fun #i h s -> EverCrypt.Hash.footprint s h)
EverCrypt.Hash.freeable
(fun #i h s -> EverCrypt.Hash.invariant s h)
Spec.Hash.Definitions.words_state
(fun i h s -> EverCrypt.Hash.repr s h)
(fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h)
(fun #i l s h0 h1 ->
EverCrypt.Hash.frame_invariant l s h0 h1;
EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1)
(fun #i l s h0 h1 -> ())
EverCrypt.Hash.alloca
EverCrypt.Hash.create_in
(fun i -> EverCrypt.Hash.free #i)
(fun i -> EverCrypt.Hash.copy #i)
include EverCrypt.Hash.Incremental.Macros
#push-options "--ifuel 1"
(* Adding some non-inlined definitions to factorize code. This one is public
because it's used by the WASM API, and is generally useful to callers. *)
let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) =
match a with
| MD5 -> md5_hash_len
| SHA1 -> sha1_hash_len
| SHA2_224 -> sha2_224_hash_len
| SHA2_256 -> sha2_256_hash_len
| SHA2_384 -> sha2_384_hash_len
| SHA2_512 -> sha2_512_hash_len
| SHA3_224 -> sha3_224_hash_len
| SHA3_256 -> sha3_256_hash_len
| SHA3_384 -> sha3_384_hash_len
| SHA3_512 -> sha3_512_hash_len
| Blake2S -> blake2s_hash_len
| Blake2B -> blake2b_hash_len
#pop-options
private
let block_len a = Hacl.Hash.Definitions.block_len a
inline_for_extraction noextract
let extra_state_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }):
Spec.Hash.Definitions.extra_state a | false | false | EverCrypt.Hash.Incremental.fst | {
"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": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val extra_state_of_nat (a: hash_alg) (i: nat{i % U32.v (block_len a) = 0})
: Spec.Hash.Definitions.extra_state a | [] | EverCrypt.Hash.Incremental.extra_state_of_nat | {
"file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Hash.Definitions.hash_alg ->
i: Prims.nat{i % FStar.UInt32.v (EverCrypt.Hash.Incremental.block_len a) = 0}
-> Spec.Hash.Definitions.extra_state a | {
"end_col": 6,
"end_line": 87,
"start_col": 2,
"start_line": 84
} |
Prims.Tot | val hash_len (a: Hash.alg) : (x: UInt32.t{UInt32.v x == Spec.Agile.Hash.hash_length a}) | [
{
"abbrev": false,
"full_module": "EverCrypt.Hash.Incremental.Macros",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) =
match a with
| MD5 -> md5_hash_len
| SHA1 -> sha1_hash_len
| SHA2_224 -> sha2_224_hash_len
| SHA2_256 -> sha2_256_hash_len
| SHA2_384 -> sha2_384_hash_len
| SHA2_512 -> sha2_512_hash_len
| SHA3_224 -> sha3_224_hash_len
| SHA3_256 -> sha3_256_hash_len
| SHA3_384 -> sha3_384_hash_len
| SHA3_512 -> sha3_512_hash_len
| Blake2S -> blake2s_hash_len
| Blake2B -> blake2b_hash_len | val hash_len (a: Hash.alg) : (x: UInt32.t{UInt32.v x == Spec.Agile.Hash.hash_length a})
let hash_len (a: Hash.alg) : (x: UInt32.t{UInt32.v x == Spec.Agile.Hash.hash_length a}) = | false | null | false | match a with
| MD5 -> md5_hash_len
| SHA1 -> sha1_hash_len
| SHA2_224 -> sha2_224_hash_len
| SHA2_256 -> sha2_256_hash_len
| SHA2_384 -> sha2_384_hash_len
| SHA2_512 -> sha2_512_hash_len
| SHA3_224 -> sha3_224_hash_len
| SHA3_256 -> sha3_256_hash_len
| SHA3_384 -> sha3_384_hash_len
| SHA3_512 -> sha3_512_hash_len
| Blake2S -> blake2s_hash_len
| Blake2B -> blake2b_hash_len | {
"checked_file": "EverCrypt.Hash.Incremental.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.MD5.fsti.checked",
"Hacl.Hash.MD.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Hash.Blake2.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"EverCrypt.TargetConfig.fsti.checked",
"EverCrypt.Hash.Incremental.Macros.fst.checked",
"EverCrypt.Hash.fsti.checked",
"EverCrypt.Error.fsti.checked",
"EverCrypt.AutoConfig2.fsti.checked"
],
"interface_file": false,
"source_file": "EverCrypt.Hash.Incremental.fst"
} | [
"total"
] | [
"EverCrypt.Hash.alg",
"EverCrypt.Hash.Incremental.Macros.md5_hash_len",
"EverCrypt.Hash.Incremental.Macros.sha1_hash_len",
"EverCrypt.Hash.Incremental.Macros.sha2_224_hash_len",
"EverCrypt.Hash.Incremental.Macros.sha2_256_hash_len",
"EverCrypt.Hash.Incremental.Macros.sha2_384_hash_len",
"EverCrypt.Hash.Incremental.Macros.sha2_512_hash_len",
"EverCrypt.Hash.Incremental.Macros.sha3_224_hash_len",
"EverCrypt.Hash.Incremental.Macros.sha3_256_hash_len",
"EverCrypt.Hash.Incremental.Macros.sha3_384_hash_len",
"EverCrypt.Hash.Incremental.Macros.sha3_512_hash_len",
"EverCrypt.Hash.Incremental.Macros.blake2s_hash_len",
"EverCrypt.Hash.Incremental.Macros.blake2b_hash_len",
"FStar.UInt32.t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt32.n",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.max_size_t",
"Prims.op_GreaterThan",
"FStar.UInt32.v",
"Spec.Hash.Definitions.hash_length"
] | [] | module EverCrypt.Hash.Incremental
open FStar.Mul
// Watch out: keep the module declarations in sync between fsti and fst
// (otherwise interleaving issues may bite).
module B = LowStar.Buffer
module S = FStar.Seq
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module G = FStar.Ghost
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module Hash = EverCrypt.Hash
open FStar.HyperStack.ST
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
include Spec.Hash.Definitions
include Hacl.Hash.Definitions
open Spec.Hash.Lemmas
#set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0"
// Definitions for instantiating the streaming functor
// ---------------------------------------------------
inline_for_extraction noextract
let agile_state: stateful Hash.alg =
Stateful
EverCrypt.Hash.state
(fun #i h s -> EverCrypt.Hash.footprint s h)
EverCrypt.Hash.freeable
(fun #i h s -> EverCrypt.Hash.invariant s h)
Spec.Hash.Definitions.words_state
(fun i h s -> EverCrypt.Hash.repr s h)
(fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h)
(fun #i l s h0 h1 ->
EverCrypt.Hash.frame_invariant l s h0 h1;
EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1)
(fun #i l s h0 h1 -> ())
EverCrypt.Hash.alloca
EverCrypt.Hash.create_in
(fun i -> EverCrypt.Hash.free #i)
(fun i -> EverCrypt.Hash.copy #i)
include EverCrypt.Hash.Incremental.Macros
#push-options "--ifuel 1"
(* Adding some non-inlined definitions to factorize code. This one is public
because it's used by the WASM API, and is generally useful to callers. *) | false | false | EverCrypt.Hash.Incremental.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_len (a: Hash.alg) : (x: UInt32.t{UInt32.v x == Spec.Agile.Hash.hash_length a}) | [] | EverCrypt.Hash.Incremental.hash_len | {
"file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: EverCrypt.Hash.alg -> x: FStar.UInt32.t{FStar.UInt32.v x == Spec.Hash.Definitions.hash_length a} | {
"end_col": 31,
"end_line": 73,
"start_col": 2,
"start_line": 61
} |
Prims.Tot | val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 | [
{
"abbrev": false,
"full_module": "EverCrypt.Hash.Incremental.Macros",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_256 input input_len dst =
let open EverCrypt.Hash in
// TODO: This function now only exists for SHA1 and MD5
Hacl.Hash.MD.mk_hash SHA2_256 Hacl.Hash.SHA2.alloca_256 update_multi_256
Hacl.Hash.SHA2.update_last_256 Hacl.Hash.SHA2.finish_256 input input_len dst | val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256
let hash_256 input input_len dst = | false | null | false | let open EverCrypt.Hash in
Hacl.Hash.MD.mk_hash SHA2_256
Hacl.Hash.SHA2.alloca_256
update_multi_256
Hacl.Hash.SHA2.update_last_256
Hacl.Hash.SHA2.finish_256
input
input_len
dst | {
"checked_file": "EverCrypt.Hash.Incremental.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.MD5.fsti.checked",
"Hacl.Hash.MD.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Hash.Blake2.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"EverCrypt.TargetConfig.fsti.checked",
"EverCrypt.Hash.Incremental.Macros.fst.checked",
"EverCrypt.Hash.fsti.checked",
"EverCrypt.Error.fsti.checked",
"EverCrypt.AutoConfig2.fsti.checked"
],
"interface_file": false,
"source_file": "EverCrypt.Hash.Incremental.fst"
} | [
"total"
] | [
"LowStar.Buffer.buffer",
"Lib.IntTypes.uint8",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"LowStar.Monotonic.Buffer.length",
"LowStar.Buffer.trivial_preorder",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Hacl.Hash.Definitions.hash_t",
"Spec.Hash.Definitions.SHA2_256",
"Hacl.Hash.MD.mk_hash",
"Hacl.Hash.SHA2.alloca_256",
"EverCrypt.Hash.update_multi_256",
"Hacl.Hash.SHA2.update_last_256",
"Hacl.Hash.SHA2.finish_256",
"Prims.unit"
] | [] | module EverCrypt.Hash.Incremental
open FStar.Mul
// Watch out: keep the module declarations in sync between fsti and fst
// (otherwise interleaving issues may bite).
module B = LowStar.Buffer
module S = FStar.Seq
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module G = FStar.Ghost
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module Hash = EverCrypt.Hash
open FStar.HyperStack.ST
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
include Spec.Hash.Definitions
include Hacl.Hash.Definitions
open Spec.Hash.Lemmas
#set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0"
// Definitions for instantiating the streaming functor
// ---------------------------------------------------
inline_for_extraction noextract
let agile_state: stateful Hash.alg =
Stateful
EverCrypt.Hash.state
(fun #i h s -> EverCrypt.Hash.footprint s h)
EverCrypt.Hash.freeable
(fun #i h s -> EverCrypt.Hash.invariant s h)
Spec.Hash.Definitions.words_state
(fun i h s -> EverCrypt.Hash.repr s h)
(fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h)
(fun #i l s h0 h1 ->
EverCrypt.Hash.frame_invariant l s h0 h1;
EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1)
(fun #i l s h0 h1 -> ())
EverCrypt.Hash.alloca
EverCrypt.Hash.create_in
(fun i -> EverCrypt.Hash.free #i)
(fun i -> EverCrypt.Hash.copy #i)
include EverCrypt.Hash.Incremental.Macros
#push-options "--ifuel 1"
(* Adding some non-inlined definitions to factorize code. This one is public
because it's used by the WASM API, and is generally useful to callers. *)
let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) =
match a with
| MD5 -> md5_hash_len
| SHA1 -> sha1_hash_len
| SHA2_224 -> sha2_224_hash_len
| SHA2_256 -> sha2_256_hash_len
| SHA2_384 -> sha2_384_hash_len
| SHA2_512 -> sha2_512_hash_len
| SHA3_224 -> sha3_224_hash_len
| SHA3_256 -> sha3_256_hash_len
| SHA3_384 -> sha3_384_hash_len
| SHA3_512 -> sha3_512_hash_len
| Blake2S -> blake2s_hash_len
| Blake2B -> blake2b_hash_len
#pop-options
private
let block_len a = Hacl.Hash.Definitions.block_len a
inline_for_extraction noextract
let extra_state_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }):
Spec.Hash.Definitions.extra_state a
=
if is_blake a then
i
else
()
inline_for_extraction noextract
let prev_length_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }):
Spec.Hash.Incremental.prev_length_t a
=
if is_keccak a then
()
else
i
#push-options "--z3rlimit 500"
inline_for_extraction noextract
let evercrypt_hash : block Hash.alg =
Block
Erased
agile_state
(stateful_unused Hash.alg)
unit
Hacl.Hash.Definitions.max_input_len64
(fun a () -> Spec.Hash.Definitions.hash_length a)
block_len
block_len // No vectorization
(fun _ -> 0ul)
(fun _ _ -> S.empty)
(fun a _ -> Spec.Agile.Hash.init a)
(fun a s prevlen input ->
let prevlen = extra_state_of_nat a prevlen in
Spec.Agile.Hash.update_multi a s prevlen input)
(fun a s prevlen input ->
let prevlen = prev_length_of_nat a prevlen in
Spec.Hash.Incremental.update_last a s prevlen input)
(fun a _ s () -> Spec.Agile.Hash.finish a s ())
(fun a _ s () -> Spec.Agile.Hash.hash a s)
(fun a s prevlen ->
if is_blake a then
Spec.Hash.Lemmas.update_multi_zero_blake a prevlen s
else
Spec.Hash.Lemmas.update_multi_zero a s)
(* update_multi_associative *)
(fun a s prevlen1 prevlen2 input1 input2 ->
if is_blake a then
Spec.Hash.Lemmas.update_multi_associative_blake a s prevlen1 prevlen2 input1 input2
else
Spec.Hash.Lemmas.update_multi_associative a s input1 input2)
(* spec_is_incremental *)
(fun a _ input () ->
let input1 = S.append S.empty input in
assert (S.equal input1 input);
Spec.Hash.Incremental.hash_is_hash_incremental' a input ())
EverCrypt.Hash.alg_of_state
(fun i _ _ -> EverCrypt.Hash.init #i)
(fun i s prevlen blocks len -> EverCrypt.Hash.update_multi #i s prevlen blocks len)
(fun i s prevlen last last_len ->
EverCrypt.Hash.update_last #i s prevlen last last_len)
(fun i _ s dst _ -> EverCrypt.Hash.finish #i s dst)
#pop-options
let hash_state =
F.state_s evercrypt_hash SHA2_256 ((agile_state).s SHA2_256) (G.erased unit)
// Public API (streaming)
// ----------------------
[@@ Comment
"Allocate initial state for the agile hash. The argument `a` stands for the
choice of algorithm (see Hacl_Spec.h). This API will automatically pick the most
efficient implementation, provided you have called EverCrypt_AutoConfig2_init()
before. The state is to be freed by calling `free`."]
let create_in a = F.create_in evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) ()
[@@ Comment
"Reset an existing state to the initial hash state with empty data."]
let init (a: G.erased Hash.alg) = F.init evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) ()
[@@ Comment
"Feed an arbitrary amount of data into the hash. This function returns
EverCrypt_Error_Success for success, or EverCrypt_Error_MaximumLengthExceeded if
the combined length of all of the data passed to `update` (since the last call
to `init`) exceeds 2^61-1 bytes or 2^64-1 bytes, depending on the choice of
algorithm. Both limits are unlikely to be attained in practice."]
let update (i: G.erased Hash.alg)
(s:F.state evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit))
(data: B.buffer uint8)
(len: UInt32.t):
Stack EverCrypt.Error.error_code
(requires fun h0 -> F.update_pre evercrypt_hash i s data len h0)
(ensures fun h0 e h1 ->
match e with
| EverCrypt.Error.Success ->
S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i) /\
F.update_post evercrypt_hash i s data len h0 h1
| EverCrypt.Error.MaximumLengthExceeded ->
h0 == h1 /\
not (S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i))
| _ -> False)
=
match F.update evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit) s data len with
| Hacl.Streaming.Types.Success -> EverCrypt.Error.Success
| Hacl.Streaming.Types.MaximumLengthExceeded -> EverCrypt.Error.MaximumLengthExceeded
inline_for_extraction noextract
let finish_st a = F.finish_st evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit)
/// The wrapper pattern, to ensure that the stack-allocated state is properly
/// monomorphized.
private
let finish_md5: finish_st MD5 = F.mk_finish evercrypt_hash MD5 (EverCrypt.Hash.state MD5) (G.erased unit)
private
let finish_sha1: finish_st SHA1 = F.mk_finish evercrypt_hash SHA1 (EverCrypt.Hash.state SHA1) (G.erased unit)
private
let finish_sha224: finish_st SHA2_224 = F.mk_finish evercrypt_hash SHA2_224 (EverCrypt.Hash.state SHA2_224) (G.erased unit)
private
let finish_sha256: finish_st SHA2_256 = F.mk_finish evercrypt_hash SHA2_256 (EverCrypt.Hash.state SHA2_256) (G.erased unit)
private
let finish_sha3_224: finish_st SHA3_224 = F.mk_finish evercrypt_hash SHA3_224 (EverCrypt.Hash.state SHA3_224) (G.erased unit)
private
let finish_sha3_256: finish_st SHA3_256 = F.mk_finish evercrypt_hash SHA3_256 (EverCrypt.Hash.state SHA3_256) (G.erased unit)
private
let finish_sha3_384: finish_st SHA3_384 = F.mk_finish evercrypt_hash SHA3_384 (EverCrypt.Hash.state SHA3_384) (G.erased unit)
private
let finish_sha3_512: finish_st SHA3_512 = F.mk_finish evercrypt_hash SHA3_512 (EverCrypt.Hash.state SHA3_512) (G.erased unit)
private
let finish_sha384: finish_st SHA2_384 = F.mk_finish evercrypt_hash SHA2_384 (EverCrypt.Hash.state SHA2_384) (G.erased unit)
private
let finish_sha512: finish_st SHA2_512 = F.mk_finish evercrypt_hash SHA2_512 (EverCrypt.Hash.state SHA2_512) (G.erased unit)
private
let finish_blake2s: finish_st Blake2S = F.mk_finish evercrypt_hash Blake2S (EverCrypt.Hash.state Blake2S) (G.erased unit)
private
let finish_blake2b: finish_st Blake2B = F.mk_finish evercrypt_hash Blake2B (EverCrypt.Hash.state Blake2B) (G.erased unit)
[@@ Comment
"Perform a run-time test to determine which algorithm was chosen for the given piece of state."]
let alg_of_state (a: G.erased Hash.alg) = F.index_of_state evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit)
[@@ Comment
"Write the resulting hash into `dst`, an array whose length is
algorithm-specific. You can use the macros defined earlier in this file to
allocate a destination buffer of the right length. The state remains valid after
a call to `finish`, meaning the user may feed more data into the hash via
`update`. (The finish function operates on an internal copy of the state and
therefore does not invalidate the client-held state.)"]
val finish: a:G.erased Hash.alg -> finish_st a
let finish a s dst l =
let a = alg_of_state a s in
match a with
| MD5 -> finish_md5 s dst l
| SHA1 -> finish_sha1 s dst l
| SHA2_224 -> finish_sha224 s dst l
| SHA2_256 -> finish_sha256 s dst l
| SHA2_384 -> finish_sha384 s dst l
| SHA2_512 -> finish_sha512 s dst l
| SHA3_224 -> finish_sha3_224 s dst l
| SHA3_256 -> finish_sha3_256 s dst l
| SHA3_384 -> finish_sha3_384 s dst l
| SHA3_512 -> finish_sha3_512 s dst l
| Blake2S -> finish_blake2s s dst l
| Blake2B -> finish_blake2b s dst l
[@@ Comment
"Free a state previously allocated with `create_in`."]
let free (i: G.erased Hash.alg) = F.free evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit)
// Private API (one-shot, multiplexing)
// ------------------------------------
private
val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256
// A full one-shot hash that relies on vale at each multiplexing point | false | true | EverCrypt.Hash.Incremental.fst | {
"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": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 | [] | EverCrypt.Hash.Incremental.hash_256 | {
"file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Hash.Definitions.hash_st Spec.Hash.Definitions.SHA2_256 | {
"end_col": 80,
"end_line": 268,
"start_col": 2,
"start_line": 265
} |
FStar.HyperStack.ST.Stack | val hash:
a:Hash.alg ->
dst:B.buffer Lib.IntTypes.uint8 {B.length dst = hash_length a} ->
input:B.buffer Lib.IntTypes.uint8 ->
len:FStar.UInt32.t {B.length input = FStar.UInt32.v len /\ FStar.UInt32.v len `less_than_max_input_length` a} ->
Stack unit
(requires fun h0 ->
B.live h0 dst /\
B.live h0 input /\
B.(loc_disjoint (loc_buffer input) (loc_buffer dst)))
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer dst) h0 h1) /\
B.as_seq h1 dst == Spec.Agile.Hash.hash a (B.as_seq h0 input)) | [
{
"abbrev": false,
"full_module": "EverCrypt.Hash.Incremental.Macros",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash a dst input len =
match a with
| MD5 -> Hacl.Hash.MD5.legacy_hash input len dst
| SHA1 -> Hacl.Hash.SHA1.legacy_hash input len dst
| SHA2_224 -> hash_224 input len dst
| SHA2_256 -> hash_256 input len dst
| SHA2_384 -> Hacl.Streaming.SHA2.hash_384 input len dst
| SHA2_512 -> Hacl.Streaming.SHA2.hash_512 input len dst
| SHA3_224 -> Hacl.Hash.SHA3.hash SHA3_224 input len dst
| SHA3_256 -> Hacl.Hash.SHA3.hash SHA3_256 input len dst
| SHA3_384 -> Hacl.Hash.SHA3.hash SHA3_384 input len dst
| SHA3_512 -> Hacl.Hash.SHA3.hash SHA3_512 input len dst
| Blake2S ->
if EverCrypt.TargetConfig.hacl_can_compile_vec128 then
let vec128 = EverCrypt.AutoConfig2.has_vec128 () in
if vec128 then
Hacl.Hash.Blake2.hash_blake2s_128 input len dst
else
Hacl.Hash.Blake2.hash_blake2s_32 input len dst
else
Hacl.Hash.Blake2.hash_blake2s_32 input len dst
| Blake2B ->
if EverCrypt.TargetConfig.hacl_can_compile_vec256 then
let vec256 = EverCrypt.AutoConfig2.has_vec256 () in
if vec256 then
Hacl.Hash.Blake2.hash_blake2b_256 input len dst
else
Hacl.Hash.Blake2.hash_blake2b_32 input len dst
else
Hacl.Hash.Blake2.hash_blake2b_32 input len dst | val hash:
a:Hash.alg ->
dst:B.buffer Lib.IntTypes.uint8 {B.length dst = hash_length a} ->
input:B.buffer Lib.IntTypes.uint8 ->
len:FStar.UInt32.t {B.length input = FStar.UInt32.v len /\ FStar.UInt32.v len `less_than_max_input_length` a} ->
Stack unit
(requires fun h0 ->
B.live h0 dst /\
B.live h0 input /\
B.(loc_disjoint (loc_buffer input) (loc_buffer dst)))
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer dst) h0 h1) /\
B.as_seq h1 dst == Spec.Agile.Hash.hash a (B.as_seq h0 input))
let hash a dst input len = | true | null | false | match a with
| MD5 -> Hacl.Hash.MD5.legacy_hash input len dst
| SHA1 -> Hacl.Hash.SHA1.legacy_hash input len dst
| SHA2_224 -> hash_224 input len dst
| SHA2_256 -> hash_256 input len dst
| SHA2_384 -> Hacl.Streaming.SHA2.hash_384 input len dst
| SHA2_512 -> Hacl.Streaming.SHA2.hash_512 input len dst
| SHA3_224 -> Hacl.Hash.SHA3.hash SHA3_224 input len dst
| SHA3_256 -> Hacl.Hash.SHA3.hash SHA3_256 input len dst
| SHA3_384 -> Hacl.Hash.SHA3.hash SHA3_384 input len dst
| SHA3_512 -> Hacl.Hash.SHA3.hash SHA3_512 input len dst
| Blake2S ->
if EverCrypt.TargetConfig.hacl_can_compile_vec128
then
let vec128 = EverCrypt.AutoConfig2.has_vec128 () in
if vec128
then Hacl.Hash.Blake2.hash_blake2s_128 input len dst
else Hacl.Hash.Blake2.hash_blake2s_32 input len dst
else Hacl.Hash.Blake2.hash_blake2s_32 input len dst
| Blake2B ->
if EverCrypt.TargetConfig.hacl_can_compile_vec256
then
let vec256 = EverCrypt.AutoConfig2.has_vec256 () in
if vec256
then Hacl.Hash.Blake2.hash_blake2b_256 input len dst
else Hacl.Hash.Blake2.hash_blake2b_32 input len dst
else Hacl.Hash.Blake2.hash_blake2b_32 input len dst | {
"checked_file": "EverCrypt.Hash.Incremental.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.MD5.fsti.checked",
"Hacl.Hash.MD.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Hash.Blake2.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"EverCrypt.TargetConfig.fsti.checked",
"EverCrypt.Hash.Incremental.Macros.fst.checked",
"EverCrypt.Hash.fsti.checked",
"EverCrypt.Error.fsti.checked",
"EverCrypt.AutoConfig2.fsti.checked"
],
"interface_file": false,
"source_file": "EverCrypt.Hash.Incremental.fst"
} | [] | [
"EverCrypt.Hash.alg",
"LowStar.Buffer.buffer",
"Lib.IntTypes.uint8",
"Prims.b2t",
"Prims.op_Equality",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"LowStar.Buffer.trivial_preorder",
"Spec.Hash.Definitions.hash_length",
"FStar.UInt32.t",
"Prims.l_and",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt.size",
"FStar.UInt32.n",
"FStar.UInt32.v",
"Spec.Hash.Definitions.less_than_max_input_length",
"Hacl.Hash.MD5.legacy_hash",
"Prims.unit",
"Hacl.Hash.SHA1.legacy_hash",
"EverCrypt.Hash.Incremental.hash_224",
"EverCrypt.Hash.Incremental.hash_256",
"Hacl.Streaming.SHA2.hash_384",
"Hacl.Streaming.SHA2.hash_512",
"Hacl.Hash.SHA3.hash",
"Spec.Hash.Definitions.SHA3_224",
"Spec.Hash.Definitions.SHA3_256",
"Spec.Hash.Definitions.SHA3_384",
"Spec.Hash.Definitions.SHA3_512",
"EverCrypt.TargetConfig.hacl_can_compile_vec128",
"Hacl.Hash.Blake2.hash_blake2s_128",
"Prims.bool",
"Hacl.Hash.Blake2.hash_blake2s_32",
"EverCrypt.AutoConfig2.has_vec128",
"EverCrypt.TargetConfig.hacl_can_compile_vec256",
"Hacl.Hash.Blake2.hash_blake2b_256",
"Hacl.Hash.Blake2.hash_blake2b_32",
"EverCrypt.AutoConfig2.has_vec256"
] | [] | module EverCrypt.Hash.Incremental
open FStar.Mul
// Watch out: keep the module declarations in sync between fsti and fst
// (otherwise interleaving issues may bite).
module B = LowStar.Buffer
module S = FStar.Seq
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module G = FStar.Ghost
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module Hash = EverCrypt.Hash
open FStar.HyperStack.ST
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
include Spec.Hash.Definitions
include Hacl.Hash.Definitions
open Spec.Hash.Lemmas
#set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0"
// Definitions for instantiating the streaming functor
// ---------------------------------------------------
inline_for_extraction noextract
let agile_state: stateful Hash.alg =
Stateful
EverCrypt.Hash.state
(fun #i h s -> EverCrypt.Hash.footprint s h)
EverCrypt.Hash.freeable
(fun #i h s -> EverCrypt.Hash.invariant s h)
Spec.Hash.Definitions.words_state
(fun i h s -> EverCrypt.Hash.repr s h)
(fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h)
(fun #i l s h0 h1 ->
EverCrypt.Hash.frame_invariant l s h0 h1;
EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1)
(fun #i l s h0 h1 -> ())
EverCrypt.Hash.alloca
EverCrypt.Hash.create_in
(fun i -> EverCrypt.Hash.free #i)
(fun i -> EverCrypt.Hash.copy #i)
include EverCrypt.Hash.Incremental.Macros
#push-options "--ifuel 1"
(* Adding some non-inlined definitions to factorize code. This one is public
because it's used by the WASM API, and is generally useful to callers. *)
let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) =
match a with
| MD5 -> md5_hash_len
| SHA1 -> sha1_hash_len
| SHA2_224 -> sha2_224_hash_len
| SHA2_256 -> sha2_256_hash_len
| SHA2_384 -> sha2_384_hash_len
| SHA2_512 -> sha2_512_hash_len
| SHA3_224 -> sha3_224_hash_len
| SHA3_256 -> sha3_256_hash_len
| SHA3_384 -> sha3_384_hash_len
| SHA3_512 -> sha3_512_hash_len
| Blake2S -> blake2s_hash_len
| Blake2B -> blake2b_hash_len
#pop-options
private
let block_len a = Hacl.Hash.Definitions.block_len a
inline_for_extraction noextract
let extra_state_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }):
Spec.Hash.Definitions.extra_state a
=
if is_blake a then
i
else
()
inline_for_extraction noextract
let prev_length_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }):
Spec.Hash.Incremental.prev_length_t a
=
if is_keccak a then
()
else
i
#push-options "--z3rlimit 500"
inline_for_extraction noextract
let evercrypt_hash : block Hash.alg =
Block
Erased
agile_state
(stateful_unused Hash.alg)
unit
Hacl.Hash.Definitions.max_input_len64
(fun a () -> Spec.Hash.Definitions.hash_length a)
block_len
block_len // No vectorization
(fun _ -> 0ul)
(fun _ _ -> S.empty)
(fun a _ -> Spec.Agile.Hash.init a)
(fun a s prevlen input ->
let prevlen = extra_state_of_nat a prevlen in
Spec.Agile.Hash.update_multi a s prevlen input)
(fun a s prevlen input ->
let prevlen = prev_length_of_nat a prevlen in
Spec.Hash.Incremental.update_last a s prevlen input)
(fun a _ s () -> Spec.Agile.Hash.finish a s ())
(fun a _ s () -> Spec.Agile.Hash.hash a s)
(fun a s prevlen ->
if is_blake a then
Spec.Hash.Lemmas.update_multi_zero_blake a prevlen s
else
Spec.Hash.Lemmas.update_multi_zero a s)
(* update_multi_associative *)
(fun a s prevlen1 prevlen2 input1 input2 ->
if is_blake a then
Spec.Hash.Lemmas.update_multi_associative_blake a s prevlen1 prevlen2 input1 input2
else
Spec.Hash.Lemmas.update_multi_associative a s input1 input2)
(* spec_is_incremental *)
(fun a _ input () ->
let input1 = S.append S.empty input in
assert (S.equal input1 input);
Spec.Hash.Incremental.hash_is_hash_incremental' a input ())
EverCrypt.Hash.alg_of_state
(fun i _ _ -> EverCrypt.Hash.init #i)
(fun i s prevlen blocks len -> EverCrypt.Hash.update_multi #i s prevlen blocks len)
(fun i s prevlen last last_len ->
EverCrypt.Hash.update_last #i s prevlen last last_len)
(fun i _ s dst _ -> EverCrypt.Hash.finish #i s dst)
#pop-options
let hash_state =
F.state_s evercrypt_hash SHA2_256 ((agile_state).s SHA2_256) (G.erased unit)
// Public API (streaming)
// ----------------------
[@@ Comment
"Allocate initial state for the agile hash. The argument `a` stands for the
choice of algorithm (see Hacl_Spec.h). This API will automatically pick the most
efficient implementation, provided you have called EverCrypt_AutoConfig2_init()
before. The state is to be freed by calling `free`."]
let create_in a = F.create_in evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) ()
[@@ Comment
"Reset an existing state to the initial hash state with empty data."]
let init (a: G.erased Hash.alg) = F.init evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit) ()
[@@ Comment
"Feed an arbitrary amount of data into the hash. This function returns
EverCrypt_Error_Success for success, or EverCrypt_Error_MaximumLengthExceeded if
the combined length of all of the data passed to `update` (since the last call
to `init`) exceeds 2^61-1 bytes or 2^64-1 bytes, depending on the choice of
algorithm. Both limits are unlikely to be attained in practice."]
let update (i: G.erased Hash.alg)
(s:F.state evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit))
(data: B.buffer uint8)
(len: UInt32.t):
Stack EverCrypt.Error.error_code
(requires fun h0 -> F.update_pre evercrypt_hash i s data len h0)
(ensures fun h0 e h1 ->
match e with
| EverCrypt.Error.Success ->
S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i) /\
F.update_post evercrypt_hash i s data len h0 h1
| EverCrypt.Error.MaximumLengthExceeded ->
h0 == h1 /\
not (S.length (F.seen evercrypt_hash i h0 s) + U32.v len <= U64.v (evercrypt_hash.max_input_len i))
| _ -> False)
=
match F.update evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit) s data len with
| Hacl.Streaming.Types.Success -> EverCrypt.Error.Success
| Hacl.Streaming.Types.MaximumLengthExceeded -> EverCrypt.Error.MaximumLengthExceeded
inline_for_extraction noextract
let finish_st a = F.finish_st evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit)
/// The wrapper pattern, to ensure that the stack-allocated state is properly
/// monomorphized.
private
let finish_md5: finish_st MD5 = F.mk_finish evercrypt_hash MD5 (EverCrypt.Hash.state MD5) (G.erased unit)
private
let finish_sha1: finish_st SHA1 = F.mk_finish evercrypt_hash SHA1 (EverCrypt.Hash.state SHA1) (G.erased unit)
private
let finish_sha224: finish_st SHA2_224 = F.mk_finish evercrypt_hash SHA2_224 (EverCrypt.Hash.state SHA2_224) (G.erased unit)
private
let finish_sha256: finish_st SHA2_256 = F.mk_finish evercrypt_hash SHA2_256 (EverCrypt.Hash.state SHA2_256) (G.erased unit)
private
let finish_sha3_224: finish_st SHA3_224 = F.mk_finish evercrypt_hash SHA3_224 (EverCrypt.Hash.state SHA3_224) (G.erased unit)
private
let finish_sha3_256: finish_st SHA3_256 = F.mk_finish evercrypt_hash SHA3_256 (EverCrypt.Hash.state SHA3_256) (G.erased unit)
private
let finish_sha3_384: finish_st SHA3_384 = F.mk_finish evercrypt_hash SHA3_384 (EverCrypt.Hash.state SHA3_384) (G.erased unit)
private
let finish_sha3_512: finish_st SHA3_512 = F.mk_finish evercrypt_hash SHA3_512 (EverCrypt.Hash.state SHA3_512) (G.erased unit)
private
let finish_sha384: finish_st SHA2_384 = F.mk_finish evercrypt_hash SHA2_384 (EverCrypt.Hash.state SHA2_384) (G.erased unit)
private
let finish_sha512: finish_st SHA2_512 = F.mk_finish evercrypt_hash SHA2_512 (EverCrypt.Hash.state SHA2_512) (G.erased unit)
private
let finish_blake2s: finish_st Blake2S = F.mk_finish evercrypt_hash Blake2S (EverCrypt.Hash.state Blake2S) (G.erased unit)
private
let finish_blake2b: finish_st Blake2B = F.mk_finish evercrypt_hash Blake2B (EverCrypt.Hash.state Blake2B) (G.erased unit)
[@@ Comment
"Perform a run-time test to determine which algorithm was chosen for the given piece of state."]
let alg_of_state (a: G.erased Hash.alg) = F.index_of_state evercrypt_hash a (EverCrypt.Hash.state a) (G.erased unit)
[@@ Comment
"Write the resulting hash into `dst`, an array whose length is
algorithm-specific. You can use the macros defined earlier in this file to
allocate a destination buffer of the right length. The state remains valid after
a call to `finish`, meaning the user may feed more data into the hash via
`update`. (The finish function operates on an internal copy of the state and
therefore does not invalidate the client-held state.)"]
val finish: a:G.erased Hash.alg -> finish_st a
let finish a s dst l =
let a = alg_of_state a s in
match a with
| MD5 -> finish_md5 s dst l
| SHA1 -> finish_sha1 s dst l
| SHA2_224 -> finish_sha224 s dst l
| SHA2_256 -> finish_sha256 s dst l
| SHA2_384 -> finish_sha384 s dst l
| SHA2_512 -> finish_sha512 s dst l
| SHA3_224 -> finish_sha3_224 s dst l
| SHA3_256 -> finish_sha3_256 s dst l
| SHA3_384 -> finish_sha3_384 s dst l
| SHA3_512 -> finish_sha3_512 s dst l
| Blake2S -> finish_blake2s s dst l
| Blake2B -> finish_blake2b s dst l
[@@ Comment
"Free a state previously allocated with `create_in`."]
let free (i: G.erased Hash.alg) = F.free evercrypt_hash i (EverCrypt.Hash.state i) (G.erased unit)
// Private API (one-shot, multiplexing)
// ------------------------------------
private
val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256
// A full one-shot hash that relies on vale at each multiplexing point
let hash_256 input input_len dst =
let open EverCrypt.Hash in
// TODO: This function now only exists for SHA1 and MD5
Hacl.Hash.MD.mk_hash SHA2_256 Hacl.Hash.SHA2.alloca_256 update_multi_256
Hacl.Hash.SHA2.update_last_256 Hacl.Hash.SHA2.finish_256 input input_len dst
private
val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224
let hash_224 input input_len dst =
let open EverCrypt.Hash in
Hacl.Hash.MD.mk_hash SHA2_224 Hacl.Hash.SHA2.alloca_224 update_multi_224
Hacl.Hash.SHA2.update_last_224 Hacl.Hash.SHA2.finish_224 input input_len dst
// Public API (one-shot, agile and multiplexing)
// ---------------------------------------------
// NOTE: this function goes through all the Hacl.Hash.* wrappers which export
// the correct agile low-level type, and thus does not need to be aware of the
// implementation of Spec.Agile.Hash (no friend-ing).
//
// ALSO: for some reason, this function was historically exported with an order
// of arguments different from Hacl.Hash.Definitions.hash_st a. Would be worth
// fixing at some point.
[@@ Comment
"Hash `input`, of len `len`, into `dst`, an array whose length is determined by
your choice of algorithm `a` (see Hacl_Spec.h). You can use the macros defined
earlier in this file to allocate a destination buffer of the right length. This
API will automatically pick the most efficient implementation, provided you have
called EverCrypt_AutoConfig2_init() before. "]
val hash:
a:Hash.alg ->
dst:B.buffer Lib.IntTypes.uint8 {B.length dst = hash_length a} ->
input:B.buffer Lib.IntTypes.uint8 ->
len:FStar.UInt32.t {B.length input = FStar.UInt32.v len /\ FStar.UInt32.v len `less_than_max_input_length` a} ->
Stack unit
(requires fun h0 ->
B.live h0 dst /\
B.live h0 input /\
B.(loc_disjoint (loc_buffer input) (loc_buffer dst)))
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer dst) h0 h1) /\
B.as_seq h1 dst == Spec.Agile.Hash.hash a (B.as_seq h0 input)) | false | false | EverCrypt.Hash.Incremental.fst | {
"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": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash:
a:Hash.alg ->
dst:B.buffer Lib.IntTypes.uint8 {B.length dst = hash_length a} ->
input:B.buffer Lib.IntTypes.uint8 ->
len:FStar.UInt32.t {B.length input = FStar.UInt32.v len /\ FStar.UInt32.v len `less_than_max_input_length` a} ->
Stack unit
(requires fun h0 ->
B.live h0 dst /\
B.live h0 input /\
B.(loc_disjoint (loc_buffer input) (loc_buffer dst)))
(ensures fun h0 _ h1 ->
B.(modifies (loc_buffer dst) h0 h1) /\
B.as_seq h1 dst == Spec.Agile.Hash.hash a (B.as_seq h0 input)) | [] | EverCrypt.Hash.Incremental.hash | {
"file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: EverCrypt.Hash.alg ->
dst:
LowStar.Buffer.buffer Lib.IntTypes.uint8
{LowStar.Monotonic.Buffer.length dst = Spec.Hash.Definitions.hash_length a} ->
input: LowStar.Buffer.buffer Lib.IntTypes.uint8 ->
len:
FStar.UInt32.t
{ LowStar.Monotonic.Buffer.length input = FStar.UInt32.v len /\
Spec.Hash.Definitions.less_than_max_input_length (FStar.UInt32.v len) a }
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 54,
"end_line": 337,
"start_col": 2,
"start_line": 309
} |
Prims.Tot | val evercrypt_hash:block Hash.alg | [
{
"abbrev": false,
"full_module": "EverCrypt.Hash.Incremental.Macros",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "EverCrypt.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let evercrypt_hash : block Hash.alg =
Block
Erased
agile_state
(stateful_unused Hash.alg)
unit
Hacl.Hash.Definitions.max_input_len64
(fun a () -> Spec.Hash.Definitions.hash_length a)
block_len
block_len // No vectorization
(fun _ -> 0ul)
(fun _ _ -> S.empty)
(fun a _ -> Spec.Agile.Hash.init a)
(fun a s prevlen input ->
let prevlen = extra_state_of_nat a prevlen in
Spec.Agile.Hash.update_multi a s prevlen input)
(fun a s prevlen input ->
let prevlen = prev_length_of_nat a prevlen in
Spec.Hash.Incremental.update_last a s prevlen input)
(fun a _ s () -> Spec.Agile.Hash.finish a s ())
(fun a _ s () -> Spec.Agile.Hash.hash a s)
(fun a s prevlen ->
if is_blake a then
Spec.Hash.Lemmas.update_multi_zero_blake a prevlen s
else
Spec.Hash.Lemmas.update_multi_zero a s)
(* update_multi_associative *)
(fun a s prevlen1 prevlen2 input1 input2 ->
if is_blake a then
Spec.Hash.Lemmas.update_multi_associative_blake a s prevlen1 prevlen2 input1 input2
else
Spec.Hash.Lemmas.update_multi_associative a s input1 input2)
(* spec_is_incremental *)
(fun a _ input () ->
let input1 = S.append S.empty input in
assert (S.equal input1 input);
Spec.Hash.Incremental.hash_is_hash_incremental' a input ())
EverCrypt.Hash.alg_of_state
(fun i _ _ -> EverCrypt.Hash.init #i)
(fun i s prevlen blocks len -> EverCrypt.Hash.update_multi #i s prevlen blocks len)
(fun i s prevlen last last_len ->
EverCrypt.Hash.update_last #i s prevlen last last_len)
(fun i _ s dst _ -> EverCrypt.Hash.finish #i s dst) | val evercrypt_hash:block Hash.alg
let evercrypt_hash:block Hash.alg = | false | null | false | Block Erased
agile_state
(stateful_unused Hash.alg)
unit
Hacl.Hash.Definitions.max_input_len64
(fun a () -> Spec.Hash.Definitions.hash_length a)
block_len
block_len
(fun _ -> 0ul)
(fun _ _ -> S.empty)
(fun a _ -> Spec.Agile.Hash.init a)
(fun a s prevlen input ->
let prevlen = extra_state_of_nat a prevlen in
Spec.Agile.Hash.update_multi a s prevlen input)
(fun a s prevlen input ->
let prevlen = prev_length_of_nat a prevlen in
Spec.Hash.Incremental.update_last a s prevlen input)
(fun a _ s () -> Spec.Agile.Hash.finish a s ())
(fun a _ s () -> Spec.Agile.Hash.hash a s)
(fun a s prevlen ->
if is_blake a
then Spec.Hash.Lemmas.update_multi_zero_blake a prevlen s
else Spec.Hash.Lemmas.update_multi_zero a s)
(fun a s prevlen1 prevlen2 input1 input2 ->
if is_blake a
then Spec.Hash.Lemmas.update_multi_associative_blake a s prevlen1 prevlen2 input1 input2
else Spec.Hash.Lemmas.update_multi_associative a s input1 input2)
(fun a _ input () ->
let input1 = S.append S.empty input in
assert (S.equal input1 input);
Spec.Hash.Incremental.hash_is_hash_incremental' a input ())
EverCrypt.Hash.alg_of_state
(fun i _ _ -> EverCrypt.Hash.init #i)
(fun i s prevlen blocks len -> EverCrypt.Hash.update_multi #i s prevlen blocks len)
(fun i s prevlen last last_len -> EverCrypt.Hash.update_last #i s prevlen last last_len)
(fun i _ s dst _ -> EverCrypt.Hash.finish #i s dst) | {
"checked_file": "EverCrypt.Hash.Incremental.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.SHA2.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA3.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.MD5.fsti.checked",
"Hacl.Hash.MD.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"Hacl.Hash.Blake2.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"EverCrypt.TargetConfig.fsti.checked",
"EverCrypt.Hash.Incremental.Macros.fst.checked",
"EverCrypt.Hash.fsti.checked",
"EverCrypt.Error.fsti.checked",
"EverCrypt.AutoConfig2.fsti.checked"
],
"interface_file": false,
"source_file": "EverCrypt.Hash.Incremental.fst"
} | [
"total"
] | [
"Hacl.Streaming.Interface.Block",
"Spec.Hash.Definitions.fixed_len_alg",
"Hacl.Streaming.Interface.Erased",
"EverCrypt.Hash.Incremental.agile_state",
"Hacl.Streaming.Interface.stateful_unused",
"EverCrypt.Hash.alg",
"Prims.unit",
"Hacl.Hash.Definitions.max_input_len64",
"Spec.Hash.Definitions.hash_length",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"FStar.Integers.op_Greater",
"FStar.Integers.Signed",
"FStar.Integers.Winfinite",
"EverCrypt.Hash.Incremental.block_len",
"FStar.UInt32.__uint_to_t",
"FStar.UInt32.t",
"Prims.l_and",
"FStar.Integers.op_Less_Equals",
"FStar.UInt32.v",
"FStar.UInt64.v",
"Hacl.Streaming.Interface.__proj__Stateful__item__t",
"FStar.Seq.Base.empty",
"Hacl.Streaming.Interface.uint8",
"FStar.Seq.Base.seq",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt.size",
"FStar.UInt32.n",
"FStar.Seq.Base.length",
"Spec.Agile.Hash.init",
"FStar.Integers.nat",
"FStar.Integers.op_Percent",
"FStar.Integers.op_Plus",
"Spec.Agile.Hash.update_multi",
"Spec.Hash.Definitions.extra_state",
"EverCrypt.Hash.Incremental.extra_state_of_nat",
"Spec.Hash.Incremental.Definitions.update_last",
"Spec.Hash.Incremental.Definitions.prev_length_t",
"EverCrypt.Hash.Incremental.prev_length_of_nat",
"Spec.Agile.Hash.finish",
"Prims.nat",
"Spec.Agile.Hash.hash",
"Prims.eq2",
"Spec.Hash.Definitions.is_blake",
"Spec.Hash.Lemmas.update_multi_zero_blake",
"Prims.bool",
"Spec.Hash.Lemmas.update_multi_zero",
"Spec.Hash.Lemmas.update_multi_associative_blake",
"Spec.Hash.Lemmas.update_multi_associative",
"Spec.Hash.Incremental.hash_is_hash_incremental'",
"Prims._assert",
"FStar.Seq.Base.equal",
"FStar.Seq.Base.append",
"EverCrypt.Hash.alg_of_state",
"FStar.Ghost.erased",
"Hacl.Streaming.Interface.__proj__Stateful__item__s",
"FStar.Ghost.reveal",
"LowStar.Buffer.buffer",
"LowStar.Monotonic.Buffer.length",
"LowStar.Buffer.trivial_preorder",
"EverCrypt.Hash.init",
"FStar.Monotonic.HyperStack.mem",
"Hacl.Streaming.Interface.__proj__Stateful__item__invariant",
"LowStar.Monotonic.Buffer.live",
"LowStar.Monotonic.Buffer.loc_disjoint",
"Hacl.Streaming.Interface.__proj__Stateful__item__footprint",
"LowStar.Monotonic.Buffer.loc_buffer",
"Prims.l_imp",
"Hacl.Streaming.Interface.__proj__Stateful__item__freeable",
"Hacl.Streaming.Interface.__proj__Stateful__item__v",
"FStar.Seq.Base.slice",
"LowStar.Monotonic.Buffer.as_seq",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_union",
"LowStar.Monotonic.Buffer.loc",
"FStar.UInt64.t",
"EverCrypt.Hash.update_multi",
"LowStar.Monotonic.Buffer.len",
"EverCrypt.Hash.update_last",
"Hacl.Streaming.Interface.optional_key",
"EverCrypt.Hash.finish"
] | [] | module EverCrypt.Hash.Incremental
open FStar.Mul
// Watch out: keep the module declarations in sync between fsti and fst
// (otherwise interleaving issues may bite).
module B = LowStar.Buffer
module S = FStar.Seq
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module G = FStar.Ghost
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module Hash = EverCrypt.Hash
open FStar.HyperStack.ST
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
include Spec.Hash.Definitions
include Hacl.Hash.Definitions
open Spec.Hash.Lemmas
#set-options "--z3rlimit 200 --max_fuel 0 --max_ifuel 0"
// Definitions for instantiating the streaming functor
// ---------------------------------------------------
inline_for_extraction noextract
let agile_state: stateful Hash.alg =
Stateful
EverCrypt.Hash.state
(fun #i h s -> EverCrypt.Hash.footprint s h)
EverCrypt.Hash.freeable
(fun #i h s -> EverCrypt.Hash.invariant s h)
Spec.Hash.Definitions.words_state
(fun i h s -> EverCrypt.Hash.repr s h)
(fun #i h s -> EverCrypt.Hash.invariant_loc_in_footprint s h)
(fun #i l s h0 h1 ->
EverCrypt.Hash.frame_invariant l s h0 h1;
EverCrypt.Hash.frame_invariant_implies_footprint_preservation l s h0 h1)
(fun #i l s h0 h1 -> ())
EverCrypt.Hash.alloca
EverCrypt.Hash.create_in
(fun i -> EverCrypt.Hash.free #i)
(fun i -> EverCrypt.Hash.copy #i)
include EverCrypt.Hash.Incremental.Macros
#push-options "--ifuel 1"
(* Adding some non-inlined definitions to factorize code. This one is public
because it's used by the WASM API, and is generally useful to callers. *)
let hash_len (a:Hash.alg) : (x:UInt32.t { UInt32.v x == Spec.Agile.Hash.hash_length a }) =
match a with
| MD5 -> md5_hash_len
| SHA1 -> sha1_hash_len
| SHA2_224 -> sha2_224_hash_len
| SHA2_256 -> sha2_256_hash_len
| SHA2_384 -> sha2_384_hash_len
| SHA2_512 -> sha2_512_hash_len
| SHA3_224 -> sha3_224_hash_len
| SHA3_256 -> sha3_256_hash_len
| SHA3_384 -> sha3_384_hash_len
| SHA3_512 -> sha3_512_hash_len
| Blake2S -> blake2s_hash_len
| Blake2B -> blake2b_hash_len
#pop-options
private
let block_len a = Hacl.Hash.Definitions.block_len a
inline_for_extraction noextract
let extra_state_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }):
Spec.Hash.Definitions.extra_state a
=
if is_blake a then
i
else
()
inline_for_extraction noextract
let prev_length_of_nat (a: hash_alg) (i: nat { i % U32.v (block_len a) = 0 }):
Spec.Hash.Incremental.prev_length_t a
=
if is_keccak a then
()
else
i
#push-options "--z3rlimit 500"
inline_for_extraction noextract | false | true | EverCrypt.Hash.Incremental.fst | {
"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": 500,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val evercrypt_hash:block Hash.alg | [] | EverCrypt.Hash.Incremental.evercrypt_hash | {
"file_name": "providers/evercrypt/fst/EverCrypt.Hash.Incremental.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Streaming.Interface.block Spec.Hash.Definitions.fixed_len_alg | {
"end_col": 55,
"end_line": 148,
"start_col": 2,
"start_line": 102
} |
Prims.Tot | val nat32_to_word (x:nat32) : word | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let nat32_to_word = to_uint32 | val nat32_to_word (x:nat32) : word
let nat32_to_word = | false | null | false | to_uint32 | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"total"
] | [
"Vale.SHA.SHA_helpers.to_uint32"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y)) | false | true | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val nat32_to_word (x:nat32) : word | [] | Vale.SHA.SHA_helpers.nat32_to_word | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Vale.Def.Words_s.nat32 -> Vale.SHA.SHA_helpers.word | {
"end_col": 29,
"end_line": 56,
"start_col": 20,
"start_line": 56
} |
Prims.Tot | val sha256_rnds2_spec_quad32 (src1 src2 wk: quad32) : quad32 | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef'' | val sha256_rnds2_spec_quad32 (src1 src2 wk: quad32) : quad32
let sha256_rnds2_spec_quad32 (src1 src2 wk: quad32) : quad32 = | false | null | false | let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef'' | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"total"
] | [
"Vale.Def.Types_s.quad32",
"FStar.Pervasives.Native.tuple2",
"Vale.SHA.SHA_helpers.sha256_rnds2_spec_update_quad32",
"Vale.SHA.SHA_helpers.to_uint32",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Vale.Def.Types_s.nat32",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh') | false | true | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val sha256_rnds2_spec_quad32 (src1 src2 wk: quad32) : quad32 | [] | Vale.SHA.SHA_helpers.sha256_rnds2_spec_quad32 | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | src1: Vale.Def.Types_s.quad32 -> src2: Vale.Def.Types_s.quad32 -> wk: Vale.Def.Types_s.quad32
-> Vale.Def.Types_s.quad32 | {
"end_col": 8,
"end_line": 167,
"start_col": 61,
"start_line": 164
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let shuffle_opaque = shuffle | let shuffle_opaque = | false | null | false | shuffle | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"total"
] | [
"Spec.SHA2.shuffle"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
// Top-level proof for the SHA256_msg1 instruction
let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
=
sha256_msg1_spec_reveal ();
let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
let ws_computed (b:block_w) (t:counter{t < size_k_w_256}): Tot (UInt32.t) =
if t < block_word_length SHA2_256 then to_uint32 (ws_opaque b t)
else
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
let open Lib.IntTypes in
(t16 +. s0 +. t7 +. s1)
#push-options "--max_fuel 1"
let lemma_ws_computed_is_ws (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (ws_computed b t == ws SHA2_256 b t)
=
Pervasives.reveal_opaque (`%ws) ws;
if t < block_word_length SHA2_256 then (
assert (vv (ws_computed b t) == ws_opaque b t);
assert (to_uint32 (ws_opaque b t) == ws SHA2_256 b t);
()
) else (
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
lemma_add_mod_ws_rearrangement s1 t7 s0 t16;
()
)
#pop-options
let lemma_ws_computed_is_ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (vv (ws_computed b t) == ws_opaque b t)
=
lemma_ws_computed_is_ws b t;
Pervasives.reveal_opaque (`%ws) ws;
()
let ws_computed_quad32 (t:counter{t < size_k_w_256 - 3}) (block:block_w) : quad32 =
Mkfour (vv (ws_computed block t))
(vv (ws_computed block (t+1)))
(vv (ws_computed block (t+2)))
(vv (ws_computed block (t+3)))
let lemma_ws_computed_is_ws_quad32 (b:block_w) (t:counter{t < size_k_w_256 - 3}) :
Lemma (ws_computed_quad32 t b == ws_quad32 t b)
=
let w = ws_computed_quad32 t b in
let w' = ws_quad32 t b in
lemma_ws_computed_is_ws_opaque b t;
lemma_ws_computed_is_ws_opaque b (t+1);
lemma_ws_computed_is_ws_opaque b (t+2);
lemma_ws_computed_is_ws_opaque b (t+3);
()
#push-options "--z3rlimit 30"
let lemma_ws_computed_quad32 (t:counter{16 <= t /\ t < size_k_w_256 - 4}) (block:block_w) :
Lemma (let t_minus_16 = ws_quad32 (t-16) block in
let t_minus_15 = ws_quad32 (t-15) block in
let t_minus_7 = ws_quad32 (t - 7) block in
let t_minus_2 = ws_quad32 (t - 2) block in
let m1 = add_mod_quad32 t_minus_16 (_sigma0_quad32 t_minus_15) in
let m2 = add_mod_quad32 m1 t_minus_7 in
let m3 = add_mod_quad32 m2 (_sigma1_quad32 t_minus_2) in
m3 == ws_computed_quad32 t block )
=
()
#pop-options
let sha256_msg1_spec_t (t:counter{t < size_k_w_256 - 1}) (block:block_w) : quad32 =
let init = ws_quad32 t block in
let next = ws_quad32 (t + 1) block in
let msg1 = add_mod_quad32 init (_sigma0_quad32 next) in
msg1
#push-options "--ifuel 1"
let lemma_sha256_msg1_spec_t_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 - 3)
(ensures ws_partial t block == sha256_msg1_spec_t (t-16) block)
=
ws_partial_reveal ();
let init = ws_quad32 (t-16) block in
let next = ws_quad32 (t-15) block in
lemma_add_wrap_quad32_is_add_mod_quad32 init (_sigma0_quad32 next);
()
#pop-options
let lemma_sha256_msg1_spec_t (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w_256 - 4 /\
src1 == ws_quad32 t block /\
src2.lo0 == ws_opaque block (t+4))
(ensures sha256_msg1_spec_t t block == sha256_msg1_spec src1 src2)
=
sha256_msg1_spec_reveal ();
()
#push-options "--z3rlimit 70"
let lemma_sha256_step2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1) /\
(let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
src1 == add_mod_quad32 w mid))
(ensures sha256_msg2_spec src1 src2 == ws_computed_quad32 t block)
=
sha256_msg2_spec_reveal ();
let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
let final = sha256_msg2_spec src1 src2 in
lemma_ws_computed_is_ws_opaque block (t);
lemma_ws_computed_is_ws_opaque block (t+1);
()
#pop-options
// Top-level proof for the SHA256_msg2 instruction
let lemma_sha256_msg2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
(let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
src1 == add_wrap_quad32 step1 t_minus_7 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1)))
(ensures sha256_msg2_spec src1 src2 == ws_quad32 t block)
=
let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
lemma_sha256_msg1_spec_t_partial t block;
// ==> step1 == sha256_msg1_spec_t (t-16) block
lemma_add_wrap_quad32_is_add_mod_quad32 step1 t_minus_7;
lemma_sha256_step2 src1 src2 t block;
lemma_ws_computed_is_ws_quad32 block t;
()
(* Abbreviations and lemmas for the code itself *)
#reset-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block qs
=
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32);
reveal_opaque (`%ws) ws
#reset-options "--max_fuel 0 --max_ifuel 0"
let translate_hash_update (h0 h1 h0' h1' a0 a1:quad32) : Lemma
(requires h0' == add_wrap_quad32 a0 h0 /\
h1' == add_wrap_quad32 a1 h1)
(ensures (
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
mapped == h'))
=
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
assert (equal mapped h');
() | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val shuffle_opaque : a: Spec.Hash.Definitions.sha2_alg ->
hash: Spec.Hash.Definitions.words_state a ->
block: Spec.SHA2.block_w a
-> Spec.Hash.Definitions.words_state a | [] | Vale.SHA.SHA_helpers.shuffle_opaque | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Hash.Definitions.sha2_alg ->
hash: Spec.Hash.Definitions.words_state a ->
block: Spec.SHA2.block_w a
-> Spec.Hash.Definitions.words_state a | {
"end_col": 35,
"end_line": 647,
"start_col": 28,
"start_line": 647
} |
|
Prims.Tot | val word:Type0 | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let word = Lib.IntTypes.uint32 | val word:Type0
let word = | false | null | false | Lib.IntTypes.uint32 | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"total"
] | [
"Lib.IntTypes.uint32"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u | false | true | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val word:Type0 | [] | Vale.SHA.SHA_helpers.word | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 30,
"end_line": 28,
"start_col": 11,
"start_line": 28
} |
Prims.Tot | val k : (s:seq word {length s = size_k_w_256}) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let k = (Spec.SHA2.k0 SHA2_256) | val k : (s:seq word {length s = size_k_w_256})
let k = | false | null | false | (Spec.SHA2.k0 SHA2_256) | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"total"
] | [
"Spec.SHA2.k0",
"Spec.Hash.Definitions.SHA2_256"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val k : (s:seq word {length s = size_k_w_256}) | [] | Vale.SHA.SHA_helpers.k | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s:
FStar.Seq.Base.seq Vale.SHA.SHA_helpers.word
{FStar.Seq.Base.length s = Vale.SHA.SHA_helpers.size_k_w_256} | {
"end_col": 31,
"end_line": 29,
"start_col": 8,
"start_line": 29
} |
Prims.Tot | val to_uint32 (n: nat32) : Lib.IntTypes.uint32 | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n | val to_uint32 (n: nat32) : Lib.IntTypes.uint32
let to_uint32 (n: nat32) : Lib.IntTypes.uint32 = | false | null | false | Lib.IntTypes.u32 n | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"total"
] | [
"Vale.Def.Words_s.nat32",
"Lib.IntTypes.u32",
"Lib.IntTypes.uint32"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site | false | true | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val to_uint32 (n: nat32) : Lib.IntTypes.uint32 | [] | Vale.SHA.SHA_helpers.to_uint32 | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n: Vale.Def.Words_s.nat32 -> Lib.IntTypes.uint32 | {
"end_col": 66,
"end_line": 27,
"start_col": 48,
"start_line": 27
} |
Prims.Tot | val vv (u: Lib.IntTypes.uint32) : nat32 | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u | val vv (u: Lib.IntTypes.uint32) : nat32
let vv (u: Lib.IntTypes.uint32) : nat32 = | false | null | false | Lib.IntTypes.v u | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"total"
] | [
"Lib.IntTypes.uint32",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.SEC",
"Vale.Def.Words_s.nat32"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about | false | true | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val vv (u: Lib.IntTypes.uint32) : nat32 | [] | Vale.SHA.SHA_helpers.vv | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | u4: Lib.IntTypes.uint32 -> Vale.Def.Words_s.nat32 | {
"end_col": 57,
"end_line": 26,
"start_col": 41,
"start_line": 26
} |
FStar.Pervasives.Lemma | val lemma_ws_computed_is_ws_quad32 (b: block_w) (t: counter{t < size_k_w_256 - 3})
: Lemma (ws_computed_quad32 t b == ws_quad32 t b) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_ws_computed_is_ws_quad32 (b:block_w) (t:counter{t < size_k_w_256 - 3}) :
Lemma (ws_computed_quad32 t b == ws_quad32 t b)
=
let w = ws_computed_quad32 t b in
let w' = ws_quad32 t b in
lemma_ws_computed_is_ws_opaque b t;
lemma_ws_computed_is_ws_opaque b (t+1);
lemma_ws_computed_is_ws_opaque b (t+2);
lemma_ws_computed_is_ws_opaque b (t+3);
() | val lemma_ws_computed_is_ws_quad32 (b: block_w) (t: counter{t < size_k_w_256 - 3})
: Lemma (ws_computed_quad32 t b == ws_quad32 t b)
let lemma_ws_computed_is_ws_quad32 (b: block_w) (t: counter{t < size_k_w_256 - 3})
: Lemma (ws_computed_quad32 t b == ws_quad32 t b) = | false | null | true | let w = ws_computed_quad32 t b in
let w' = ws_quad32 t b in
lemma_ws_computed_is_ws_opaque b t;
lemma_ws_computed_is_ws_opaque b (t + 1);
lemma_ws_computed_is_ws_opaque b (t + 2);
lemma_ws_computed_is_ws_opaque b (t + 3);
() | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"Vale.SHA.SHA_helpers.block_w",
"Vale.SHA.SHA_helpers.counter",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_Subtraction",
"Vale.SHA.SHA_helpers.size_k_w_256",
"Prims.unit",
"Vale.SHA.SHA_helpers.lemma_ws_computed_is_ws_opaque",
"Prims.op_Addition",
"Vale.Def.Types_s.quad32",
"Vale.SHA.SHA_helpers.ws_quad32",
"Vale.SHA.SHA_helpers.ws_computed_quad32",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
// Top-level proof for the SHA256_msg1 instruction
let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
=
sha256_msg1_spec_reveal ();
let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
let ws_computed (b:block_w) (t:counter{t < size_k_w_256}): Tot (UInt32.t) =
if t < block_word_length SHA2_256 then to_uint32 (ws_opaque b t)
else
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
let open Lib.IntTypes in
(t16 +. s0 +. t7 +. s1)
#push-options "--max_fuel 1"
let lemma_ws_computed_is_ws (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (ws_computed b t == ws SHA2_256 b t)
=
Pervasives.reveal_opaque (`%ws) ws;
if t < block_word_length SHA2_256 then (
assert (vv (ws_computed b t) == ws_opaque b t);
assert (to_uint32 (ws_opaque b t) == ws SHA2_256 b t);
()
) else (
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
lemma_add_mod_ws_rearrangement s1 t7 s0 t16;
()
)
#pop-options
let lemma_ws_computed_is_ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (vv (ws_computed b t) == ws_opaque b t)
=
lemma_ws_computed_is_ws b t;
Pervasives.reveal_opaque (`%ws) ws;
()
let ws_computed_quad32 (t:counter{t < size_k_w_256 - 3}) (block:block_w) : quad32 =
Mkfour (vv (ws_computed block t))
(vv (ws_computed block (t+1)))
(vv (ws_computed block (t+2)))
(vv (ws_computed block (t+3)))
let lemma_ws_computed_is_ws_quad32 (b:block_w) (t:counter{t < size_k_w_256 - 3}) : | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val lemma_ws_computed_is_ws_quad32 (b: block_w) (t: counter{t < size_k_w_256 - 3})
: Lemma (ws_computed_quad32 t b == ws_quad32 t b) | [] | Vale.SHA.SHA_helpers.lemma_ws_computed_is_ws_quad32 | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Vale.SHA.SHA_helpers.block_w ->
t: Vale.SHA.SHA_helpers.counter{t < Vale.SHA.SHA_helpers.size_k_w_256 - 3}
-> FStar.Pervasives.Lemma
(ensures Vale.SHA.SHA_helpers.ws_computed_quad32 t b == Vale.SHA.SHA_helpers.ws_quad32 t b) | {
"end_col": 4,
"end_line": 533,
"start_col": 3,
"start_line": 526
} |
FStar.Pervasives.Lemma | val lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1: quad32)
: Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
() | val lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1: quad32)
: Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1: quad32)
: Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1) = | false | null | true | FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
() | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"Vale.Def.Types_s.quad32",
"Prims.unit",
"FStar.Classical.forall_intro_2",
"Vale.Def.Words_s.nat32",
"Prims.eq2",
"Vale.Def.Words_s.natN",
"Vale.Def.Words_s.pow2_32",
"Vale.Def.Types_s.add_wrap",
"Vale.SHA.SHA_helpers.vv",
"FStar.UInt32.add_mod",
"Vale.SHA.SHA_helpers.to_uint32",
"Vale.SHA.SHA_helpers.lemma_add_wrap_is_add_mod",
"Prims.l_True",
"Prims.squash",
"Vale.SHA.SHA_helpers.add_mod_quad32",
"Vale.Arch.Types.add_wrap_quad32",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1) | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1: quad32)
: Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1) | [] | Vale.SHA.SHA_helpers.lemma_add_wrap_quad32_is_add_mod_quad32 | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | q0: Vale.Def.Types_s.quad32 -> q1: Vale.Def.Types_s.quad32
-> FStar.Pervasives.Lemma
(ensures Vale.SHA.SHA_helpers.add_mod_quad32 q0 q1 == Vale.Arch.Types.add_wrap_quad32 q0 q1) | {
"end_col": 4,
"end_line": 439,
"start_col": 2,
"start_line": 438
} |
Prims.Tot | val ws_computed_quad32 (t: counter{t < size_k_w_256 - 3}) (block: block_w) : quad32 | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ws_computed_quad32 (t:counter{t < size_k_w_256 - 3}) (block:block_w) : quad32 =
Mkfour (vv (ws_computed block t))
(vv (ws_computed block (t+1)))
(vv (ws_computed block (t+2)))
(vv (ws_computed block (t+3))) | val ws_computed_quad32 (t: counter{t < size_k_w_256 - 3}) (block: block_w) : quad32
let ws_computed_quad32 (t: counter{t < size_k_w_256 - 3}) (block: block_w) : quad32 = | false | null | false | Mkfour (vv (ws_computed block t))
(vv (ws_computed block (t + 1)))
(vv (ws_computed block (t + 2)))
(vv (ws_computed block (t + 3))) | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"total"
] | [
"Vale.SHA.SHA_helpers.counter",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_Subtraction",
"Vale.SHA.SHA_helpers.size_k_w_256",
"Vale.SHA.SHA_helpers.block_w",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Vale.SHA.SHA_helpers.vv",
"Vale.SHA.SHA_helpers.ws_computed",
"Prims.op_Addition",
"Vale.Def.Types_s.quad32"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
// Top-level proof for the SHA256_msg1 instruction
let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
=
sha256_msg1_spec_reveal ();
let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
let ws_computed (b:block_w) (t:counter{t < size_k_w_256}): Tot (UInt32.t) =
if t < block_word_length SHA2_256 then to_uint32 (ws_opaque b t)
else
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
let open Lib.IntTypes in
(t16 +. s0 +. t7 +. s1)
#push-options "--max_fuel 1"
let lemma_ws_computed_is_ws (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (ws_computed b t == ws SHA2_256 b t)
=
Pervasives.reveal_opaque (`%ws) ws;
if t < block_word_length SHA2_256 then (
assert (vv (ws_computed b t) == ws_opaque b t);
assert (to_uint32 (ws_opaque b t) == ws SHA2_256 b t);
()
) else (
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
lemma_add_mod_ws_rearrangement s1 t7 s0 t16;
()
)
#pop-options
let lemma_ws_computed_is_ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (vv (ws_computed b t) == ws_opaque b t)
=
lemma_ws_computed_is_ws b t;
Pervasives.reveal_opaque (`%ws) ws;
() | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val ws_computed_quad32 (t: counter{t < size_k_w_256 - 3}) (block: block_w) : quad32 | [] | Vale.SHA.SHA_helpers.ws_computed_quad32 | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
t: Vale.SHA.SHA_helpers.counter{t < Vale.SHA.SHA_helpers.size_k_w_256 - 3} ->
block: Vale.SHA.SHA_helpers.block_w
-> Vale.Def.Types_s.quad32 | {
"end_col": 44,
"end_line": 522,
"start_col": 7,
"start_line": 519
} |
Prims.Tot | val byte_to_nat8 (b:byte) : nat8 | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let byte_to_nat8 = UInt8.v | val byte_to_nat8 (b:byte) : nat8
let byte_to_nat8 = | false | null | false | UInt8.v | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"total"
] | [
"FStar.UInt8.v"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv | false | true | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val byte_to_nat8 (b:byte) : nat8 | [] | Vale.SHA.SHA_helpers.byte_to_nat8 | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Vale.SHA.SHA_helpers.byte -> Vale.Def.Words_s.nat8 | {
"end_col": 26,
"end_line": 57,
"start_col": 19,
"start_line": 57
} |
Prims.Tot | val sha256_rnds2_spec_update_quad32 (abef cdgh: quad32) (wk: UInt32.t) : (quad32 & quad32) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh') | val sha256_rnds2_spec_update_quad32 (abef cdgh: quad32) (wk: UInt32.t) : (quad32 & quad32)
let sha256_rnds2_spec_update_quad32 (abef cdgh: quad32) (wk: UInt32.t) : (quad32 & quad32) = | false | null | false | let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[ 0 ]
hash0.[ 1 ]
hash0.[ 2 ]
hash0.[ 3 ]
hash0.[ 4 ]
hash0.[ 5 ]
hash0.[ 6 ]
hash0.[ 7 ]
wk
in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh') | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"total"
] | [
"Vale.Def.Types_s.quad32",
"FStar.UInt32.t",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.SHA2_256",
"FStar.Pervasives.Native.Mktuple2",
"Vale.Def.Words_s.four",
"Vale.Def.Words_s.nat32",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Vale.SHA.SHA_helpers.vv",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.tuple8",
"Vale.X64.CryptoInstructions_s.sha256_rnds2_spec_update",
"Spec.SHA2.op_String_Access",
"Vale.SHA.SHA_helpers.word",
"Vale.SHA.SHA_helpers.hash256",
"Vale.SHA.SHA_helpers.make_hash"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
() | false | true | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val sha256_rnds2_spec_update_quad32 (abef cdgh: quad32) (wk: UInt32.t) : (quad32 & quad32) | [] | Vale.SHA.SHA_helpers.sha256_rnds2_spec_update_quad32 | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | abef: Vale.Def.Types_s.quad32 -> cdgh: Vale.Def.Types_s.quad32 -> wk: FStar.UInt32.t
-> Vale.Def.Types_s.quad32 * Vale.Def.Types_s.quad32 | {
"end_col": 16,
"end_line": 162,
"start_col": 90,
"start_line": 157
} |
Prims.Tot | val _sigma0_quad32 (q: quad32) : quad32 | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3))) | val _sigma0_quad32 (q: quad32) : quad32
let _sigma0_quad32 (q: quad32) : quad32 = | false | null | false | Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3))) | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"total"
] | [
"Vale.Def.Types_s.quad32",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Vale.SHA.SHA_helpers.vv",
"Spec.SHA2._sigma0",
"Spec.Hash.Definitions.SHA2_256",
"Vale.SHA.SHA_helpers.to_uint32",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *) | false | true | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val _sigma0_quad32 (q: quad32) : quad32 | [] | Vale.SHA.SHA_helpers._sigma0_quad32 | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | q: Vale.Def.Types_s.quad32 -> Vale.Def.Types_s.quad32 | {
"end_col": 50,
"end_line": 412,
"start_col": 2,
"start_line": 409
} |
Prims.Tot | val ws_computed (b: block_w) (t: counter{t < size_k_w_256}) : Tot (UInt32.t) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ws_computed (b:block_w) (t:counter{t < size_k_w_256}): Tot (UInt32.t) =
if t < block_word_length SHA2_256 then to_uint32 (ws_opaque b t)
else
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
let open Lib.IntTypes in
(t16 +. s0 +. t7 +. s1) | val ws_computed (b: block_w) (t: counter{t < size_k_w_256}) : Tot (UInt32.t)
let ws_computed (b: block_w) (t: counter{t < size_k_w_256}) : Tot (UInt32.t) = | false | null | false | if t < block_word_length SHA2_256
then to_uint32 (ws_opaque b t)
else
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
let open Lib.IntTypes in (t16 +. s0 +. t7 +. s1) | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"total"
] | [
"Vale.SHA.SHA_helpers.block_w",
"Vale.SHA.SHA_helpers.counter",
"Prims.b2t",
"Prims.op_LessThan",
"Vale.SHA.SHA_helpers.size_k_w_256",
"Spec.Hash.Definitions.block_word_length",
"Spec.Hash.Definitions.SHA2_256",
"Vale.SHA.SHA_helpers.to_uint32",
"Vale.SHA.SHA_helpers.ws_opaque",
"Prims.bool",
"Lib.IntTypes.op_Plus_Dot",
"Lib.IntTypes.U32",
"Lib.IntTypes.SEC",
"Spec.Hash.Definitions.word",
"Spec.SHA2._sigma0",
"Spec.SHA2._sigma1",
"Lib.IntTypes.int_t",
"Prims.op_Subtraction",
"FStar.UInt32.t"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
// Top-level proof for the SHA256_msg1 instruction
let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
=
sha256_msg1_spec_reveal ();
let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
} | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val ws_computed (b: block_w) (t: counter{t < size_k_w_256}) : Tot (UInt32.t) | [] | Vale.SHA.SHA_helpers.ws_computed | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Vale.SHA.SHA_helpers.block_w ->
t: Vale.SHA.SHA_helpers.counter{t < Vale.SHA.SHA_helpers.size_k_w_256}
-> FStar.UInt32.t | {
"end_col": 27,
"end_line": 488,
"start_col": 2,
"start_line": 479
} |
Prims.Tot | val sha256_msg1_spec_t (t: counter{t < size_k_w_256 - 1}) (block: block_w) : quad32 | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sha256_msg1_spec_t (t:counter{t < size_k_w_256 - 1}) (block:block_w) : quad32 =
let init = ws_quad32 t block in
let next = ws_quad32 (t + 1) block in
let msg1 = add_mod_quad32 init (_sigma0_quad32 next) in
msg1 | val sha256_msg1_spec_t (t: counter{t < size_k_w_256 - 1}) (block: block_w) : quad32
let sha256_msg1_spec_t (t: counter{t < size_k_w_256 - 1}) (block: block_w) : quad32 = | false | null | false | let init = ws_quad32 t block in
let next = ws_quad32 (t + 1) block in
let msg1 = add_mod_quad32 init (_sigma0_quad32 next) in
msg1 | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"total"
] | [
"Vale.SHA.SHA_helpers.counter",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_Subtraction",
"Vale.SHA.SHA_helpers.size_k_w_256",
"Vale.SHA.SHA_helpers.block_w",
"Vale.Def.Types_s.quad32",
"Vale.SHA.SHA_helpers.add_mod_quad32",
"Vale.SHA.SHA_helpers._sigma0_quad32",
"Vale.SHA.SHA_helpers.ws_quad32",
"Prims.op_Addition"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
// Top-level proof for the SHA256_msg1 instruction
let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
=
sha256_msg1_spec_reveal ();
let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
let ws_computed (b:block_w) (t:counter{t < size_k_w_256}): Tot (UInt32.t) =
if t < block_word_length SHA2_256 then to_uint32 (ws_opaque b t)
else
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
let open Lib.IntTypes in
(t16 +. s0 +. t7 +. s1)
#push-options "--max_fuel 1"
let lemma_ws_computed_is_ws (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (ws_computed b t == ws SHA2_256 b t)
=
Pervasives.reveal_opaque (`%ws) ws;
if t < block_word_length SHA2_256 then (
assert (vv (ws_computed b t) == ws_opaque b t);
assert (to_uint32 (ws_opaque b t) == ws SHA2_256 b t);
()
) else (
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
lemma_add_mod_ws_rearrangement s1 t7 s0 t16;
()
)
#pop-options
let lemma_ws_computed_is_ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (vv (ws_computed b t) == ws_opaque b t)
=
lemma_ws_computed_is_ws b t;
Pervasives.reveal_opaque (`%ws) ws;
()
let ws_computed_quad32 (t:counter{t < size_k_w_256 - 3}) (block:block_w) : quad32 =
Mkfour (vv (ws_computed block t))
(vv (ws_computed block (t+1)))
(vv (ws_computed block (t+2)))
(vv (ws_computed block (t+3)))
let lemma_ws_computed_is_ws_quad32 (b:block_w) (t:counter{t < size_k_w_256 - 3}) :
Lemma (ws_computed_quad32 t b == ws_quad32 t b)
=
let w = ws_computed_quad32 t b in
let w' = ws_quad32 t b in
lemma_ws_computed_is_ws_opaque b t;
lemma_ws_computed_is_ws_opaque b (t+1);
lemma_ws_computed_is_ws_opaque b (t+2);
lemma_ws_computed_is_ws_opaque b (t+3);
()
#push-options "--z3rlimit 30"
let lemma_ws_computed_quad32 (t:counter{16 <= t /\ t < size_k_w_256 - 4}) (block:block_w) :
Lemma (let t_minus_16 = ws_quad32 (t-16) block in
let t_minus_15 = ws_quad32 (t-15) block in
let t_minus_7 = ws_quad32 (t - 7) block in
let t_minus_2 = ws_quad32 (t - 2) block in
let m1 = add_mod_quad32 t_minus_16 (_sigma0_quad32 t_minus_15) in
let m2 = add_mod_quad32 m1 t_minus_7 in
let m3 = add_mod_quad32 m2 (_sigma1_quad32 t_minus_2) in
m3 == ws_computed_quad32 t block )
=
()
#pop-options | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val sha256_msg1_spec_t (t: counter{t < size_k_w_256 - 1}) (block: block_w) : quad32 | [] | Vale.SHA.SHA_helpers.sha256_msg1_spec_t | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
t: Vale.SHA.SHA_helpers.counter{t < Vale.SHA.SHA_helpers.size_k_w_256 - 1} ->
block: Vale.SHA.SHA_helpers.block_w
-> Vale.Def.Types_s.quad32 | {
"end_col": 6,
"end_line": 553,
"start_col": 83,
"start_line": 549
} |
Prims.Tot | val nat8_to_byte (b:nat8) : byte | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let nat8_to_byte = UInt8.uint_to_t | val nat8_to_byte (b:nat8) : byte
let nat8_to_byte = | false | null | false | UInt8.uint_to_t | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"total"
] | [
"FStar.UInt8.uint_to_t"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32 | false | true | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val nat8_to_byte (b:nat8) : byte | [] | Vale.SHA.SHA_helpers.nat8_to_byte | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Vale.Def.Words_s.nat8 -> Vale.SHA.SHA_helpers.byte | {
"end_col": 34,
"end_line": 58,
"start_col": 19,
"start_line": 58
} |
Prims.Tot | val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256 | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks | val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256
let update_multi_transparent (hash: hash256) (blocks: bytes_blocks) = | false | null | false | update_multi SHA2_256 hash () blocks | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"total"
] | [
"Vale.SHA.SHA_helpers.hash256",
"Vale.SHA.SHA_helpers.bytes_blocks",
"Spec.Agile.Hash.update_multi",
"Spec.Hash.Definitions.SHA2_256"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks) | false | true | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val update_multi_transparent (hash:hash256) (blocks:bytes_blocks):hash256 | [] | Vale.SHA.SHA_helpers.update_multi_transparent | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | hash: Vale.SHA.SHA_helpers.hash256 -> blocks: Vale.SHA.SHA_helpers.bytes_blocks
-> Vale.SHA.SHA_helpers.hash256 | {
"end_col": 38,
"end_line": 52,
"start_col": 2,
"start_line": 52
} |
Prims.Tot | val ws_partial_def (t:counter) (block:block_w) : quad32 | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0 | val ws_partial_def (t:counter) (block:block_w) : quad32
let ws_partial_def (t: counter) (block: block_w) : quad32 = | false | null | false | if 16 <= t && t < size_k_w_256
then
(let init = ws_quad32 (t - 16) block in
let sigma0_in = ws_quad32 (t - 15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else Mkfour 0 0 0 0 | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"total"
] | [
"Vale.SHA.SHA_helpers.counter",
"Vale.SHA.SHA_helpers.block_w",
"Prims.op_AmpAmp",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Vale.SHA.SHA_helpers.size_k_w_256",
"Vale.Arch.Types.add_wrap_quad32",
"Vale.Def.Types_s.quad32",
"Vale.SHA.SHA_helpers._sigma0_quad32",
"Vale.SHA.SHA_helpers.ws_quad32",
"Prims.op_Subtraction",
"Prims.bool",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3))) | false | true | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val ws_partial_def (t:counter) (block:block_w) : quad32 | [] | Vale.SHA.SHA_helpers.ws_partial_def | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Vale.SHA.SHA_helpers.counter -> block: Vale.SHA.SHA_helpers.block_w -> Vale.Def.Types_s.quad32 | {
"end_col": 21,
"end_line": 427,
"start_col": 4,
"start_line": 421
} |
FStar.Pervasives.Lemma | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def | let make_ordered_hash_reveal = | false | null | true | opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"Vale.Def.Opaque_s.opaque_revealer",
"Vale.Def.Types_s.quad32",
"Vale.SHA.SHA_helpers.hash256",
"Prims.l_True",
"Prims.l_and",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"Vale.SHA.SHA_helpers.word",
"Spec.SHA2.op_String_Access",
"Vale.SHA.SHA_helpers.nat32_to_word",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0",
"Vale.Def.Types_s.nat32",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Vale.SHA.SHA_helpers.make_ordered_hash",
"Vale.SHA.SHA_helpers.make_ordered_hash_def"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val make_ordered_hash_reveal : _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.SHA.SHA_helpers.make_ordered_hash == Vale.SHA.SHA_helpers.make_ordered_hash_def) | [] | Vale.SHA.SHA_helpers.make_ordered_hash_reveal | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.SHA.SHA_helpers.make_ordered_hash == Vale.SHA.SHA_helpers.make_ordered_hash_def) | {
"end_col": 120,
"end_line": 116,
"start_col": 43,
"start_line": 116
} |
|
Prims.Tot | val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t | val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256
let shuffle_core_opaque (block: block_w) (hash: hash256) (t: counter{t < size_k_w_256}) : hash256 = | false | null | false | shuffle_core_opaque_aux SHA2_256 block hash t | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"total"
] | [
"Vale.SHA.SHA_helpers.block_w",
"Vale.SHA.SHA_helpers.hash256",
"Vale.SHA.SHA_helpers.counter",
"Prims.b2t",
"Prims.op_LessThan",
"Vale.SHA.SHA_helpers.size_k_w_256",
"Vale.SHA.SHA_helpers.shuffle_core_opaque_aux",
"Spec.Hash.Definitions.SHA2_256"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 | [] | Vale.SHA.SHA_helpers.shuffle_core_opaque | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
block: Vale.SHA.SHA_helpers.block_w ->
hash: Vale.SHA.SHA_helpers.hash256 ->
t: Vale.SHA.SHA_helpers.counter{t < Vale.SHA.SHA_helpers.size_k_w_256}
-> Vale.SHA.SHA_helpers.hash256 | {
"end_col": 47,
"end_line": 44,
"start_col": 2,
"start_line": 44
} |
FStar.Pervasives.Lemma | val lemma_sha256_msg2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 - 3 /\
(let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
src1 == add_wrap_quad32 step1 t_minus_7 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1)))
(ensures sha256_msg2_spec src1 src2 == ws_quad32 t block) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_sha256_msg2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
(let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
src1 == add_wrap_quad32 step1 t_minus_7 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1)))
(ensures sha256_msg2_spec src1 src2 == ws_quad32 t block)
=
let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
lemma_sha256_msg1_spec_t_partial t block;
// ==> step1 == sha256_msg1_spec_t (t-16) block
lemma_add_wrap_quad32_is_add_mod_quad32 step1 t_minus_7;
lemma_sha256_step2 src1 src2 t block;
lemma_ws_computed_is_ws_quad32 block t;
() | val lemma_sha256_msg2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 - 3 /\
(let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
src1 == add_wrap_quad32 step1 t_minus_7 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1)))
(ensures sha256_msg2_spec src1 src2 == ws_quad32 t block)
let lemma_sha256_msg2 (src1 src2: quad32) (t: counter) (block: block_w)
: Lemma
(requires
16 <= t /\ t < size_k_w (SHA2_256) - 3 /\
(let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t - 7) block in
src1 == add_wrap_quad32 step1 t_minus_7 /\ src2.hi2 == ws_opaque block (t - 2) /\
src2.hi3 == ws_opaque block (t - 1)))
(ensures sha256_msg2_spec src1 src2 == ws_quad32 t block) = | false | null | true | let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t - 7) block in
lemma_sha256_msg1_spec_t_partial t block;
lemma_add_wrap_quad32_is_add_mod_quad32 step1 t_minus_7;
lemma_sha256_step2 src1 src2 t block;
lemma_ws_computed_is_ws_quad32 block t;
() | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"Vale.Def.Types_s.quad32",
"Vale.SHA.SHA_helpers.counter",
"Vale.SHA.SHA_helpers.block_w",
"Prims.unit",
"Vale.SHA.SHA_helpers.lemma_ws_computed_is_ws_quad32",
"Vale.SHA.SHA_helpers.lemma_sha256_step2",
"Vale.SHA.SHA_helpers.lemma_add_wrap_quad32_is_add_mod_quad32",
"Vale.SHA.SHA_helpers.lemma_sha256_msg1_spec_t_partial",
"Vale.SHA.SHA_helpers.ws_quad32",
"Prims.op_Subtraction",
"Vale.SHA.SHA_helpers.ws_partial",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Spec.SHA2.size_k_w",
"Spec.Hash.Definitions.SHA2_256",
"Prims.eq2",
"Vale.Arch.Types.add_wrap_quad32",
"Vale.Def.Words_s.nat32",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Vale.Def.Types_s.nat32",
"Vale.SHA.SHA_helpers.ws_opaque",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Prims.squash",
"Vale.X64.CryptoInstructions_s.sha256_msg2_spec",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
// Top-level proof for the SHA256_msg1 instruction
let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
=
sha256_msg1_spec_reveal ();
let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
let ws_computed (b:block_w) (t:counter{t < size_k_w_256}): Tot (UInt32.t) =
if t < block_word_length SHA2_256 then to_uint32 (ws_opaque b t)
else
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
let open Lib.IntTypes in
(t16 +. s0 +. t7 +. s1)
#push-options "--max_fuel 1"
let lemma_ws_computed_is_ws (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (ws_computed b t == ws SHA2_256 b t)
=
Pervasives.reveal_opaque (`%ws) ws;
if t < block_word_length SHA2_256 then (
assert (vv (ws_computed b t) == ws_opaque b t);
assert (to_uint32 (ws_opaque b t) == ws SHA2_256 b t);
()
) else (
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
lemma_add_mod_ws_rearrangement s1 t7 s0 t16;
()
)
#pop-options
let lemma_ws_computed_is_ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (vv (ws_computed b t) == ws_opaque b t)
=
lemma_ws_computed_is_ws b t;
Pervasives.reveal_opaque (`%ws) ws;
()
let ws_computed_quad32 (t:counter{t < size_k_w_256 - 3}) (block:block_w) : quad32 =
Mkfour (vv (ws_computed block t))
(vv (ws_computed block (t+1)))
(vv (ws_computed block (t+2)))
(vv (ws_computed block (t+3)))
let lemma_ws_computed_is_ws_quad32 (b:block_w) (t:counter{t < size_k_w_256 - 3}) :
Lemma (ws_computed_quad32 t b == ws_quad32 t b)
=
let w = ws_computed_quad32 t b in
let w' = ws_quad32 t b in
lemma_ws_computed_is_ws_opaque b t;
lemma_ws_computed_is_ws_opaque b (t+1);
lemma_ws_computed_is_ws_opaque b (t+2);
lemma_ws_computed_is_ws_opaque b (t+3);
()
#push-options "--z3rlimit 30"
let lemma_ws_computed_quad32 (t:counter{16 <= t /\ t < size_k_w_256 - 4}) (block:block_w) :
Lemma (let t_minus_16 = ws_quad32 (t-16) block in
let t_minus_15 = ws_quad32 (t-15) block in
let t_minus_7 = ws_quad32 (t - 7) block in
let t_minus_2 = ws_quad32 (t - 2) block in
let m1 = add_mod_quad32 t_minus_16 (_sigma0_quad32 t_minus_15) in
let m2 = add_mod_quad32 m1 t_minus_7 in
let m3 = add_mod_quad32 m2 (_sigma1_quad32 t_minus_2) in
m3 == ws_computed_quad32 t block )
=
()
#pop-options
let sha256_msg1_spec_t (t:counter{t < size_k_w_256 - 1}) (block:block_w) : quad32 =
let init = ws_quad32 t block in
let next = ws_quad32 (t + 1) block in
let msg1 = add_mod_quad32 init (_sigma0_quad32 next) in
msg1
#push-options "--ifuel 1"
let lemma_sha256_msg1_spec_t_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 - 3)
(ensures ws_partial t block == sha256_msg1_spec_t (t-16) block)
=
ws_partial_reveal ();
let init = ws_quad32 (t-16) block in
let next = ws_quad32 (t-15) block in
lemma_add_wrap_quad32_is_add_mod_quad32 init (_sigma0_quad32 next);
()
#pop-options
let lemma_sha256_msg1_spec_t (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w_256 - 4 /\
src1 == ws_quad32 t block /\
src2.lo0 == ws_opaque block (t+4))
(ensures sha256_msg1_spec_t t block == sha256_msg1_spec src1 src2)
=
sha256_msg1_spec_reveal ();
()
#push-options "--z3rlimit 70"
let lemma_sha256_step2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1) /\
(let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
src1 == add_mod_quad32 w mid))
(ensures sha256_msg2_spec src1 src2 == ws_computed_quad32 t block)
=
sha256_msg2_spec_reveal ();
let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
let final = sha256_msg2_spec src1 src2 in
lemma_ws_computed_is_ws_opaque block (t);
lemma_ws_computed_is_ws_opaque block (t+1);
()
#pop-options
// Top-level proof for the SHA256_msg2 instruction
let lemma_sha256_msg2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
(let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
src1 == add_wrap_quad32 step1 t_minus_7 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1))) | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val lemma_sha256_msg2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 - 3 /\
(let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
src1 == add_wrap_quad32 step1 t_minus_7 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1)))
(ensures sha256_msg2_spec src1 src2 == ws_quad32 t block) | [] | Vale.SHA.SHA_helpers.lemma_sha256_msg2 | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
src1: Vale.Def.Types_s.quad32 ->
src2: Vale.Def.Types_s.quad32 ->
t: Vale.SHA.SHA_helpers.counter ->
block: Vale.SHA.SHA_helpers.block_w
-> FStar.Pervasives.Lemma
(requires
16 <= t /\ t < Vale.SHA.SHA_helpers.size_k_w_256 - 3 /\
(let step1 = Vale.SHA.SHA_helpers.ws_partial t block in
let t_minus_7 = Vale.SHA.SHA_helpers.ws_quad32 (t - 7) block in
src1 == Vale.Arch.Types.add_wrap_quad32 step1 t_minus_7 /\
Mkfour?.hi2 src2 == Vale.SHA.SHA_helpers.ws_opaque block (t - 2) /\
Mkfour?.hi3 src2 == Vale.SHA.SHA_helpers.ws_opaque block (t - 1)))
(ensures
Vale.X64.CryptoInstructions_s.sha256_msg2_spec src1 src2 ==
Vale.SHA.SHA_helpers.ws_quad32 t block) | {
"end_col": 4,
"end_line": 615,
"start_col": 3,
"start_line": 607
} |
FStar.Pervasives.Lemma | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def | let make_hash_reveal = | false | null | true | opaque_revealer (`%make_hash) make_hash make_hash_def | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"Vale.Def.Opaque_s.opaque_revealer",
"Vale.Def.Types_s.quad32",
"Vale.SHA.SHA_helpers.hash256",
"Prims.l_True",
"Prims.l_and",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"Vale.SHA.SHA_helpers.word",
"Spec.SHA2.op_String_Access",
"Vale.SHA.SHA_helpers.nat32_to_word",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Vale.Def.Types_s.nat32",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0",
"Vale.SHA.SHA_helpers.make_hash",
"Vale.SHA.SHA_helpers.make_hash_def"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val make_hash_reveal : _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.SHA.SHA_helpers.make_hash == Vale.SHA.SHA_helpers.make_hash_def) | [] | Vale.SHA.SHA_helpers.make_hash_reveal | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.SHA.SHA_helpers.make_hash == Vale.SHA.SHA_helpers.make_hash_def) | {
"end_col": 88,
"end_line": 87,
"start_col": 35,
"start_line": 87
} |
|
FStar.Pervasives.Lemma | val lemma_add_mod_ws_rearrangement (a b c d: UInt32.t)
: Lemma (let open Lib.IntTypes in a +. b +. c +. d == d +. c +. b +. a) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
} | val lemma_add_mod_ws_rearrangement (a b c d: UInt32.t)
: Lemma (let open Lib.IntTypes in a +. b +. c +. d == d +. c +. b +. a)
let lemma_add_mod_ws_rearrangement (a b c d: UInt32.t)
: Lemma (let open Lib.IntTypes in a +. b +. c +. d == d +. c +. b +. a) = | false | null | true | let open Lib.IntTypes in
calc ( == ) {
a +. b +. c +. d;
( == ) { () }
(((a +. b) +. c) +. d);
( == ) { (lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b) }
d +. (c +. (b +. a));
( == ) { (lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a) }
(((d +. c) +. b) +. a);
} | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"FStar.UInt32.t",
"FStar.Calc.calc_finish",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.eq2",
"Lib.IntTypes.op_Plus_Dot",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Prims.squash",
"Vale.SHA.SHA_helpers.lemma_add_mod_commutes",
"Vale.SHA.SHA_helpers.lemma_add_mod_associates_U32",
"Prims.l_True",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
// Top-level proof for the SHA256_msg1 instruction
let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
=
sha256_msg1_spec_reveal ();
let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a) | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val lemma_add_mod_ws_rearrangement (a b c d: UInt32.t)
: Lemma (let open Lib.IntTypes in a +. b +. c +. d == d +. c +. b +. a) | [] | Vale.SHA.SHA_helpers.lemma_add_mod_ws_rearrangement | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: FStar.UInt32.t -> b: FStar.UInt32.t -> c: FStar.UInt32.t -> d: FStar.UInt32.t
-> FStar.Pervasives.Lemma (ensures a +. b +. c +. d == d +. c +. b +. a) | {
"end_col": 3,
"end_line": 476,
"start_col": 2,
"start_line": 463
} |
FStar.Pervasives.Lemma | val lemma_sha256_rnds2_spec_quad32 (src1 src2 wk: quad32)
: Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
() | val lemma_sha256_rnds2_spec_quad32 (src1 src2 wk: quad32)
: Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk: quad32)
: Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk) = | false | null | true | sha256_rnds2_spec_reveal ();
() | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"Vale.Def.Types_s.quad32",
"Prims.unit",
"Vale.X64.CryptoInstructions_s.sha256_rnds2_spec_reveal",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"Vale.X64.CryptoInstructions_s.sha256_rnds2_spec",
"Vale.SHA.SHA_helpers.sha256_rnds2_spec_quad32",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk) | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val lemma_sha256_rnds2_spec_quad32 (src1 src2 wk: quad32)
: Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk) | [] | Vale.SHA.SHA_helpers.lemma_sha256_rnds2_spec_quad32 | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | src1: Vale.Def.Types_s.quad32 -> src2: Vale.Def.Types_s.quad32 -> wk: Vale.Def.Types_s.quad32
-> FStar.Pervasives.Lemma
(ensures
Vale.X64.CryptoInstructions_s.sha256_rnds2_spec src1 src2 wk ==
Vale.SHA.SHA_helpers.sha256_rnds2_spec_quad32 src1 src2 wk) | {
"end_col": 4,
"end_line": 173,
"start_col": 2,
"start_line": 172
} |
Prims.Tot | val sha256_rnds2_spec_update_core_quad32
(abef cdgh: quad32)
(wk: UInt32.t)
(block: block_w)
(t: counter{t < size_k_w_256})
: (quad32 & quad32) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh') | val sha256_rnds2_spec_update_core_quad32
(abef cdgh: quad32)
(wk: UInt32.t)
(block: block_w)
(t: counter{t < size_k_w_256})
: (quad32 & quad32)
let sha256_rnds2_spec_update_core_quad32
(abef cdgh: quad32)
(wk: UInt32.t)
(block: block_w)
(t: counter{t < size_k_w_256})
: (quad32 & quad32) = | false | null | false | let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[ 5 ]) (vv hash1.[ 4 ]) (vv hash1.[ 1 ]) (vv hash1.[ 0 ]) in
let cdgh' = Mkfour (vv hash1.[ 7 ]) (vv hash1.[ 6 ]) (vv hash1.[ 3 ]) (vv hash1.[ 2 ]) in
(abef', cdgh') | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"total"
] | [
"Vale.Def.Types_s.quad32",
"FStar.UInt32.t",
"Vale.SHA.SHA_helpers.block_w",
"Vale.SHA.SHA_helpers.counter",
"Prims.b2t",
"Prims.op_LessThan",
"Vale.SHA.SHA_helpers.size_k_w_256",
"FStar.Pervasives.Native.Mktuple2",
"Vale.Def.Words_s.four",
"Vale.Def.Words_s.nat32",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Vale.SHA.SHA_helpers.vv",
"Spec.SHA2.op_String_Access",
"Vale.SHA.SHA_helpers.word",
"Vale.SHA.SHA_helpers.hash256",
"Vale.SHA.SHA_helpers.shuffle_core_opaque",
"Vale.SHA.SHA_helpers.make_hash",
"FStar.Pervasives.Native.tuple2"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val sha256_rnds2_spec_update_core_quad32
(abef cdgh: quad32)
(wk: UInt32.t)
(block: block_w)
(t: counter{t < size_k_w_256})
: (quad32 & quad32) | [] | Vale.SHA.SHA_helpers.sha256_rnds2_spec_update_core_quad32 | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
abef: Vale.Def.Types_s.quad32 ->
cdgh: Vale.Def.Types_s.quad32 ->
wk: FStar.UInt32.t ->
block: Vale.SHA.SHA_helpers.block_w ->
t: Vale.SHA.SHA_helpers.counter{t < Vale.SHA.SHA_helpers.size_k_w_256}
-> Vale.Def.Types_s.quad32 * Vale.Def.Types_s.quad32 | {
"end_col": 16,
"end_line": 312,
"start_col": 141,
"start_line": 307
} |
Prims.Pure | val make_ordered_hash (abcd efgh:quad32): Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word abcd.lo0 /\
hash.[1] == nat32_to_word abcd.lo1 /\
hash.[2] == nat32_to_word abcd.hi2 /\
hash.[3] == nat32_to_word abcd.hi3 /\
hash.[4] == nat32_to_word efgh.lo0 /\
hash.[5] == nat32_to_word efgh.lo1 /\
hash.[6] == nat32_to_word efgh.hi2 /\
hash.[7] == nat32_to_word efgh.hi3
) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let make_ordered_hash = opaque_make make_ordered_hash_def | val make_ordered_hash (abcd efgh:quad32): Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word abcd.lo0 /\
hash.[1] == nat32_to_word abcd.lo1 /\
hash.[2] == nat32_to_word abcd.hi2 /\
hash.[3] == nat32_to_word abcd.hi3 /\
hash.[4] == nat32_to_word efgh.lo0 /\
hash.[5] == nat32_to_word efgh.lo1 /\
hash.[6] == nat32_to_word efgh.hi2 /\
hash.[7] == nat32_to_word efgh.hi3
)
let make_ordered_hash = | false | null | false | opaque_make make_ordered_hash_def | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [] | [
"Vale.Def.Opaque_s.opaque_make",
"Vale.Def.Types_s.quad32",
"Vale.SHA.SHA_helpers.hash256",
"Prims.l_True",
"Prims.l_and",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"Vale.SHA.SHA_helpers.word",
"Spec.SHA2.op_String_Access",
"Vale.SHA.SHA_helpers.nat32_to_word",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0",
"Vale.Def.Types_s.nat32",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Vale.SHA.SHA_helpers.make_ordered_hash_def"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l; | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val make_ordered_hash (abcd efgh:quad32): Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word abcd.lo0 /\
hash.[1] == nat32_to_word abcd.lo1 /\
hash.[2] == nat32_to_word abcd.hi2 /\
hash.[3] == nat32_to_word abcd.hi3 /\
hash.[4] == nat32_to_word efgh.lo0 /\
hash.[5] == nat32_to_word efgh.lo1 /\
hash.[6] == nat32_to_word efgh.hi2 /\
hash.[7] == nat32_to_word efgh.hi3
) | [] | Vale.SHA.SHA_helpers.make_ordered_hash | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | abcd: Vale.Def.Types_s.quad32 -> efgh: Vale.Def.Types_s.quad32
-> Prims.Pure Vale.SHA.SHA_helpers.hash256 | {
"end_col": 76,
"end_line": 115,
"start_col": 43,
"start_line": 115
} |
FStar.Pervasives.Lemma | val lemma_le_bytes_to_seq_quad32_empty (b: seq nat8)
: Lemma (requires b == empty) (ensures le_bytes_to_seq_quad32 b == empty) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_le_bytes_to_seq_quad32_empty (b:seq nat8) : Lemma
(requires b == empty)
(ensures le_bytes_to_seq_quad32 b == empty)
=
reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32;
assert (equal (le_bytes_to_seq_quad32 b) empty) | val lemma_le_bytes_to_seq_quad32_empty (b: seq nat8)
: Lemma (requires b == empty) (ensures le_bytes_to_seq_quad32 b == empty)
let lemma_le_bytes_to_seq_quad32_empty (b: seq nat8)
: Lemma (requires b == empty) (ensures le_bytes_to_seq_quad32 b == empty) = | false | null | true | reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32;
assert (equal (le_bytes_to_seq_quad32 b) empty) | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"FStar.Seq.Base.seq",
"Vale.Def.Words_s.nat8",
"Prims._assert",
"FStar.Seq.Base.equal",
"Vale.Def.Types_s.quad32",
"Vale.Def.Types_s.le_bytes_to_seq_quad32",
"FStar.Seq.Base.empty",
"Prims.unit",
"FStar.Pervasives.reveal_opaque",
"Vale.Def.Types_s.nat8",
"Prims.eq2",
"Prims.int",
"Prims.op_Modulus",
"FStar.Seq.Base.length",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
// Top-level proof for the SHA256_msg1 instruction
let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
=
sha256_msg1_spec_reveal ();
let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
let ws_computed (b:block_w) (t:counter{t < size_k_w_256}): Tot (UInt32.t) =
if t < block_word_length SHA2_256 then to_uint32 (ws_opaque b t)
else
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
let open Lib.IntTypes in
(t16 +. s0 +. t7 +. s1)
#push-options "--max_fuel 1"
let lemma_ws_computed_is_ws (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (ws_computed b t == ws SHA2_256 b t)
=
Pervasives.reveal_opaque (`%ws) ws;
if t < block_word_length SHA2_256 then (
assert (vv (ws_computed b t) == ws_opaque b t);
assert (to_uint32 (ws_opaque b t) == ws SHA2_256 b t);
()
) else (
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
lemma_add_mod_ws_rearrangement s1 t7 s0 t16;
()
)
#pop-options
let lemma_ws_computed_is_ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (vv (ws_computed b t) == ws_opaque b t)
=
lemma_ws_computed_is_ws b t;
Pervasives.reveal_opaque (`%ws) ws;
()
let ws_computed_quad32 (t:counter{t < size_k_w_256 - 3}) (block:block_w) : quad32 =
Mkfour (vv (ws_computed block t))
(vv (ws_computed block (t+1)))
(vv (ws_computed block (t+2)))
(vv (ws_computed block (t+3)))
let lemma_ws_computed_is_ws_quad32 (b:block_w) (t:counter{t < size_k_w_256 - 3}) :
Lemma (ws_computed_quad32 t b == ws_quad32 t b)
=
let w = ws_computed_quad32 t b in
let w' = ws_quad32 t b in
lemma_ws_computed_is_ws_opaque b t;
lemma_ws_computed_is_ws_opaque b (t+1);
lemma_ws_computed_is_ws_opaque b (t+2);
lemma_ws_computed_is_ws_opaque b (t+3);
()
#push-options "--z3rlimit 30"
let lemma_ws_computed_quad32 (t:counter{16 <= t /\ t < size_k_w_256 - 4}) (block:block_w) :
Lemma (let t_minus_16 = ws_quad32 (t-16) block in
let t_minus_15 = ws_quad32 (t-15) block in
let t_minus_7 = ws_quad32 (t - 7) block in
let t_minus_2 = ws_quad32 (t - 2) block in
let m1 = add_mod_quad32 t_minus_16 (_sigma0_quad32 t_minus_15) in
let m2 = add_mod_quad32 m1 t_minus_7 in
let m3 = add_mod_quad32 m2 (_sigma1_quad32 t_minus_2) in
m3 == ws_computed_quad32 t block )
=
()
#pop-options
let sha256_msg1_spec_t (t:counter{t < size_k_w_256 - 1}) (block:block_w) : quad32 =
let init = ws_quad32 t block in
let next = ws_quad32 (t + 1) block in
let msg1 = add_mod_quad32 init (_sigma0_quad32 next) in
msg1
#push-options "--ifuel 1"
let lemma_sha256_msg1_spec_t_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 - 3)
(ensures ws_partial t block == sha256_msg1_spec_t (t-16) block)
=
ws_partial_reveal ();
let init = ws_quad32 (t-16) block in
let next = ws_quad32 (t-15) block in
lemma_add_wrap_quad32_is_add_mod_quad32 init (_sigma0_quad32 next);
()
#pop-options
let lemma_sha256_msg1_spec_t (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w_256 - 4 /\
src1 == ws_quad32 t block /\
src2.lo0 == ws_opaque block (t+4))
(ensures sha256_msg1_spec_t t block == sha256_msg1_spec src1 src2)
=
sha256_msg1_spec_reveal ();
()
#push-options "--z3rlimit 70"
let lemma_sha256_step2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1) /\
(let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
src1 == add_mod_quad32 w mid))
(ensures sha256_msg2_spec src1 src2 == ws_computed_quad32 t block)
=
sha256_msg2_spec_reveal ();
let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
let final = sha256_msg2_spec src1 src2 in
lemma_ws_computed_is_ws_opaque block (t);
lemma_ws_computed_is_ws_opaque block (t+1);
()
#pop-options
// Top-level proof for the SHA256_msg2 instruction
let lemma_sha256_msg2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
(let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
src1 == add_wrap_quad32 step1 t_minus_7 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1)))
(ensures sha256_msg2_spec src1 src2 == ws_quad32 t block)
=
let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
lemma_sha256_msg1_spec_t_partial t block;
// ==> step1 == sha256_msg1_spec_t (t-16) block
lemma_add_wrap_quad32_is_add_mod_quad32 step1 t_minus_7;
lemma_sha256_step2 src1 src2 t block;
lemma_ws_computed_is_ws_quad32 block t;
()
(* Abbreviations and lemmas for the code itself *)
#reset-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block qs
=
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32);
reveal_opaque (`%ws) ws
#reset-options "--max_fuel 0 --max_ifuel 0"
let translate_hash_update (h0 h1 h0' h1' a0 a1:quad32) : Lemma
(requires h0' == add_wrap_quad32 a0 h0 /\
h1' == add_wrap_quad32 a1 h1)
(ensures (
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
mapped == h'))
=
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
assert (equal mapped h');
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_lemma (src1 src2 src1' src2' h0 h1:quad32) (block:block_w) : Lemma
(requires (let hash_orig = make_hash h0 h1 in
make_hash src1 src2 ==
Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash_orig /\
src1' == add_wrap_quad32 src1 h0 /\
src2' == add_wrap_quad32 src2 h1))
(ensures (let hash_orig = make_hash h0 h1 in
make_hash src1' src2' == update_block hash_orig block))
=
let hash_orig = make_hash h0 h1 in
let hash_1 = shuffle_opaque SHA2_256 hash_orig block in
Pervasives.reveal_opaque (`%shuffle) shuffle;
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let rec f (i:nat{i <= 64}) : Lemma (
Spec.Loops.repeat_range 0 i (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 i (shuffle_core SHA2_256 block) hash_orig)
=
if i = 0 then (
Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_base 0 (shuffle_core SHA2_256 block) hash_orig
) else (
f (i - 1);
Spec.Loops.repeat_range_induction 0 i (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_induction 0 i (shuffle_core SHA2_256 block) hash_orig
)
in
f 64;
(*
let h = make_hash src1 src2 in
assert (forall (block:block_w) (hash:hash256) . FStar.FunctionalExtensionality.feq (shuffle_core_opaque block hash) (shuffle_core_opaque_aux SHA2_256 block hash));
//assert (forall (block:block_w) . (shuffle_core_opaque block) == (shuffle_core_opaque_aux SHA2_256 block));
assert (shuffle_core_opaque == shuffle_core_opaque_aux SHA2_256);
assert (shuffle_core_opaque == shuffle_core SHA2_256);
assert (shuffle_core_opaque block == shuffle_core SHA2_256 block);
assert (Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 64 (shuffle_core SHA2_256 block) hash_orig);
assert (make_hash src1 src2 == shuffle SHA2_256 hash_orig block);
assert (make_hash src1 src2 == shuffle_opaque SHA2_256 hash_orig block);
*)
translate_hash_update src1 src2 src1' src2' h0 h1;
shuffle_is_shuffle_pre SHA2_256 hash_orig block;
assert (equal (make_hash src1' src2') (update_block hash_orig block));
()
let lemma_le_bytes_to_seq_quad32_empty (b:seq nat8) : Lemma
(requires b == empty)
(ensures le_bytes_to_seq_quad32 b == empty) | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val lemma_le_bytes_to_seq_quad32_empty (b: seq nat8)
: Lemma (requires b == empty) (ensures le_bytes_to_seq_quad32 b == empty) | [] | Vale.SHA.SHA_helpers.lemma_le_bytes_to_seq_quad32_empty | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: FStar.Seq.Base.seq Vale.Def.Words_s.nat8
-> FStar.Pervasives.Lemma (requires b == FStar.Seq.Base.empty)
(ensures Vale.Def.Types_s.le_bytes_to_seq_quad32 b == FStar.Seq.Base.empty) | {
"end_col": 49,
"end_line": 714,
"start_col": 2,
"start_line": 713
} |
Prims.Pure | val make_hash (abef cdgh:quad32) : Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word abef.hi3 /\
hash.[1] == nat32_to_word abef.hi2 /\
hash.[2] == nat32_to_word cdgh.hi3 /\
hash.[3] == nat32_to_word cdgh.hi2 /\
hash.[4] == nat32_to_word abef.lo1 /\
hash.[5] == nat32_to_word abef.lo0 /\
hash.[6] == nat32_to_word cdgh.lo1 /\
hash.[7] == nat32_to_word cdgh.lo0
) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let make_hash = opaque_make make_hash_def | val make_hash (abef cdgh:quad32) : Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word abef.hi3 /\
hash.[1] == nat32_to_word abef.hi2 /\
hash.[2] == nat32_to_word cdgh.hi3 /\
hash.[3] == nat32_to_word cdgh.hi2 /\
hash.[4] == nat32_to_word abef.lo1 /\
hash.[5] == nat32_to_word abef.lo0 /\
hash.[6] == nat32_to_word cdgh.lo1 /\
hash.[7] == nat32_to_word cdgh.lo0
)
let make_hash = | false | null | false | opaque_make make_hash_def | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [] | [
"Vale.Def.Opaque_s.opaque_make",
"Vale.Def.Types_s.quad32",
"Vale.SHA.SHA_helpers.hash256",
"Prims.l_True",
"Prims.l_and",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"Vale.SHA.SHA_helpers.word",
"Spec.SHA2.op_String_Access",
"Vale.SHA.SHA_helpers.nat32_to_word",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Vale.Def.Types_s.nat32",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0",
"Vale.SHA.SHA_helpers.make_hash_def"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c); | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val make_hash (abef cdgh:quad32) : Pure (hash256)
(requires True)
(ensures fun hash ->
length hash == 8 /\
hash.[0] == nat32_to_word abef.hi3 /\
hash.[1] == nat32_to_word abef.hi2 /\
hash.[2] == nat32_to_word cdgh.hi3 /\
hash.[3] == nat32_to_word cdgh.hi2 /\
hash.[4] == nat32_to_word abef.lo1 /\
hash.[5] == nat32_to_word abef.lo0 /\
hash.[6] == nat32_to_word cdgh.lo1 /\
hash.[7] == nat32_to_word cdgh.lo0
) | [] | Vale.SHA.SHA_helpers.make_hash | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | abef: Vale.Def.Types_s.quad32 -> cdgh: Vale.Def.Types_s.quad32
-> Prims.Pure Vale.SHA.SHA_helpers.hash256 | {
"end_col": 60,
"end_line": 86,
"start_col": 35,
"start_line": 86
} |
FStar.Pervasives.Lemma | val lemma_sha256_msg1_spec_t (src1 src2: quad32) (t: counter) (block: block_w)
: Lemma
(requires
t < size_k_w_256 - 4 /\ src1 == ws_quad32 t block /\ src2.lo0 == ws_opaque block (t + 4))
(ensures sha256_msg1_spec_t t block == sha256_msg1_spec src1 src2) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_sha256_msg1_spec_t (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w_256 - 4 /\
src1 == ws_quad32 t block /\
src2.lo0 == ws_opaque block (t+4))
(ensures sha256_msg1_spec_t t block == sha256_msg1_spec src1 src2)
=
sha256_msg1_spec_reveal ();
() | val lemma_sha256_msg1_spec_t (src1 src2: quad32) (t: counter) (block: block_w)
: Lemma
(requires
t < size_k_w_256 - 4 /\ src1 == ws_quad32 t block /\ src2.lo0 == ws_opaque block (t + 4))
(ensures sha256_msg1_spec_t t block == sha256_msg1_spec src1 src2)
let lemma_sha256_msg1_spec_t (src1 src2: quad32) (t: counter) (block: block_w)
: Lemma
(requires
t < size_k_w_256 - 4 /\ src1 == ws_quad32 t block /\ src2.lo0 == ws_opaque block (t + 4))
(ensures sha256_msg1_spec_t t block == sha256_msg1_spec src1 src2) = | false | null | true | sha256_msg1_spec_reveal ();
() | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"Vale.Def.Types_s.quad32",
"Vale.SHA.SHA_helpers.counter",
"Vale.SHA.SHA_helpers.block_w",
"Prims.unit",
"Vale.X64.CryptoInstructions_s.sha256_msg1_spec_reveal",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_Subtraction",
"Vale.SHA.SHA_helpers.size_k_w_256",
"Prims.eq2",
"Vale.SHA.SHA_helpers.ws_quad32",
"Vale.Def.Words_s.nat32",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0",
"Vale.Def.Types_s.nat32",
"Vale.SHA.SHA_helpers.ws_opaque",
"Prims.op_Addition",
"Prims.squash",
"Vale.SHA.SHA_helpers.sha256_msg1_spec_t",
"Vale.X64.CryptoInstructions_s.sha256_msg1_spec",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
// Top-level proof for the SHA256_msg1 instruction
let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
=
sha256_msg1_spec_reveal ();
let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
let ws_computed (b:block_w) (t:counter{t < size_k_w_256}): Tot (UInt32.t) =
if t < block_word_length SHA2_256 then to_uint32 (ws_opaque b t)
else
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
let open Lib.IntTypes in
(t16 +. s0 +. t7 +. s1)
#push-options "--max_fuel 1"
let lemma_ws_computed_is_ws (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (ws_computed b t == ws SHA2_256 b t)
=
Pervasives.reveal_opaque (`%ws) ws;
if t < block_word_length SHA2_256 then (
assert (vv (ws_computed b t) == ws_opaque b t);
assert (to_uint32 (ws_opaque b t) == ws SHA2_256 b t);
()
) else (
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
lemma_add_mod_ws_rearrangement s1 t7 s0 t16;
()
)
#pop-options
let lemma_ws_computed_is_ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (vv (ws_computed b t) == ws_opaque b t)
=
lemma_ws_computed_is_ws b t;
Pervasives.reveal_opaque (`%ws) ws;
()
let ws_computed_quad32 (t:counter{t < size_k_w_256 - 3}) (block:block_w) : quad32 =
Mkfour (vv (ws_computed block t))
(vv (ws_computed block (t+1)))
(vv (ws_computed block (t+2)))
(vv (ws_computed block (t+3)))
let lemma_ws_computed_is_ws_quad32 (b:block_w) (t:counter{t < size_k_w_256 - 3}) :
Lemma (ws_computed_quad32 t b == ws_quad32 t b)
=
let w = ws_computed_quad32 t b in
let w' = ws_quad32 t b in
lemma_ws_computed_is_ws_opaque b t;
lemma_ws_computed_is_ws_opaque b (t+1);
lemma_ws_computed_is_ws_opaque b (t+2);
lemma_ws_computed_is_ws_opaque b (t+3);
()
#push-options "--z3rlimit 30"
let lemma_ws_computed_quad32 (t:counter{16 <= t /\ t < size_k_w_256 - 4}) (block:block_w) :
Lemma (let t_minus_16 = ws_quad32 (t-16) block in
let t_minus_15 = ws_quad32 (t-15) block in
let t_minus_7 = ws_quad32 (t - 7) block in
let t_minus_2 = ws_quad32 (t - 2) block in
let m1 = add_mod_quad32 t_minus_16 (_sigma0_quad32 t_minus_15) in
let m2 = add_mod_quad32 m1 t_minus_7 in
let m3 = add_mod_quad32 m2 (_sigma1_quad32 t_minus_2) in
m3 == ws_computed_quad32 t block )
=
()
#pop-options
let sha256_msg1_spec_t (t:counter{t < size_k_w_256 - 1}) (block:block_w) : quad32 =
let init = ws_quad32 t block in
let next = ws_quad32 (t + 1) block in
let msg1 = add_mod_quad32 init (_sigma0_quad32 next) in
msg1
#push-options "--ifuel 1"
let lemma_sha256_msg1_spec_t_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 - 3)
(ensures ws_partial t block == sha256_msg1_spec_t (t-16) block)
=
ws_partial_reveal ();
let init = ws_quad32 (t-16) block in
let next = ws_quad32 (t-15) block in
lemma_add_wrap_quad32_is_add_mod_quad32 init (_sigma0_quad32 next);
()
#pop-options
let lemma_sha256_msg1_spec_t (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w_256 - 4 /\
src1 == ws_quad32 t block /\
src2.lo0 == ws_opaque block (t+4))
(ensures sha256_msg1_spec_t t block == sha256_msg1_spec src1 src2) | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val lemma_sha256_msg1_spec_t (src1 src2: quad32) (t: counter) (block: block_w)
: Lemma
(requires
t < size_k_w_256 - 4 /\ src1 == ws_quad32 t block /\ src2.lo0 == ws_opaque block (t + 4))
(ensures sha256_msg1_spec_t t block == sha256_msg1_spec src1 src2) | [] | Vale.SHA.SHA_helpers.lemma_sha256_msg1_spec_t | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
src1: Vale.Def.Types_s.quad32 ->
src2: Vale.Def.Types_s.quad32 ->
t: Vale.SHA.SHA_helpers.counter ->
block: Vale.SHA.SHA_helpers.block_w
-> FStar.Pervasives.Lemma
(requires
t < Vale.SHA.SHA_helpers.size_k_w_256 - 4 /\ src1 == Vale.SHA.SHA_helpers.ws_quad32 t block /\
Mkfour?.lo0 src2 == Vale.SHA.SHA_helpers.ws_opaque block (t + 4))
(ensures
Vale.SHA.SHA_helpers.sha256_msg1_spec_t t block ==
Vale.X64.CryptoInstructions_s.sha256_msg1_spec src1 src2) | {
"end_col": 4,
"end_line": 576,
"start_col": 2,
"start_line": 575
} |
FStar.Pervasives.Lemma | val lemma_sha256_rnds2_two_steps (abef cdgh xmm0: quad32) (t: counter) (block: block_w)
: Lemma
(requires
t + 1 < size_k_w_256 /\ xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[ t ]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[ t + 1 ]) (ws_opaque block (t + 1)))
(ensures
(let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef)) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
() | val lemma_sha256_rnds2_two_steps (abef cdgh xmm0: quad32) (t: counter) (block: block_w)
: Lemma
(requires
t + 1 < size_k_w_256 /\ xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[ t ]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[ t + 1 ]) (ws_opaque block (t + 1)))
(ensures
(let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0: quad32) (t: counter) (block: block_w)
: Lemma
(requires
t + 1 < size_k_w_256 /\ xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[ t ]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[ t + 1 ]) (ws_opaque block (t + 1)))
(ensures
(let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef)) = | false | null | true | let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[ t ]) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[ t + 1 ]) (ws_opaque block (t + 1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
() | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"Vale.Def.Types_s.quad32",
"Vale.SHA.SHA_helpers.counter",
"Vale.SHA.SHA_helpers.block_w",
"Prims.unit",
"Vale.SHA.SHA_helpers.lemma_sha256_rnds2_spec_quad32",
"Vale.SHA.SHA_helpers.sha256_rnds2_spec_quad32_is_shuffle_core_x2",
"Vale.SHA.SHA_helpers.lemma_add_wrap_is_add_mod",
"Vale.SHA.SHA_helpers.vv",
"Spec.SHA2.op_String_Access",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.SHA2_256",
"Spec.SHA2.k0",
"Prims.op_Addition",
"Vale.SHA.SHA_helpers.ws_opaque",
"Vale.SHA.SHA_helpers.hash256",
"Vale.SHA.SHA_helpers.shuffle_core_opaque",
"Vale.SHA.SHA_helpers.make_hash",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Vale.SHA.SHA_helpers.size_k_w_256",
"Prims.eq2",
"Vale.Def.Words_s.natN",
"Vale.Def.Words_s.pow2_32",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0",
"Vale.Def.Types_s.nat32",
"Vale.Def.Types_s.add_wrap",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Prims.squash",
"Vale.X64.CryptoInstructions_s.sha256_rnds2_spec",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val lemma_sha256_rnds2_two_steps (abef cdgh xmm0: quad32) (t: counter) (block: block_w)
: Lemma
(requires
t + 1 < size_k_w_256 /\ xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[ t ]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[ t + 1 ]) (ws_opaque block (t + 1)))
(ensures
(let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef)) | [] | Vale.SHA.SHA_helpers.lemma_sha256_rnds2_two_steps | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
abef: Vale.Def.Types_s.quad32 ->
cdgh: Vale.Def.Types_s.quad32 ->
xmm0: Vale.Def.Types_s.quad32 ->
t: Vale.SHA.SHA_helpers.counter ->
block: Vale.SHA.SHA_helpers.block_w
-> FStar.Pervasives.Lemma
(requires
t + 1 < Vale.SHA.SHA_helpers.size_k_w_256 /\
Mkfour?.lo0 xmm0 ==
Vale.Def.Types_s.add_wrap (Vale.SHA.SHA_helpers.vv (Spec.SHA2.k0 Spec.Hash.Definitions.SHA2_256
).[ t ])
(Vale.SHA.SHA_helpers.ws_opaque block t) /\
Mkfour?.lo1 xmm0 ==
Vale.Def.Types_s.add_wrap (Vale.SHA.SHA_helpers.vv (Spec.SHA2.k0 Spec.Hash.Definitions.SHA2_256
).[ t + 1 ])
(Vale.SHA.SHA_helpers.ws_opaque block (t + 1)))
(ensures
(let hash0 = Vale.SHA.SHA_helpers.make_hash abef cdgh in
let hash1 = Vale.SHA.SHA_helpers.shuffle_core_opaque block hash0 t in
let hash2 = Vale.SHA.SHA_helpers.shuffle_core_opaque block hash1 (t + 1) in
hash2 ==
Vale.SHA.SHA_helpers.make_hash (Vale.X64.CryptoInstructions_s.sha256_rnds2_spec cdgh
abef
xmm0)
abef)) | {
"end_col": 4,
"end_line": 388,
"start_col": 3,
"start_line": 380
} |
FStar.Pervasives.Lemma | val lemma_add_mod_e (a b c d e f g h wk: UInt32.t)
: Lemma
(let u =
add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d)))
in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
() | val lemma_add_mod_e (a b c d e f g h wk: UInt32.t)
: Lemma
(let u =
add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d)))
in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
let lemma_add_mod_e (a b c d e f g h wk: UInt32.t)
: Lemma
(let u =
add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d)))
in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core) = | false | null | true | let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
lemma_add_mod_commutes d t1;
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core ==
add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core ==
add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core ==
add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
() | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"FStar.UInt32.t",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"FStar.UInt32.add_mod",
"Spec.SHA2._Ch",
"Spec.Hash.Definitions.SHA2_256",
"Spec.SHA2._Sigma1",
"Vale.SHA.SHA_helpers.lemma_add_mod_associates_U32",
"Vale.SHA.SHA_helpers.lemma_add_mod_commutes",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val lemma_add_mod_e (a b c d e f g h wk: UInt32.t)
: Lemma
(let u =
add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d)))
in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core) | [] | Vale.SHA.SHA_helpers.lemma_add_mod_e | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: FStar.UInt32.t ->
b: FStar.UInt32.t ->
c: FStar.UInt32.t ->
d: FStar.UInt32.t ->
e: FStar.UInt32.t ->
f: FStar.UInt32.t ->
g: FStar.UInt32.t ->
h: FStar.UInt32.t ->
wk: FStar.UInt32.t
-> FStar.Pervasives.Lemma
(ensures
(let u105 =
FStar.UInt32.add_mod (Spec.SHA2._Ch Spec.Hash.Definitions.SHA2_256 e f g)
(FStar.UInt32.add_mod (Spec.SHA2._Sigma1 Spec.Hash.Definitions.SHA2_256 e)
(FStar.UInt32.add_mod wk (FStar.UInt32.add_mod h d)))
in
let t1 =
FStar.UInt32.add_mod h
(FStar.UInt32.add_mod (Spec.SHA2._Sigma1 Spec.Hash.Definitions.SHA2_256 e)
(FStar.UInt32.add_mod (Spec.SHA2._Ch Spec.Hash.Definitions.SHA2_256 e f g) wk))
in
let core = FStar.UInt32.add_mod d t1 in
u105 == core)) | {
"end_col": 4,
"end_line": 281,
"start_col": 3,
"start_line": 266
} |
FStar.Pervasives.Lemma | val lemma_rnds_quad32
(abef cdgh: quad32)
(wk: UInt32.t)
(block: block_w)
(t: counter{t < size_k_w_256})
: Lemma (requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[ t ] (ws_opaque block t)))
(ensures
sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t ==
sha256_rnds2_spec_update_quad32 abef cdgh wk) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
() | val lemma_rnds_quad32
(abef cdgh: quad32)
(wk: UInt32.t)
(block: block_w)
(t: counter{t < size_k_w_256})
: Lemma (requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[ t ] (ws_opaque block t)))
(ensures
sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t ==
sha256_rnds2_spec_update_quad32 abef cdgh wk)
let lemma_rnds_quad32
(abef cdgh: quad32)
(wk: UInt32.t)
(block: block_w)
(t: counter{t < size_k_w_256})
: Lemma (requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[ t ] (ws_opaque block t)))
(ensures
sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t ==
sha256_rnds2_spec_update_quad32 abef cdgh wk) = | false | null | true | let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[ 0 ]
hash0.[ 1 ]
hash0.[ 2 ]
hash0.[ 3 ]
hash0.[ 4 ]
hash0.[ 5 ]
hash0.[ 6 ]
hash0.[ 7 ]
wk
in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
() | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"Vale.Def.Types_s.quad32",
"FStar.UInt32.t",
"Vale.SHA.SHA_helpers.block_w",
"Vale.SHA.SHA_helpers.counter",
"Prims.b2t",
"Prims.op_LessThan",
"Vale.SHA.SHA_helpers.size_k_w_256",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.SHA2_256",
"Prims.unit",
"Vale.SHA.SHA_helpers.lemma_sha256_rnds2_spec_update_is_shuffle_core",
"FStar.Seq.Properties.elim_of_list",
"Prims.list",
"Prims.Cons",
"Prims.Nil",
"FStar.Pervasives.Native.tuple8",
"Vale.X64.CryptoInstructions_s.sha256_rnds2_spec_update",
"Spec.SHA2.op_String_Access",
"Vale.SHA.SHA_helpers.word",
"Vale.SHA.SHA_helpers.hash256",
"Vale.SHA.SHA_helpers.shuffle_core_opaque",
"Vale.SHA.SHA_helpers.make_hash",
"Prims.eq2",
"Vale.SHA.SHA_helpers.to_uint32",
"Vale.SHA.SHA_helpers.add_mod32",
"Spec.SHA2.k0",
"Vale.SHA.SHA_helpers.ws_opaque",
"Prims.squash",
"FStar.Pervasives.Native.tuple2",
"Vale.SHA.SHA_helpers.sha256_rnds2_spec_update_core_quad32",
"Vale.SHA.SHA_helpers.sha256_rnds2_spec_update_quad32",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t))) | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val lemma_rnds_quad32
(abef cdgh: quad32)
(wk: UInt32.t)
(block: block_w)
(t: counter{t < size_k_w_256})
: Lemma (requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[ t ] (ws_opaque block t)))
(ensures
sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t ==
sha256_rnds2_spec_update_quad32 abef cdgh wk) | [] | Vale.SHA.SHA_helpers.lemma_rnds_quad32 | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
abef: Vale.Def.Types_s.quad32 ->
cdgh: Vale.Def.Types_s.quad32 ->
wk: FStar.UInt32.t ->
block: Vale.SHA.SHA_helpers.block_w ->
t: Vale.SHA.SHA_helpers.counter{t < Vale.SHA.SHA_helpers.size_k_w_256}
-> FStar.Pervasives.Lemma
(requires
wk ==
Vale.SHA.SHA_helpers.to_uint32 (Vale.SHA.SHA_helpers.add_mod32 (Spec.SHA2.k0 Spec.Hash.Definitions.SHA2_256
).[ t ]
(Vale.SHA.SHA_helpers.ws_opaque block t)))
(ensures
Vale.SHA.SHA_helpers.sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t ==
Vale.SHA.SHA_helpers.sha256_rnds2_spec_update_quad32 abef cdgh wk) | {
"end_col": 4,
"end_line": 326,
"start_col": 3,
"start_line": 317
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ws_opaque_aux = ws | let ws_opaque_aux = | false | null | false | ws | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"total"
] | [
"Spec.SHA2.Lemmas.ws"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = () | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val ws_opaque_aux : a: Spec.Hash.Definitions.sha2_alg ->
b: Spec.SHA2.block_w a ->
t: Spec.SHA2.counter{t < Spec.SHA2.size_k_w a}
-> Spec.Hash.Definitions.word a | [] | Vale.SHA.SHA_helpers.ws_opaque_aux | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Hash.Definitions.sha2_alg ->
b: Spec.SHA2.block_w a ->
t: Spec.SHA2.counter{t < Spec.SHA2.size_k_w a}
-> Spec.Hash.Definitions.word a | {
"end_col": 29,
"end_line": 38,
"start_col": 27,
"start_line": 38
} |
|
Prims.Tot | val make_ordered_hash_def (abcd efgh: quad32)
: (hash:
words_state SHA2_256
{ length hash == 8 /\ hash.[ 0 ] == to_uint32 abcd.lo0 /\ hash.[ 1 ] == to_uint32 abcd.lo1 /\
hash.[ 2 ] == to_uint32 abcd.hi2 /\ hash.[ 3 ] == to_uint32 abcd.hi3 /\
hash.[ 4 ] == to_uint32 efgh.lo0 /\ hash.[ 5 ] == to_uint32 efgh.lo1 /\
hash.[ 6 ] == to_uint32 efgh.hi2 /\ hash.[ 7 ] == to_uint32 efgh.hi3 }) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash | val make_ordered_hash_def (abcd efgh: quad32)
: (hash:
words_state SHA2_256
{ length hash == 8 /\ hash.[ 0 ] == to_uint32 abcd.lo0 /\ hash.[ 1 ] == to_uint32 abcd.lo1 /\
hash.[ 2 ] == to_uint32 abcd.hi2 /\ hash.[ 3 ] == to_uint32 abcd.hi3 /\
hash.[ 4 ] == to_uint32 efgh.lo0 /\ hash.[ 5 ] == to_uint32 efgh.lo1 /\
hash.[ 6 ] == to_uint32 efgh.hi2 /\ hash.[ 7 ] == to_uint32 efgh.hi3 })
let make_ordered_hash_def (abcd efgh: quad32)
: (hash:
words_state SHA2_256
{ length hash == 8 /\ hash.[ 0 ] == to_uint32 abcd.lo0 /\ hash.[ 1 ] == to_uint32 abcd.lo1 /\
hash.[ 2 ] == to_uint32 abcd.hi2 /\ hash.[ 3 ] == to_uint32 abcd.hi3 /\
hash.[ 4 ] == to_uint32 efgh.lo0 /\ hash.[ 5 ] == to_uint32 efgh.lo1 /\
hash.[ 6 ] == to_uint32 efgh.hi2 /\ hash.[ 7 ] == to_uint32 efgh.hi3 }) = | false | null | false | let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"total"
] | [
"Vale.Def.Types_s.quad32",
"Prims.unit",
"FStar.Seq.Properties.elim_of_list",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.SHA2_256",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"FStar.Seq.Base.seq",
"Prims.b2t",
"Prims.op_Equality",
"Prims.nat",
"FStar.List.Tot.Base.length",
"FStar.Seq.Properties.seq_of_list",
"Prims.list",
"Prims.Cons",
"Prims.Nil",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.SEC",
"Vale.SHA.SHA_helpers.to_uint32",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Vale.Def.Types_s.nat32",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0",
"Spec.Hash.Definitions.words_state",
"Prims.l_and",
"FStar.UInt32.t",
"Spec.SHA2.op_String_Access"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3 | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val make_ordered_hash_def (abcd efgh: quad32)
: (hash:
words_state SHA2_256
{ length hash == 8 /\ hash.[ 0 ] == to_uint32 abcd.lo0 /\ hash.[ 1 ] == to_uint32 abcd.lo1 /\
hash.[ 2 ] == to_uint32 abcd.hi2 /\ hash.[ 3 ] == to_uint32 abcd.hi3 /\
hash.[ 4 ] == to_uint32 efgh.lo0 /\ hash.[ 5 ] == to_uint32 efgh.lo1 /\
hash.[ 6 ] == to_uint32 efgh.hi2 /\ hash.[ 7 ] == to_uint32 efgh.hi3 }) | [] | Vale.SHA.SHA_helpers.make_ordered_hash_def | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | abcd: Vale.Def.Types_s.quad32 -> efgh: Vale.Def.Types_s.quad32
-> hash:
Spec.Hash.Definitions.words_state Spec.Hash.Definitions.SHA2_256
{ FStar.Seq.Base.length hash == 8 /\
hash.[ 0 ] == Vale.SHA.SHA_helpers.to_uint32 (Mkfour?.lo0 abcd) /\
hash.[ 1 ] == Vale.SHA.SHA_helpers.to_uint32 (Mkfour?.lo1 abcd) /\
hash.[ 2 ] == Vale.SHA.SHA_helpers.to_uint32 (Mkfour?.hi2 abcd) /\
hash.[ 3 ] == Vale.SHA.SHA_helpers.to_uint32 (Mkfour?.hi3 abcd) /\
hash.[ 4 ] == Vale.SHA.SHA_helpers.to_uint32 (Mkfour?.lo0 efgh) /\
hash.[ 5 ] == Vale.SHA.SHA_helpers.to_uint32 (Mkfour?.lo1 efgh) /\
hash.[ 6 ] == Vale.SHA.SHA_helpers.to_uint32 (Mkfour?.hi2 efgh) /\
hash.[ 7 ] == Vale.SHA.SHA_helpers.to_uint32 (Mkfour?.hi3 efgh) } | {
"end_col": 8,
"end_line": 114,
"start_col": 3,
"start_line": 101
} |
FStar.Pervasives.Lemma | val lemma_add_mod_associates_U32 (x y z: UInt32.t)
: Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z) | val lemma_add_mod_associates_U32 (x y z: UInt32.t)
: Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
let lemma_add_mod_associates_U32 (x y z: UInt32.t)
: Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z) = | false | null | true | let open Lib.IntTypes in
calc ( == ) {
v (x +. (y +. z));
( == ) { () }
(v x + (v y + v z) % pow2 32) % pow2 32;
( == ) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
( == ) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
( == ) { () }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z) | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"FStar.UInt32.t",
"FStar.UInt32.v_inj",
"Lib.IntTypes.op_Plus_Dot",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.unit",
"FStar.Calc.calc_finish",
"Lib.IntTypes.range_t",
"Prims.eq2",
"Lib.IntTypes.v",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"FStar.Calc.calc_step",
"Prims.op_Modulus",
"Prims.op_Addition",
"Prims.pow2",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Prims.squash",
"FStar.Math.Lemmas.lemma_mod_add_distr",
"Prims.l_True",
"FStar.UInt32.add_mod",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z) | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val lemma_add_mod_associates_U32 (x y z: UInt32.t)
: Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z) | [] | Vale.SHA.SHA_helpers.lemma_add_mod_associates_U32 | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: FStar.UInt32.t -> y: FStar.UInt32.t -> z: FStar.UInt32.t
-> FStar.Pervasives.Lemma
(ensures
FStar.UInt32.add_mod x (FStar.UInt32.add_mod y z) ==
FStar.UInt32.add_mod (FStar.UInt32.add_mod x y) z) | {
"end_col": 39,
"end_line": 202,
"start_col": 2,
"start_line": 190
} |
FStar.Pervasives.Lemma | val lemma_le_bytes_to_hash_quads (s: seq quad32)
: Lemma (requires length s == 2)
(ensures
(let rhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
rhs.[ 0 ] == to_uint32 (s.[ 0 ]).lo0 /\ rhs.[ 1 ] == to_uint32 (s.[ 0 ]).lo1 /\
rhs.[ 2 ] == to_uint32 (s.[ 0 ]).hi2 /\ rhs.[ 3 ] == to_uint32 (s.[ 0 ]).hi3 /\
rhs.[ 4 ] == to_uint32 (s.[ 1 ]).lo0 /\ rhs.[ 5 ] == to_uint32 (s.[ 1 ]).lo1 /\
rhs.[ 6 ] == to_uint32 (s.[ 1 ]).hi2 /\ rhs.[ 7 ] == to_uint32 (s.[ 1 ]).hi3 /\
length rhs == 8)) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_le_bytes_to_hash_quads (s:seq quad32) : Lemma
(requires length s == 2)
(ensures (let rhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
rhs.[0] == to_uint32 (s.[0]).lo0 /\
rhs.[1] == to_uint32 (s.[0]).lo1 /\
rhs.[2] == to_uint32 (s.[0]).hi2 /\
rhs.[3] == to_uint32 (s.[0]).hi3 /\
rhs.[4] == to_uint32 (s.[1]).lo0 /\
rhs.[5] == to_uint32 (s.[1]).lo1 /\
rhs.[6] == to_uint32 (s.[1]).hi2 /\
rhs.[7] == to_uint32 (s.[1]).hi3 /\
length rhs == 8))
=
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32);
let rhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
lemma_le_bytes_to_hash_quads_part1 s;
assert (rhs == Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s));
() | val lemma_le_bytes_to_hash_quads (s: seq quad32)
: Lemma (requires length s == 2)
(ensures
(let rhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
rhs.[ 0 ] == to_uint32 (s.[ 0 ]).lo0 /\ rhs.[ 1 ] == to_uint32 (s.[ 0 ]).lo1 /\
rhs.[ 2 ] == to_uint32 (s.[ 0 ]).hi2 /\ rhs.[ 3 ] == to_uint32 (s.[ 0 ]).hi3 /\
rhs.[ 4 ] == to_uint32 (s.[ 1 ]).lo0 /\ rhs.[ 5 ] == to_uint32 (s.[ 1 ]).lo1 /\
rhs.[ 6 ] == to_uint32 (s.[ 1 ]).hi2 /\ rhs.[ 7 ] == to_uint32 (s.[ 1 ]).hi3 /\
length rhs == 8))
let lemma_le_bytes_to_hash_quads (s: seq quad32)
: Lemma (requires length s == 2)
(ensures
(let rhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
rhs.[ 0 ] == to_uint32 (s.[ 0 ]).lo0 /\ rhs.[ 1 ] == to_uint32 (s.[ 0 ]).lo1 /\
rhs.[ 2 ] == to_uint32 (s.[ 0 ]).hi2 /\ rhs.[ 3 ] == to_uint32 (s.[ 0 ]).hi3 /\
rhs.[ 4 ] == to_uint32 (s.[ 1 ]).lo0 /\ rhs.[ 5 ] == to_uint32 (s.[ 1 ]).lo1 /\
rhs.[ 6 ] == to_uint32 (s.[ 1 ]).hi2 /\ rhs.[ 7 ] == to_uint32 (s.[ 1 ]).hi3 /\
length rhs == 8)) = | false | null | true | reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32);
let rhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
lemma_le_bytes_to_hash_quads_part1 s;
assert (rhs == Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s));
() | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.quad32",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Vale.SHA.SHA_helpers.word",
"Vale.Lib.Seqs_s.seq_map",
"Vale.Def.Types_s.nat32",
"Vale.SHA.SHA_helpers.nat32_to_word",
"Vale.Def.Words.Seq_s.seq_four_to_seq_LE",
"Vale.SHA.SHA_helpers.lemma_le_bytes_to_hash_quads_part1",
"Vale.SHA.SHA_helpers.hash256",
"Vale.SHA.SHA_helpers.le_bytes_to_hash",
"Vale.Def.Types_s.le_seq_quad32_to_bytes",
"FStar.Pervasives.reveal_opaque",
"Vale.Def.Words_s.four",
"Vale.Def.Words_s.nat32",
"Prims.int",
"FStar.Seq.Base.length",
"FStar.Mul.op_Star",
"Prims.squash",
"Prims.l_and",
"Lib.IntTypes.uint32",
"Spec.SHA2.op_String_Access",
"Vale.SHA.SHA_helpers.to_uint32",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
// Top-level proof for the SHA256_msg1 instruction
let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
=
sha256_msg1_spec_reveal ();
let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
let ws_computed (b:block_w) (t:counter{t < size_k_w_256}): Tot (UInt32.t) =
if t < block_word_length SHA2_256 then to_uint32 (ws_opaque b t)
else
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
let open Lib.IntTypes in
(t16 +. s0 +. t7 +. s1)
#push-options "--max_fuel 1"
let lemma_ws_computed_is_ws (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (ws_computed b t == ws SHA2_256 b t)
=
Pervasives.reveal_opaque (`%ws) ws;
if t < block_word_length SHA2_256 then (
assert (vv (ws_computed b t) == ws_opaque b t);
assert (to_uint32 (ws_opaque b t) == ws SHA2_256 b t);
()
) else (
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
lemma_add_mod_ws_rearrangement s1 t7 s0 t16;
()
)
#pop-options
let lemma_ws_computed_is_ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (vv (ws_computed b t) == ws_opaque b t)
=
lemma_ws_computed_is_ws b t;
Pervasives.reveal_opaque (`%ws) ws;
()
let ws_computed_quad32 (t:counter{t < size_k_w_256 - 3}) (block:block_w) : quad32 =
Mkfour (vv (ws_computed block t))
(vv (ws_computed block (t+1)))
(vv (ws_computed block (t+2)))
(vv (ws_computed block (t+3)))
let lemma_ws_computed_is_ws_quad32 (b:block_w) (t:counter{t < size_k_w_256 - 3}) :
Lemma (ws_computed_quad32 t b == ws_quad32 t b)
=
let w = ws_computed_quad32 t b in
let w' = ws_quad32 t b in
lemma_ws_computed_is_ws_opaque b t;
lemma_ws_computed_is_ws_opaque b (t+1);
lemma_ws_computed_is_ws_opaque b (t+2);
lemma_ws_computed_is_ws_opaque b (t+3);
()
#push-options "--z3rlimit 30"
let lemma_ws_computed_quad32 (t:counter{16 <= t /\ t < size_k_w_256 - 4}) (block:block_w) :
Lemma (let t_minus_16 = ws_quad32 (t-16) block in
let t_minus_15 = ws_quad32 (t-15) block in
let t_minus_7 = ws_quad32 (t - 7) block in
let t_minus_2 = ws_quad32 (t - 2) block in
let m1 = add_mod_quad32 t_minus_16 (_sigma0_quad32 t_minus_15) in
let m2 = add_mod_quad32 m1 t_minus_7 in
let m3 = add_mod_quad32 m2 (_sigma1_quad32 t_minus_2) in
m3 == ws_computed_quad32 t block )
=
()
#pop-options
let sha256_msg1_spec_t (t:counter{t < size_k_w_256 - 1}) (block:block_w) : quad32 =
let init = ws_quad32 t block in
let next = ws_quad32 (t + 1) block in
let msg1 = add_mod_quad32 init (_sigma0_quad32 next) in
msg1
#push-options "--ifuel 1"
let lemma_sha256_msg1_spec_t_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 - 3)
(ensures ws_partial t block == sha256_msg1_spec_t (t-16) block)
=
ws_partial_reveal ();
let init = ws_quad32 (t-16) block in
let next = ws_quad32 (t-15) block in
lemma_add_wrap_quad32_is_add_mod_quad32 init (_sigma0_quad32 next);
()
#pop-options
let lemma_sha256_msg1_spec_t (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w_256 - 4 /\
src1 == ws_quad32 t block /\
src2.lo0 == ws_opaque block (t+4))
(ensures sha256_msg1_spec_t t block == sha256_msg1_spec src1 src2)
=
sha256_msg1_spec_reveal ();
()
#push-options "--z3rlimit 70"
let lemma_sha256_step2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1) /\
(let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
src1 == add_mod_quad32 w mid))
(ensures sha256_msg2_spec src1 src2 == ws_computed_quad32 t block)
=
sha256_msg2_spec_reveal ();
let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
let final = sha256_msg2_spec src1 src2 in
lemma_ws_computed_is_ws_opaque block (t);
lemma_ws_computed_is_ws_opaque block (t+1);
()
#pop-options
// Top-level proof for the SHA256_msg2 instruction
let lemma_sha256_msg2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
(let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
src1 == add_wrap_quad32 step1 t_minus_7 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1)))
(ensures sha256_msg2_spec src1 src2 == ws_quad32 t block)
=
let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
lemma_sha256_msg1_spec_t_partial t block;
// ==> step1 == sha256_msg1_spec_t (t-16) block
lemma_add_wrap_quad32_is_add_mod_quad32 step1 t_minus_7;
lemma_sha256_step2 src1 src2 t block;
lemma_ws_computed_is_ws_quad32 block t;
()
(* Abbreviations and lemmas for the code itself *)
#reset-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block qs
=
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32);
reveal_opaque (`%ws) ws
#reset-options "--max_fuel 0 --max_ifuel 0"
let translate_hash_update (h0 h1 h0' h1' a0 a1:quad32) : Lemma
(requires h0' == add_wrap_quad32 a0 h0 /\
h1' == add_wrap_quad32 a1 h1)
(ensures (
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
mapped == h'))
=
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
assert (equal mapped h');
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_lemma (src1 src2 src1' src2' h0 h1:quad32) (block:block_w) : Lemma
(requires (let hash_orig = make_hash h0 h1 in
make_hash src1 src2 ==
Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash_orig /\
src1' == add_wrap_quad32 src1 h0 /\
src2' == add_wrap_quad32 src2 h1))
(ensures (let hash_orig = make_hash h0 h1 in
make_hash src1' src2' == update_block hash_orig block))
=
let hash_orig = make_hash h0 h1 in
let hash_1 = shuffle_opaque SHA2_256 hash_orig block in
Pervasives.reveal_opaque (`%shuffle) shuffle;
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let rec f (i:nat{i <= 64}) : Lemma (
Spec.Loops.repeat_range 0 i (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 i (shuffle_core SHA2_256 block) hash_orig)
=
if i = 0 then (
Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_base 0 (shuffle_core SHA2_256 block) hash_orig
) else (
f (i - 1);
Spec.Loops.repeat_range_induction 0 i (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_induction 0 i (shuffle_core SHA2_256 block) hash_orig
)
in
f 64;
(*
let h = make_hash src1 src2 in
assert (forall (block:block_w) (hash:hash256) . FStar.FunctionalExtensionality.feq (shuffle_core_opaque block hash) (shuffle_core_opaque_aux SHA2_256 block hash));
//assert (forall (block:block_w) . (shuffle_core_opaque block) == (shuffle_core_opaque_aux SHA2_256 block));
assert (shuffle_core_opaque == shuffle_core_opaque_aux SHA2_256);
assert (shuffle_core_opaque == shuffle_core SHA2_256);
assert (shuffle_core_opaque block == shuffle_core SHA2_256 block);
assert (Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 64 (shuffle_core SHA2_256 block) hash_orig);
assert (make_hash src1 src2 == shuffle SHA2_256 hash_orig block);
assert (make_hash src1 src2 == shuffle_opaque SHA2_256 hash_orig block);
*)
translate_hash_update src1 src2 src1' src2' h0 h1;
shuffle_is_shuffle_pre SHA2_256 hash_orig block;
assert (equal (make_hash src1' src2') (update_block hash_orig block));
()
let lemma_le_bytes_to_seq_quad32_empty (b:seq nat8) : Lemma
(requires b == empty)
(ensures le_bytes_to_seq_quad32 b == empty)
=
reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32;
assert (equal (le_bytes_to_seq_quad32 b) empty)
let lemma_le_bytes_to_seq_quad32_length (b:seq nat8) : Lemma
(requires length b % 16 == 0)
(ensures length (le_bytes_to_seq_quad32 b) == length b / 16)
=
reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32;
()
#push-options "--max_fuel 1" // Without this, F* refuses to do even one unfolding of recursive functions :(
let lemma_slice_commutes_reverse_bytes_nat32_quad32_seq (s:seq quad32) (pivot:nat) : Lemma
(requires pivot <= length s)
(ensures slice (reverse_bytes_nat32_quad32_seq s) 0 pivot == reverse_bytes_nat32_quad32_seq (slice s 0 pivot))
=
let rs = reverse_bytes_nat32_quad32_seq s in
let srs = slice (reverse_bytes_nat32_quad32_seq s) 0 pivot in
let ss = slice s 0 pivot in
let rss = reverse_bytes_nat32_quad32_seq ss in
if pivot = 0 then (
assert (equal ss empty);
assert (equal srs empty);
assert (equal empty (reverse_bytes_nat32_quad32_seq empty));
()
) else (
assert (equal srs rss)
)
// One level of expansion that we can use in places that can't use fuel
let lemma_update_multi_quads_unfold (s:seq quad32) (hash_orig:hash256) : Lemma
(requires length s >= 4)
(ensures (let prefix, qs = split s (length s - 4) in
let h_prefix = update_multi_quads prefix hash_orig in
let hash = update_block h_prefix (quads_to_block qs) in
update_multi_quads s hash_orig == hash))
=
()
let lemma_update_multi_quads_short (s:seq quad32) (hash_orig:hash256) : Lemma
(requires length s < 4)
(ensures update_multi_quads s hash_orig == hash_orig)
=
()
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
#pop-options
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 40"
let lemma_endian_relation (quads qs:seq quad32) (input2:seq UInt8.t) : Lemma
(requires length qs == 4 /\ length input2 == 64 /\
qs == reverse_bytes_nat32_quad32_seq quads /\
input2 == seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads))
(ensures quads_to_block qs == words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2)
=
let fi (i:nat{i < length (quads_to_block qs)}) : Lemma
((quads_to_block qs).[i] == (words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2).[i])
=
let open Vale.Def.Words.Four_s in
let open Vale.Lib.Seqs_s in
let ni = (seq_four_to_seq_LE quads).[i] in
let b = slice input2 (4 * i) (4 * i + 4) in
// FStar.Krml.Endianness.lemma_be_to_n_is_bounded b;
calc (==) {
b;
== {}
slice input2 (4 * i) (4 * i + 4);
== {}
slice (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) (4 * i) (4 * i + 4);
== {le_seq_quad32_to_bytes_reveal ()}
slice (seq_nat8_to_seq_uint8 (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE quads))) (4 * i) (4 * i + 4);
equal {}
seq_nat8_to_seq_uint8 (slice (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE quads)) (4 * i) (4 * i + 4));
== {}
seq_nat8_to_seq_uint8 (slice (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE quads))) (4 * i) (4 * i + 4));
== {slice_commutes_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE quads)) i (i + 1)}
seq_nat8_to_seq_uint8 (seq_four_to_seq_LE (slice (seq_map (nat_to_four 8) (seq_four_to_seq_LE quads)) i (i + 1)));
equal {reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat8)}
seq_nat8_to_seq_uint8 (four_to_seq_LE (nat_to_four 8 (seq_four_to_seq_LE quads).[i]));
};
let open Lib.IntTypes in
calc (==) {
(words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2).[i];
== { }
(Lib.ByteSequence.uints_from_bytes_be #U32 #SEC #(block_word_length SHA2_256) input2).[i];
== { Lib.ByteSequence.index_uints_from_bytes_be #U32 #SEC #(block_word_length SHA2_256) input2 i }
Lib.ByteSequence.uint_from_bytes_be (Lib.Sequence.sub #uint8 #64 input2 (i * 4) 4);
== { let open Lib.Sequence in
calc (==) {
sub #uint8 #64 input2 (i * 4) 4;
== { }
Seq.slice input2 (4 * i) (4 * i + 4);
}
}
Lib.ByteSequence.uint_from_bytes_be #U32 #SEC b;
== { calc (==) {
Lib.ByteSequence.nat_from_bytes_be #SEC b;
(==) { }
Lib.ByteSequence.nat_from_bytes_be #SEC (seq_nat8_to_seq_uint8 (four_to_seq_LE (nat_to_four 8 ni)));
(==) { lemma_be_to_n_4 (four_to_seq_LE (nat_to_four 8 ni)) }
be_bytes_to_nat32 (four_to_seq_LE (nat_to_four 8 ni));
};
v_inj (Lib.ByteSequence.uint_from_bytes_be #U32 #SEC b)
(u32 (be_bytes_to_nat32 (four_to_seq_LE (nat_to_four 8 ni))))
}
nat32_to_word (be_bytes_to_nat32 (four_to_seq_LE (nat_to_four 8 ni)));
== {}
nat32_to_word (be_bytes_to_nat32 (reverse_seq (nat32_to_be_bytes ni)));
== {reverse_bytes_nat32_reveal ()}
nat32_to_word (reverse_bytes_nat32 ni);
== {}
nat32_to_word (reverse_bytes_nat32 (seq_four_to_seq_LE quads).[i]);
== {reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32)}
nat32_to_word (seq_four_to_seq_LE qs).[i];
== {}
(quads_to_block qs).[i];
}
in
FStar.Classical.forall_intro fi;
assert (equal (quads_to_block qs) (words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2))
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
#reset-options "--max_fuel 0 --ifuel 1 --z3rlimit 20"
let rec lemma_update_multi_equiv_vale (hash hash':hash256) (quads:seq quad32) (r_quads:seq quad32)
(nat8s:seq nat8) (blocks:seq UInt8.t) :
Lemma (requires length quads % 4 == 0 /\
r_quads == reverse_bytes_nat32_quad32_seq quads /\
nat8s == le_seq_quad32_to_bytes quads /\
blocks == seq_nat8_to_seq_uint8 nat8s /\
hash' == update_multi_quads r_quads hash)
(ensures
length blocks % 64 == 0 /\
hash' == update_multi_opaque_vale hash blocks)
(decreases (length quads))
=
lemma_mod_transform quads;
assert (length blocks % 64 == 0);
update_multi_reveal ();
if length quads = 0 then begin
lemma_le_seq_quad32_to_bytes_length quads;
//assert (length nat8s == 0);
//assert (length r_quads == 0);
lemma_update_multi_quads_short r_quads hash;
//assert (hash' == hash);
//assert (length blocks == 0);
assert (equal blocks empty);
update_multi_zero SHA2_256 hash;
//assert (update_multi SHA2_256 hash blocks == hash);
()
end else begin
let num_blocks = (length quads) / 4 in
let bytes_pivot = (num_blocks - 1) * 64 in
// Use associativity of update_multi to rearrange recursion to better match update_multi_quads' recursion
let input1,input2 = Lib.UpdateMulti.split_block block_length blocks (bytes_pivot / 64) in
let h_bytes1 = update_multi SHA2_256 hash () input1 in
let h_bytes2 = update_multi SHA2_256 h_bytes1 () input2 in
update_multi_associative SHA2_256 hash input1 input2;
assert (input1 `Seq.append` input2 == blocks);
Seq.lemma_eq_intro h_bytes2 (update_multi SHA2_256 hash () blocks);
assert (h_bytes2 == update_multi SHA2_256 hash () blocks);
// Unfold update_multi_quads one level, so we can start matching parts up
let prefix, qs = split r_quads (length r_quads - 4) in
let h_prefix = update_multi_quads prefix hash in
let h_final = update_block h_prefix (quads_to_block qs) in
lemma_update_multi_quads_unfold r_quads hash;
// hash' == update_multi_quads r_quads hash == h_final
(*+ Goal: h_bytes_2 == h_final +*)
(* Step 1: Show that h_prefix == h_bytes1 *)
// Inductive hypothesis says that we roughly line up on input1
let r_prefix = reverse_bytes_nat32_quad32_seq prefix in
lemma_update_multi_equiv_vale hash h_prefix r_prefix prefix
(le_seq_quad32_to_bytes r_prefix)
(seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes r_prefix));
assert (h_prefix == update_multi SHA2_256 hash () (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes r_prefix)));
// To show that h_prefix == h_bytes1, we need to show that:
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes r_prefix) == input1
// calc {
// input1
// slice blocks 0 bytes_pivot
// slice ( (le_seq_quad32_to_bytes quads)) 0 bytes_pivot
assert (equal (slice (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) 0 bytes_pivot)
(seq_nat8_to_seq_uint8 (slice (le_seq_quad32_to_bytes quads) 0 bytes_pivot)));
// seq_nat8_to_seq_U8 (slice (le_seq_quad32_to_bytes quads) 0 bytes_pivot)
slice_commutes_le_seq_quad32_to_bytes0 quads (bytes_pivot / 16);
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads 0 (bytes_pivot / 16)))
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads 0 ((num_blocks - 1) * 4)))
assert (bytes_pivot / 16 == length quads - 4);
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads 0 (length quads - 4)))
//
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads 0 (length quads - 4)))))
assert (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq (slice quads 0 (length quads - 4))) == slice quads 0 (length quads - 4));
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq (slice quads 0 (length quads - 4)))))
Vale.Lib.Seqs.slice_seq_map_commute reverse_bytes_nat32_quad32 quads 0 (length quads - 4);
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (reverse_bytes_nat32_quad32_seq (slice (reverse_bytes_nat32_quad32_seq quads) 0 (length quads - 4)))
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes r_prefix)
// }
// assert (seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes r_prefix) == input1); // Conclusion of the calc
assert (Seq.equal h_prefix h_bytes1); // Conclusion of Step 1
// To invoke lemma_endian_relation below,
// we need to show (1):
// calc {
// qs
Vale.Lib.Seqs.slice_seq_map_commute reverse_bytes_nat32_quad32 quads (length quads - 4) (length quads);
// slice (reverse_bytes_nat32_quad32_seq quads) (length quads - 4) (length quads))
// reverse_bytes_nat32_quad32_seq (slice quads (length quads - 4) (length quads))
// }
// And (2):
// calc {
// input2
// slice blocks bytes_pivot (length blocks)
// slice (seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes quads)) bytes_pivot (length blocks)
// assert (equal (slice (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) bytes_pivot (length blocks))
// (seq_nat8_to_seq_uint8 (slice (le_seq_quad32_to_bytes quads) bytes_pivot (length blocks))));
// seq_nat8_to_seq_U8 (slice (le_seq_quad32_to_bytes quads) bytes_pivot (length blocks))
slice_commutes_le_seq_quad32_to_bytes quads (bytes_pivot/16) ((length blocks)/16);
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads bytes_pivot/16 (length blocks)/16)
//
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads (length quads - 4) (length quads))))
// }
//assert (input2 == seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads (length quads - 4) (length quads)))); // Conclusion of the calc
(* Step 2: Show that update_block SHA2_256 h_prefix (quads_to_block qs) == update_multi SHA2_256 h_bytes1 input2 *)
// calc {
// update_block SHA2_256 h_prefix (quads_to_block qs)
// { from Step 1 }
// update_block SHA2_256 h_bytes1 (quads_to_block qs)
//
assert (equal input2 (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (slice quads (length quads - 4) (length quads)))));
lemma_endian_relation (slice quads (length quads - 4) (length quads)) qs
input2; // ==> quads_to_block qs == words_of_bytes SHA2_256 block_word_length input2
// update_block SHA2_256 h_bytes1 (words_of_bytes SHA2_256 16 input2)
lemma_update_block_equiv h_bytes1 input2;
// update SHA2_256 h_bytes1 input2
update_multi_one h_bytes1 input2;
// update_multi SHA2_256 h_bytes1 input2
// }
//
// assert (update_block SHA2_256 h_prefix (quads_to_block qs) == update_multi SHA2_256 h_bytes1 input2); // Conclusion of calc
// assert (h_final == h_bytes2); // Conclusion of Goal
()
end
//
#push-options "--max_fuel 1" // Without this, F* refuses to do even one unfolding of update_multi_quads :(
let lemma_update_multi_quads (s:seq quad32) (hash_orig:hash256) (bound:nat) : Lemma
(requires bound + 4 <= length s)
(ensures (let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_nat32_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_nat32_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound+4) in
let input_BE = reverse_bytes_nat32_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block block_quads_BE) in
h == update_multi_quads input_BE hash_orig))
=
let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_nat32_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_nat32_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound+4) in
let input_BE = reverse_bytes_nat32_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block block_quads_BE) in
lemma_slice_commutes_reverse_bytes_nat32_quad32_seq s bound;
lemma_slice_commutes_reverse_bytes_nat32_quad32_seq s (bound + 4);
assert (prefix_BE == slice (reverse_bytes_nat32_quad32_seq s) 0 bound);
assert (input_BE == slice (reverse_bytes_nat32_quad32_seq s) 0 (bound + 4));
if bound = 0 then ()
else (
let prefix, qs = split input_BE (length input_BE - 4) in
assert (equal prefix prefix_BE);
assert (equal qs block_quads_BE);
()
)
#pop-options
let lemma_le_bytes_to_hash_quads_part1 (s:seq quad32) : Lemma
(requires length s == 2)
(ensures le_bytes_to_hash (le_seq_quad32_to_bytes s) ==
Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s))
=
let lhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
assert (lhs == Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)));
le_seq_quad32_to_bytes_reveal ();
Vale.Def.Words.Seq.seq_nat8_to_seq_nat32_to_seq_nat8_LE (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s);
()
//
#push-options "--z3rlimit 30"
let lemma_le_bytes_to_hash_quads (s:seq quad32) : Lemma
(requires length s == 2)
(ensures (let rhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
rhs.[0] == to_uint32 (s.[0]).lo0 /\
rhs.[1] == to_uint32 (s.[0]).lo1 /\
rhs.[2] == to_uint32 (s.[0]).hi2 /\
rhs.[3] == to_uint32 (s.[0]).hi3 /\
rhs.[4] == to_uint32 (s.[1]).lo0 /\
rhs.[5] == to_uint32 (s.[1]).lo1 /\
rhs.[6] == to_uint32 (s.[1]).hi2 /\
rhs.[7] == to_uint32 (s.[1]).hi3 /\
length rhs == 8)) | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": 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": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_le_bytes_to_hash_quads (s: seq quad32)
: Lemma (requires length s == 2)
(ensures
(let rhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
rhs.[ 0 ] == to_uint32 (s.[ 0 ]).lo0 /\ rhs.[ 1 ] == to_uint32 (s.[ 0 ]).lo1 /\
rhs.[ 2 ] == to_uint32 (s.[ 0 ]).hi2 /\ rhs.[ 3 ] == to_uint32 (s.[ 0 ]).hi3 /\
rhs.[ 4 ] == to_uint32 (s.[ 1 ]).lo0 /\ rhs.[ 5 ] == to_uint32 (s.[ 1 ]).lo1 /\
rhs.[ 6 ] == to_uint32 (s.[ 1 ]).hi2 /\ rhs.[ 7 ] == to_uint32 (s.[ 1 ]).hi3 /\
length rhs == 8)) | [] | Vale.SHA.SHA_helpers.lemma_le_bytes_to_hash_quads | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: FStar.Seq.Base.seq Vale.Def.Types_s.quad32
-> FStar.Pervasives.Lemma (requires FStar.Seq.Base.length s == 2)
(ensures
(let rhs =
Vale.SHA.SHA_helpers.le_bytes_to_hash (Vale.Def.Types_s.le_seq_quad32_to_bytes s)
in
rhs.[ 0 ] == Vale.SHA.SHA_helpers.to_uint32 (Mkfour?.lo0 s.[ 0 ]) /\
rhs.[ 1 ] == Vale.SHA.SHA_helpers.to_uint32 (Mkfour?.lo1 s.[ 0 ]) /\
rhs.[ 2 ] == Vale.SHA.SHA_helpers.to_uint32 (Mkfour?.hi2 s.[ 0 ]) /\
rhs.[ 3 ] == Vale.SHA.SHA_helpers.to_uint32 (Mkfour?.hi3 s.[ 0 ]) /\
rhs.[ 4 ] == Vale.SHA.SHA_helpers.to_uint32 (Mkfour?.lo0 s.[ 1 ]) /\
rhs.[ 5 ] == Vale.SHA.SHA_helpers.to_uint32 (Mkfour?.lo1 s.[ 1 ]) /\
rhs.[ 6 ] == Vale.SHA.SHA_helpers.to_uint32 (Mkfour?.hi2 s.[ 1 ]) /\
rhs.[ 7 ] == Vale.SHA.SHA_helpers.to_uint32 (Mkfour?.hi3 s.[ 1 ]) /\
FStar.Seq.Base.length rhs == 8)) | {
"end_col": 4,
"end_line": 1068,
"start_col": 2,
"start_line": 1064
} |
FStar.Pervasives.Lemma | val lemma_update_multi_quads (s:seq quad32) (hash_orig:hash256) (bound:nat) : Lemma
(requires bound + 4 <= length s)
(ensures (let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_nat32_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_nat32_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound+4) in
let input_BE = reverse_bytes_nat32_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block block_quads_BE) in
h == update_multi_quads input_BE hash_orig)) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_update_multi_quads (s:seq quad32) (hash_orig:hash256) (bound:nat) : Lemma
(requires bound + 4 <= length s)
(ensures (let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_nat32_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_nat32_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound+4) in
let input_BE = reverse_bytes_nat32_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block block_quads_BE) in
h == update_multi_quads input_BE hash_orig))
=
let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_nat32_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_nat32_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound+4) in
let input_BE = reverse_bytes_nat32_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block block_quads_BE) in
lemma_slice_commutes_reverse_bytes_nat32_quad32_seq s bound;
lemma_slice_commutes_reverse_bytes_nat32_quad32_seq s (bound + 4);
assert (prefix_BE == slice (reverse_bytes_nat32_quad32_seq s) 0 bound);
assert (input_BE == slice (reverse_bytes_nat32_quad32_seq s) 0 (bound + 4));
if bound = 0 then ()
else (
let prefix, qs = split input_BE (length input_BE - 4) in
assert (equal prefix prefix_BE);
assert (equal qs block_quads_BE);
()
) | val lemma_update_multi_quads (s:seq quad32) (hash_orig:hash256) (bound:nat) : Lemma
(requires bound + 4 <= length s)
(ensures (let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_nat32_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_nat32_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound+4) in
let input_BE = reverse_bytes_nat32_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block block_quads_BE) in
h == update_multi_quads input_BE hash_orig))
let lemma_update_multi_quads (s: seq quad32) (hash_orig: hash256) (bound: nat)
: Lemma (requires bound + 4 <= length s)
(ensures
(let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_nat32_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_nat32_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound + 4) in
let input_BE = reverse_bytes_nat32_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block block_quads_BE) in
h == update_multi_quads input_BE hash_orig)) = | false | null | true | let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_nat32_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_nat32_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound + 4) in
let input_BE = reverse_bytes_nat32_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block block_quads_BE) in
lemma_slice_commutes_reverse_bytes_nat32_quad32_seq s bound;
lemma_slice_commutes_reverse_bytes_nat32_quad32_seq s (bound + 4);
assert (prefix_BE == slice (reverse_bytes_nat32_quad32_seq s) 0 bound);
assert (input_BE == slice (reverse_bytes_nat32_quad32_seq s) 0 (bound + 4));
if bound = 0
then ()
else
(let prefix, qs = split input_BE (length input_BE - 4) in
assert (equal prefix prefix_BE);
assert (equal qs block_quads_BE);
()) | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.quad32",
"Vale.SHA.SHA_helpers.hash256",
"Prims.nat",
"Prims.op_Equality",
"Prims.int",
"Prims.bool",
"Prims.unit",
"Prims._assert",
"FStar.Seq.Base.equal",
"FStar.Pervasives.Native.tuple2",
"FStar.Seq.Properties.split",
"Prims.op_Subtraction",
"FStar.Seq.Base.length",
"Prims.eq2",
"FStar.Seq.Base.slice",
"Vale.Arch.Types.reverse_bytes_nat32_quad32_seq",
"Prims.op_Addition",
"Vale.SHA.SHA_helpers.lemma_slice_commutes_reverse_bytes_nat32_quad32_seq",
"Vale.SHA.SHA_helpers.update_block",
"Vale.SHA.SHA_helpers.quads_to_block",
"Vale.SHA.SHA_helpers.update_multi_quads",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
// Top-level proof for the SHA256_msg1 instruction
let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
=
sha256_msg1_spec_reveal ();
let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
let ws_computed (b:block_w) (t:counter{t < size_k_w_256}): Tot (UInt32.t) =
if t < block_word_length SHA2_256 then to_uint32 (ws_opaque b t)
else
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
let open Lib.IntTypes in
(t16 +. s0 +. t7 +. s1)
#push-options "--max_fuel 1"
let lemma_ws_computed_is_ws (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (ws_computed b t == ws SHA2_256 b t)
=
Pervasives.reveal_opaque (`%ws) ws;
if t < block_word_length SHA2_256 then (
assert (vv (ws_computed b t) == ws_opaque b t);
assert (to_uint32 (ws_opaque b t) == ws SHA2_256 b t);
()
) else (
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
lemma_add_mod_ws_rearrangement s1 t7 s0 t16;
()
)
#pop-options
let lemma_ws_computed_is_ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (vv (ws_computed b t) == ws_opaque b t)
=
lemma_ws_computed_is_ws b t;
Pervasives.reveal_opaque (`%ws) ws;
()
let ws_computed_quad32 (t:counter{t < size_k_w_256 - 3}) (block:block_w) : quad32 =
Mkfour (vv (ws_computed block t))
(vv (ws_computed block (t+1)))
(vv (ws_computed block (t+2)))
(vv (ws_computed block (t+3)))
let lemma_ws_computed_is_ws_quad32 (b:block_w) (t:counter{t < size_k_w_256 - 3}) :
Lemma (ws_computed_quad32 t b == ws_quad32 t b)
=
let w = ws_computed_quad32 t b in
let w' = ws_quad32 t b in
lemma_ws_computed_is_ws_opaque b t;
lemma_ws_computed_is_ws_opaque b (t+1);
lemma_ws_computed_is_ws_opaque b (t+2);
lemma_ws_computed_is_ws_opaque b (t+3);
()
#push-options "--z3rlimit 30"
let lemma_ws_computed_quad32 (t:counter{16 <= t /\ t < size_k_w_256 - 4}) (block:block_w) :
Lemma (let t_minus_16 = ws_quad32 (t-16) block in
let t_minus_15 = ws_quad32 (t-15) block in
let t_minus_7 = ws_quad32 (t - 7) block in
let t_minus_2 = ws_quad32 (t - 2) block in
let m1 = add_mod_quad32 t_minus_16 (_sigma0_quad32 t_minus_15) in
let m2 = add_mod_quad32 m1 t_minus_7 in
let m3 = add_mod_quad32 m2 (_sigma1_quad32 t_minus_2) in
m3 == ws_computed_quad32 t block )
=
()
#pop-options
let sha256_msg1_spec_t (t:counter{t < size_k_w_256 - 1}) (block:block_w) : quad32 =
let init = ws_quad32 t block in
let next = ws_quad32 (t + 1) block in
let msg1 = add_mod_quad32 init (_sigma0_quad32 next) in
msg1
#push-options "--ifuel 1"
let lemma_sha256_msg1_spec_t_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 - 3)
(ensures ws_partial t block == sha256_msg1_spec_t (t-16) block)
=
ws_partial_reveal ();
let init = ws_quad32 (t-16) block in
let next = ws_quad32 (t-15) block in
lemma_add_wrap_quad32_is_add_mod_quad32 init (_sigma0_quad32 next);
()
#pop-options
let lemma_sha256_msg1_spec_t (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w_256 - 4 /\
src1 == ws_quad32 t block /\
src2.lo0 == ws_opaque block (t+4))
(ensures sha256_msg1_spec_t t block == sha256_msg1_spec src1 src2)
=
sha256_msg1_spec_reveal ();
()
#push-options "--z3rlimit 70"
let lemma_sha256_step2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1) /\
(let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
src1 == add_mod_quad32 w mid))
(ensures sha256_msg2_spec src1 src2 == ws_computed_quad32 t block)
=
sha256_msg2_spec_reveal ();
let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
let final = sha256_msg2_spec src1 src2 in
lemma_ws_computed_is_ws_opaque block (t);
lemma_ws_computed_is_ws_opaque block (t+1);
()
#pop-options
// Top-level proof for the SHA256_msg2 instruction
let lemma_sha256_msg2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
(let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
src1 == add_wrap_quad32 step1 t_minus_7 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1)))
(ensures sha256_msg2_spec src1 src2 == ws_quad32 t block)
=
let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
lemma_sha256_msg1_spec_t_partial t block;
// ==> step1 == sha256_msg1_spec_t (t-16) block
lemma_add_wrap_quad32_is_add_mod_quad32 step1 t_minus_7;
lemma_sha256_step2 src1 src2 t block;
lemma_ws_computed_is_ws_quad32 block t;
()
(* Abbreviations and lemmas for the code itself *)
#reset-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block qs
=
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32);
reveal_opaque (`%ws) ws
#reset-options "--max_fuel 0 --max_ifuel 0"
let translate_hash_update (h0 h1 h0' h1' a0 a1:quad32) : Lemma
(requires h0' == add_wrap_quad32 a0 h0 /\
h1' == add_wrap_quad32 a1 h1)
(ensures (
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
mapped == h'))
=
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
assert (equal mapped h');
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_lemma (src1 src2 src1' src2' h0 h1:quad32) (block:block_w) : Lemma
(requires (let hash_orig = make_hash h0 h1 in
make_hash src1 src2 ==
Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash_orig /\
src1' == add_wrap_quad32 src1 h0 /\
src2' == add_wrap_quad32 src2 h1))
(ensures (let hash_orig = make_hash h0 h1 in
make_hash src1' src2' == update_block hash_orig block))
=
let hash_orig = make_hash h0 h1 in
let hash_1 = shuffle_opaque SHA2_256 hash_orig block in
Pervasives.reveal_opaque (`%shuffle) shuffle;
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let rec f (i:nat{i <= 64}) : Lemma (
Spec.Loops.repeat_range 0 i (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 i (shuffle_core SHA2_256 block) hash_orig)
=
if i = 0 then (
Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_base 0 (shuffle_core SHA2_256 block) hash_orig
) else (
f (i - 1);
Spec.Loops.repeat_range_induction 0 i (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_induction 0 i (shuffle_core SHA2_256 block) hash_orig
)
in
f 64;
(*
let h = make_hash src1 src2 in
assert (forall (block:block_w) (hash:hash256) . FStar.FunctionalExtensionality.feq (shuffle_core_opaque block hash) (shuffle_core_opaque_aux SHA2_256 block hash));
//assert (forall (block:block_w) . (shuffle_core_opaque block) == (shuffle_core_opaque_aux SHA2_256 block));
assert (shuffle_core_opaque == shuffle_core_opaque_aux SHA2_256);
assert (shuffle_core_opaque == shuffle_core SHA2_256);
assert (shuffle_core_opaque block == shuffle_core SHA2_256 block);
assert (Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 64 (shuffle_core SHA2_256 block) hash_orig);
assert (make_hash src1 src2 == shuffle SHA2_256 hash_orig block);
assert (make_hash src1 src2 == shuffle_opaque SHA2_256 hash_orig block);
*)
translate_hash_update src1 src2 src1' src2' h0 h1;
shuffle_is_shuffle_pre SHA2_256 hash_orig block;
assert (equal (make_hash src1' src2') (update_block hash_orig block));
()
let lemma_le_bytes_to_seq_quad32_empty (b:seq nat8) : Lemma
(requires b == empty)
(ensures le_bytes_to_seq_quad32 b == empty)
=
reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32;
assert (equal (le_bytes_to_seq_quad32 b) empty)
let lemma_le_bytes_to_seq_quad32_length (b:seq nat8) : Lemma
(requires length b % 16 == 0)
(ensures length (le_bytes_to_seq_quad32 b) == length b / 16)
=
reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32;
()
#push-options "--max_fuel 1" // Without this, F* refuses to do even one unfolding of recursive functions :(
let lemma_slice_commutes_reverse_bytes_nat32_quad32_seq (s:seq quad32) (pivot:nat) : Lemma
(requires pivot <= length s)
(ensures slice (reverse_bytes_nat32_quad32_seq s) 0 pivot == reverse_bytes_nat32_quad32_seq (slice s 0 pivot))
=
let rs = reverse_bytes_nat32_quad32_seq s in
let srs = slice (reverse_bytes_nat32_quad32_seq s) 0 pivot in
let ss = slice s 0 pivot in
let rss = reverse_bytes_nat32_quad32_seq ss in
if pivot = 0 then (
assert (equal ss empty);
assert (equal srs empty);
assert (equal empty (reverse_bytes_nat32_quad32_seq empty));
()
) else (
assert (equal srs rss)
)
// One level of expansion that we can use in places that can't use fuel
let lemma_update_multi_quads_unfold (s:seq quad32) (hash_orig:hash256) : Lemma
(requires length s >= 4)
(ensures (let prefix, qs = split s (length s - 4) in
let h_prefix = update_multi_quads prefix hash_orig in
let hash = update_block h_prefix (quads_to_block qs) in
update_multi_quads s hash_orig == hash))
=
()
let lemma_update_multi_quads_short (s:seq quad32) (hash_orig:hash256) : Lemma
(requires length s < 4)
(ensures update_multi_quads s hash_orig == hash_orig)
=
()
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
#pop-options
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 40"
let lemma_endian_relation (quads qs:seq quad32) (input2:seq UInt8.t) : Lemma
(requires length qs == 4 /\ length input2 == 64 /\
qs == reverse_bytes_nat32_quad32_seq quads /\
input2 == seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads))
(ensures quads_to_block qs == words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2)
=
let fi (i:nat{i < length (quads_to_block qs)}) : Lemma
((quads_to_block qs).[i] == (words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2).[i])
=
let open Vale.Def.Words.Four_s in
let open Vale.Lib.Seqs_s in
let ni = (seq_four_to_seq_LE quads).[i] in
let b = slice input2 (4 * i) (4 * i + 4) in
// FStar.Krml.Endianness.lemma_be_to_n_is_bounded b;
calc (==) {
b;
== {}
slice input2 (4 * i) (4 * i + 4);
== {}
slice (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) (4 * i) (4 * i + 4);
== {le_seq_quad32_to_bytes_reveal ()}
slice (seq_nat8_to_seq_uint8 (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE quads))) (4 * i) (4 * i + 4);
equal {}
seq_nat8_to_seq_uint8 (slice (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE quads)) (4 * i) (4 * i + 4));
== {}
seq_nat8_to_seq_uint8 (slice (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE quads))) (4 * i) (4 * i + 4));
== {slice_commutes_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE quads)) i (i + 1)}
seq_nat8_to_seq_uint8 (seq_four_to_seq_LE (slice (seq_map (nat_to_four 8) (seq_four_to_seq_LE quads)) i (i + 1)));
equal {reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat8)}
seq_nat8_to_seq_uint8 (four_to_seq_LE (nat_to_four 8 (seq_four_to_seq_LE quads).[i]));
};
let open Lib.IntTypes in
calc (==) {
(words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2).[i];
== { }
(Lib.ByteSequence.uints_from_bytes_be #U32 #SEC #(block_word_length SHA2_256) input2).[i];
== { Lib.ByteSequence.index_uints_from_bytes_be #U32 #SEC #(block_word_length SHA2_256) input2 i }
Lib.ByteSequence.uint_from_bytes_be (Lib.Sequence.sub #uint8 #64 input2 (i * 4) 4);
== { let open Lib.Sequence in
calc (==) {
sub #uint8 #64 input2 (i * 4) 4;
== { }
Seq.slice input2 (4 * i) (4 * i + 4);
}
}
Lib.ByteSequence.uint_from_bytes_be #U32 #SEC b;
== { calc (==) {
Lib.ByteSequence.nat_from_bytes_be #SEC b;
(==) { }
Lib.ByteSequence.nat_from_bytes_be #SEC (seq_nat8_to_seq_uint8 (four_to_seq_LE (nat_to_four 8 ni)));
(==) { lemma_be_to_n_4 (four_to_seq_LE (nat_to_four 8 ni)) }
be_bytes_to_nat32 (four_to_seq_LE (nat_to_four 8 ni));
};
v_inj (Lib.ByteSequence.uint_from_bytes_be #U32 #SEC b)
(u32 (be_bytes_to_nat32 (four_to_seq_LE (nat_to_four 8 ni))))
}
nat32_to_word (be_bytes_to_nat32 (four_to_seq_LE (nat_to_four 8 ni)));
== {}
nat32_to_word (be_bytes_to_nat32 (reverse_seq (nat32_to_be_bytes ni)));
== {reverse_bytes_nat32_reveal ()}
nat32_to_word (reverse_bytes_nat32 ni);
== {}
nat32_to_word (reverse_bytes_nat32 (seq_four_to_seq_LE quads).[i]);
== {reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32)}
nat32_to_word (seq_four_to_seq_LE qs).[i];
== {}
(quads_to_block qs).[i];
}
in
FStar.Classical.forall_intro fi;
assert (equal (quads_to_block qs) (words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2))
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
#reset-options "--max_fuel 0 --ifuel 1 --z3rlimit 20"
let rec lemma_update_multi_equiv_vale (hash hash':hash256) (quads:seq quad32) (r_quads:seq quad32)
(nat8s:seq nat8) (blocks:seq UInt8.t) :
Lemma (requires length quads % 4 == 0 /\
r_quads == reverse_bytes_nat32_quad32_seq quads /\
nat8s == le_seq_quad32_to_bytes quads /\
blocks == seq_nat8_to_seq_uint8 nat8s /\
hash' == update_multi_quads r_quads hash)
(ensures
length blocks % 64 == 0 /\
hash' == update_multi_opaque_vale hash blocks)
(decreases (length quads))
=
lemma_mod_transform quads;
assert (length blocks % 64 == 0);
update_multi_reveal ();
if length quads = 0 then begin
lemma_le_seq_quad32_to_bytes_length quads;
//assert (length nat8s == 0);
//assert (length r_quads == 0);
lemma_update_multi_quads_short r_quads hash;
//assert (hash' == hash);
//assert (length blocks == 0);
assert (equal blocks empty);
update_multi_zero SHA2_256 hash;
//assert (update_multi SHA2_256 hash blocks == hash);
()
end else begin
let num_blocks = (length quads) / 4 in
let bytes_pivot = (num_blocks - 1) * 64 in
// Use associativity of update_multi to rearrange recursion to better match update_multi_quads' recursion
let input1,input2 = Lib.UpdateMulti.split_block block_length blocks (bytes_pivot / 64) in
let h_bytes1 = update_multi SHA2_256 hash () input1 in
let h_bytes2 = update_multi SHA2_256 h_bytes1 () input2 in
update_multi_associative SHA2_256 hash input1 input2;
assert (input1 `Seq.append` input2 == blocks);
Seq.lemma_eq_intro h_bytes2 (update_multi SHA2_256 hash () blocks);
assert (h_bytes2 == update_multi SHA2_256 hash () blocks);
// Unfold update_multi_quads one level, so we can start matching parts up
let prefix, qs = split r_quads (length r_quads - 4) in
let h_prefix = update_multi_quads prefix hash in
let h_final = update_block h_prefix (quads_to_block qs) in
lemma_update_multi_quads_unfold r_quads hash;
// hash' == update_multi_quads r_quads hash == h_final
(*+ Goal: h_bytes_2 == h_final +*)
(* Step 1: Show that h_prefix == h_bytes1 *)
// Inductive hypothesis says that we roughly line up on input1
let r_prefix = reverse_bytes_nat32_quad32_seq prefix in
lemma_update_multi_equiv_vale hash h_prefix r_prefix prefix
(le_seq_quad32_to_bytes r_prefix)
(seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes r_prefix));
assert (h_prefix == update_multi SHA2_256 hash () (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes r_prefix)));
// To show that h_prefix == h_bytes1, we need to show that:
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes r_prefix) == input1
// calc {
// input1
// slice blocks 0 bytes_pivot
// slice ( (le_seq_quad32_to_bytes quads)) 0 bytes_pivot
assert (equal (slice (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) 0 bytes_pivot)
(seq_nat8_to_seq_uint8 (slice (le_seq_quad32_to_bytes quads) 0 bytes_pivot)));
// seq_nat8_to_seq_U8 (slice (le_seq_quad32_to_bytes quads) 0 bytes_pivot)
slice_commutes_le_seq_quad32_to_bytes0 quads (bytes_pivot / 16);
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads 0 (bytes_pivot / 16)))
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads 0 ((num_blocks - 1) * 4)))
assert (bytes_pivot / 16 == length quads - 4);
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads 0 (length quads - 4)))
//
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads 0 (length quads - 4)))))
assert (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq (slice quads 0 (length quads - 4))) == slice quads 0 (length quads - 4));
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq (slice quads 0 (length quads - 4)))))
Vale.Lib.Seqs.slice_seq_map_commute reverse_bytes_nat32_quad32 quads 0 (length quads - 4);
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (reverse_bytes_nat32_quad32_seq (slice (reverse_bytes_nat32_quad32_seq quads) 0 (length quads - 4)))
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes r_prefix)
// }
// assert (seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes r_prefix) == input1); // Conclusion of the calc
assert (Seq.equal h_prefix h_bytes1); // Conclusion of Step 1
// To invoke lemma_endian_relation below,
// we need to show (1):
// calc {
// qs
Vale.Lib.Seqs.slice_seq_map_commute reverse_bytes_nat32_quad32 quads (length quads - 4) (length quads);
// slice (reverse_bytes_nat32_quad32_seq quads) (length quads - 4) (length quads))
// reverse_bytes_nat32_quad32_seq (slice quads (length quads - 4) (length quads))
// }
// And (2):
// calc {
// input2
// slice blocks bytes_pivot (length blocks)
// slice (seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes quads)) bytes_pivot (length blocks)
// assert (equal (slice (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) bytes_pivot (length blocks))
// (seq_nat8_to_seq_uint8 (slice (le_seq_quad32_to_bytes quads) bytes_pivot (length blocks))));
// seq_nat8_to_seq_U8 (slice (le_seq_quad32_to_bytes quads) bytes_pivot (length blocks))
slice_commutes_le_seq_quad32_to_bytes quads (bytes_pivot/16) ((length blocks)/16);
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads bytes_pivot/16 (length blocks)/16)
//
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads (length quads - 4) (length quads))))
// }
//assert (input2 == seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads (length quads - 4) (length quads)))); // Conclusion of the calc
(* Step 2: Show that update_block SHA2_256 h_prefix (quads_to_block qs) == update_multi SHA2_256 h_bytes1 input2 *)
// calc {
// update_block SHA2_256 h_prefix (quads_to_block qs)
// { from Step 1 }
// update_block SHA2_256 h_bytes1 (quads_to_block qs)
//
assert (equal input2 (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (slice quads (length quads - 4) (length quads)))));
lemma_endian_relation (slice quads (length quads - 4) (length quads)) qs
input2; // ==> quads_to_block qs == words_of_bytes SHA2_256 block_word_length input2
// update_block SHA2_256 h_bytes1 (words_of_bytes SHA2_256 16 input2)
lemma_update_block_equiv h_bytes1 input2;
// update SHA2_256 h_bytes1 input2
update_multi_one h_bytes1 input2;
// update_multi SHA2_256 h_bytes1 input2
// }
//
// assert (update_block SHA2_256 h_prefix (quads_to_block qs) == update_multi SHA2_256 h_bytes1 input2); // Conclusion of calc
// assert (h_final == h_bytes2); // Conclusion of Goal
()
end
//
#push-options "--max_fuel 1" // Without this, F* refuses to do even one unfolding of update_multi_quads :(
let lemma_update_multi_quads (s:seq quad32) (hash_orig:hash256) (bound:nat) : Lemma
(requires bound + 4 <= length s)
(ensures (let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_nat32_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_nat32_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound+4) in
let input_BE = reverse_bytes_nat32_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block block_quads_BE) in | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": 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"
} | null | val lemma_update_multi_quads (s:seq quad32) (hash_orig:hash256) (bound:nat) : Lemma
(requires bound + 4 <= length s)
(ensures (let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_nat32_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_nat32_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound+4) in
let input_BE = reverse_bytes_nat32_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block block_quads_BE) in
h == update_multi_quads input_BE hash_orig)) | [] | Vale.SHA.SHA_helpers.lemma_update_multi_quads | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
s: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
hash_orig: Vale.SHA.SHA_helpers.hash256 ->
bound: Prims.nat
-> FStar.Pervasives.Lemma (requires bound + 4 <= FStar.Seq.Base.length s)
(ensures
(let prefix_LE = FStar.Seq.Base.slice s 0 bound in
let prefix_BE = Vale.Arch.Types.reverse_bytes_nat32_quad32_seq prefix_LE in
let h_prefix = Vale.SHA.SHA_helpers.update_multi_quads prefix_BE hash_orig in
let block_quads_LE = FStar.Seq.Base.slice s bound (bound + 4) in
let block_quads_BE = Vale.Arch.Types.reverse_bytes_nat32_quad32_seq block_quads_LE in
let input_LE = FStar.Seq.Base.slice s 0 (bound + 4) in
let input_BE = Vale.Arch.Types.reverse_bytes_nat32_quad32_seq input_LE in
let h =
Vale.SHA.SHA_helpers.update_block h_prefix
(Vale.SHA.SHA_helpers.quads_to_block block_quads_BE)
in
h == Vale.SHA.SHA_helpers.update_multi_quads input_BE hash_orig)) | {
"end_col": 3,
"end_line": 1035,
"start_col": 3,
"start_line": 1016
} |
FStar.Pervasives.Lemma | val lemma_quads_to_block (qs:seq quad32) : Lemma
(requires length qs == 4)
(ensures
(let block = quads_to_block qs in
forall i . {:pattern (index qs i)} 0 <= i /\ i < 4 ==>
(qs.[i]).lo0 == ws_opaque block (4 * i + 0) /\
(qs.[i]).lo1 == ws_opaque block (4 * i + 1) /\
(qs.[i]).hi2 == ws_opaque block (4 * i + 2) /\
(qs.[i]).hi3 == ws_opaque block (4 * i + 3) /\
qs.[i] == ws_quad32 (4 * i) block)) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_quads_to_block qs
=
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32);
reveal_opaque (`%ws) ws | val lemma_quads_to_block (qs:seq quad32) : Lemma
(requires length qs == 4)
(ensures
(let block = quads_to_block qs in
forall i . {:pattern (index qs i)} 0 <= i /\ i < 4 ==>
(qs.[i]).lo0 == ws_opaque block (4 * i + 0) /\
(qs.[i]).lo1 == ws_opaque block (4 * i + 1) /\
(qs.[i]).hi2 == ws_opaque block (4 * i + 2) /\
(qs.[i]).hi3 == ws_opaque block (4 * i + 3) /\
qs.[i] == ws_quad32 (4 * i) block))
let lemma_quads_to_block qs = | false | null | true | reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32);
reveal_opaque (`%ws) ws | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.quad32",
"FStar.Pervasives.reveal_opaque",
"Spec.Hash.Definitions.sha2_alg",
"Spec.SHA2.block_w",
"Spec.SHA2.counter",
"Prims.b2t",
"Prims.op_LessThan",
"Spec.SHA2.size_k_w",
"Spec.Hash.Definitions.word",
"Spec.SHA2.Lemmas.ws",
"Prims.unit",
"Vale.Def.Words_s.four",
"Vale.Def.Words_s.nat32",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"FStar.Mul.op_Star",
"Vale.Def.Words.Seq_s.seq_four_to_seq_LE"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
// Top-level proof for the SHA256_msg1 instruction
let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
=
sha256_msg1_spec_reveal ();
let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
let ws_computed (b:block_w) (t:counter{t < size_k_w_256}): Tot (UInt32.t) =
if t < block_word_length SHA2_256 then to_uint32 (ws_opaque b t)
else
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
let open Lib.IntTypes in
(t16 +. s0 +. t7 +. s1)
#push-options "--max_fuel 1"
let lemma_ws_computed_is_ws (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (ws_computed b t == ws SHA2_256 b t)
=
Pervasives.reveal_opaque (`%ws) ws;
if t < block_word_length SHA2_256 then (
assert (vv (ws_computed b t) == ws_opaque b t);
assert (to_uint32 (ws_opaque b t) == ws SHA2_256 b t);
()
) else (
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
lemma_add_mod_ws_rearrangement s1 t7 s0 t16;
()
)
#pop-options
let lemma_ws_computed_is_ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (vv (ws_computed b t) == ws_opaque b t)
=
lemma_ws_computed_is_ws b t;
Pervasives.reveal_opaque (`%ws) ws;
()
let ws_computed_quad32 (t:counter{t < size_k_w_256 - 3}) (block:block_w) : quad32 =
Mkfour (vv (ws_computed block t))
(vv (ws_computed block (t+1)))
(vv (ws_computed block (t+2)))
(vv (ws_computed block (t+3)))
let lemma_ws_computed_is_ws_quad32 (b:block_w) (t:counter{t < size_k_w_256 - 3}) :
Lemma (ws_computed_quad32 t b == ws_quad32 t b)
=
let w = ws_computed_quad32 t b in
let w' = ws_quad32 t b in
lemma_ws_computed_is_ws_opaque b t;
lemma_ws_computed_is_ws_opaque b (t+1);
lemma_ws_computed_is_ws_opaque b (t+2);
lemma_ws_computed_is_ws_opaque b (t+3);
()
#push-options "--z3rlimit 30"
let lemma_ws_computed_quad32 (t:counter{16 <= t /\ t < size_k_w_256 - 4}) (block:block_w) :
Lemma (let t_minus_16 = ws_quad32 (t-16) block in
let t_minus_15 = ws_quad32 (t-15) block in
let t_minus_7 = ws_quad32 (t - 7) block in
let t_minus_2 = ws_quad32 (t - 2) block in
let m1 = add_mod_quad32 t_minus_16 (_sigma0_quad32 t_minus_15) in
let m2 = add_mod_quad32 m1 t_minus_7 in
let m3 = add_mod_quad32 m2 (_sigma1_quad32 t_minus_2) in
m3 == ws_computed_quad32 t block )
=
()
#pop-options
let sha256_msg1_spec_t (t:counter{t < size_k_w_256 - 1}) (block:block_w) : quad32 =
let init = ws_quad32 t block in
let next = ws_quad32 (t + 1) block in
let msg1 = add_mod_quad32 init (_sigma0_quad32 next) in
msg1
#push-options "--ifuel 1"
let lemma_sha256_msg1_spec_t_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 - 3)
(ensures ws_partial t block == sha256_msg1_spec_t (t-16) block)
=
ws_partial_reveal ();
let init = ws_quad32 (t-16) block in
let next = ws_quad32 (t-15) block in
lemma_add_wrap_quad32_is_add_mod_quad32 init (_sigma0_quad32 next);
()
#pop-options
let lemma_sha256_msg1_spec_t (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w_256 - 4 /\
src1 == ws_quad32 t block /\
src2.lo0 == ws_opaque block (t+4))
(ensures sha256_msg1_spec_t t block == sha256_msg1_spec src1 src2)
=
sha256_msg1_spec_reveal ();
()
#push-options "--z3rlimit 70"
let lemma_sha256_step2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1) /\
(let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
src1 == add_mod_quad32 w mid))
(ensures sha256_msg2_spec src1 src2 == ws_computed_quad32 t block)
=
sha256_msg2_spec_reveal ();
let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
let final = sha256_msg2_spec src1 src2 in
lemma_ws_computed_is_ws_opaque block (t);
lemma_ws_computed_is_ws_opaque block (t+1);
()
#pop-options
// Top-level proof for the SHA256_msg2 instruction
let lemma_sha256_msg2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
(let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
src1 == add_wrap_quad32 step1 t_minus_7 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1)))
(ensures sha256_msg2_spec src1 src2 == ws_quad32 t block)
=
let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
lemma_sha256_msg1_spec_t_partial t block;
// ==> step1 == sha256_msg1_spec_t (t-16) block
lemma_add_wrap_quad32_is_add_mod_quad32 step1 t_minus_7;
lemma_sha256_step2 src1 src2 t block;
lemma_ws_computed_is_ws_quad32 block t;
()
(* Abbreviations and lemmas for the code itself *)
#reset-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block qs | false | false | Vale.SHA.SHA_helpers.fst | {
"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"
} | null | val lemma_quads_to_block (qs:seq quad32) : Lemma
(requires length qs == 4)
(ensures
(let block = quads_to_block qs in
forall i . {:pattern (index qs i)} 0 <= i /\ i < 4 ==>
(qs.[i]).lo0 == ws_opaque block (4 * i + 0) /\
(qs.[i]).lo1 == ws_opaque block (4 * i + 1) /\
(qs.[i]).hi2 == ws_opaque block (4 * i + 2) /\
(qs.[i]).hi3 == ws_opaque block (4 * i + 3) /\
qs.[i] == ws_quad32 (4 * i) block)) | [] | Vale.SHA.SHA_helpers.lemma_quads_to_block | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | qs: FStar.Seq.Base.seq Vale.Def.Types_s.quad32
-> FStar.Pervasives.Lemma (requires FStar.Seq.Base.length qs == 4)
(ensures
(let block = Vale.SHA.SHA_helpers.quads_to_block qs in
forall (i:
Prims.int
{ i >= 0 /\ i < FStar.Seq.Base.length qs /\ (i >= 0) /\ (i < FStar.Seq.Base.length qs) /\
(i >= 0) /\ (i < FStar.Seq.Base.length qs) /\
(i >= 0) /\ (i < FStar.Seq.Base.length qs) /\
(i >= 0) /\ (i < FStar.Seq.Base.length qs) }).
{:pattern FStar.Seq.Base.index qs i}
0 <= i /\ i < 4 ==>
Mkfour?.lo0 qs.[ i ] == Vale.SHA.SHA_helpers.ws_opaque block (4 * i + 0) /\
Mkfour?.lo1 qs.[ i ] == Vale.SHA.SHA_helpers.ws_opaque block (4 * i + 1) /\
Mkfour?.hi2 qs.[ i ] == Vale.SHA.SHA_helpers.ws_opaque block (4 * i + 2) /\
Mkfour?.hi3 qs.[ i ] == Vale.SHA.SHA_helpers.ws_opaque block (4 * i + 3) /\
qs.[ i ] == Vale.SHA.SHA_helpers.ws_quad32 (4 * i) block)) | {
"end_col": 25,
"end_line": 624,
"start_col": 2,
"start_line": 623
} |
Prims.Pure | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let update_multi_opaque_aux = opaque_make update_multi | let update_multi_opaque_aux = | false | null | false | opaque_make update_multi | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [] | [
"Vale.Def.Opaque_s.opaque_make",
"Spec.Hash.Definitions.hash_alg",
"Spec.Hash.Definitions.words_state",
"Spec.Hash.Definitions.extra_state",
"Spec.Hash.Definitions.bytes_blocks",
"Prims.b2t",
"Spec.Agile.Hash.update_multi_pre",
"Prims.l_True",
"Spec.Agile.Hash.update_multi"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val update_multi_opaque_aux : a: Spec.Hash.Definitions.hash_alg ->
hash: Spec.Hash.Definitions.words_state a ->
prev: Spec.Hash.Definitions.extra_state a ->
blocks: Spec.Hash.Definitions.bytes_blocks a
-> Prims.Pure (Spec.Hash.Definitions.words_state a) | [] | Vale.SHA.SHA_helpers.update_multi_opaque_aux | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Hash.Definitions.hash_alg ->
hash: Spec.Hash.Definitions.words_state a ->
prev: Spec.Hash.Definitions.extra_state a ->
blocks: Spec.Hash.Definitions.bytes_blocks a
-> Prims.Pure (Spec.Hash.Definitions.words_state a) | {
"end_col": 73,
"end_line": 46,
"start_col": 49,
"start_line": 46
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let shuffle_core_opaque_aux = shuffle_core | let shuffle_core_opaque_aux = | false | null | false | shuffle_core | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"total"
] | [
"Spec.SHA2.Lemmas.shuffle_core"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t) | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val shuffle_core_opaque_aux : a: Spec.Hash.Definitions.sha2_alg ->
block: Spec.SHA2.block_w a ->
hash: Spec.Hash.Definitions.words_state a ->
t: Spec.SHA2.counter{t < Spec.SHA2.size_k_w a}
-> Spec.Hash.Definitions.words_state a | [] | Vale.SHA.SHA_helpers.shuffle_core_opaque_aux | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Hash.Definitions.sha2_alg ->
block: Spec.SHA2.block_w a ->
hash: Spec.Hash.Definitions.words_state a ->
t: Spec.SHA2.counter{t < Spec.SHA2.size_k_w a}
-> Spec.Hash.Definitions.words_state a | {
"end_col": 49,
"end_line": 42,
"start_col": 37,
"start_line": 42
} |
|
Prims.Tot | val word_to_nat32 (x:word) : nat32 | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let word_to_nat32 = vv | val word_to_nat32 (x:word) : nat32
let word_to_nat32 = | false | null | false | vv | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"total"
] | [
"Vale.SHA.SHA_helpers.vv"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks | false | true | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val word_to_nat32 (x:word) : nat32 | [] | Vale.SHA.SHA_helpers.word_to_nat32 | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Vale.SHA.SHA_helpers.word -> Vale.Def.Words_s.nat32 | {
"end_col": 22,
"end_line": 55,
"start_col": 20,
"start_line": 55
} |
Prims.Tot | val add_mod32 (x: word) (y: nat32) : nat32 | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y)) | val add_mod32 (x: word) (y: nat32) : nat32
let add_mod32 (x: word) (y: nat32) : nat32 = | false | null | false | vv (add_mod x (to_uint32 y)) | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"total"
] | [
"Vale.SHA.SHA_helpers.word",
"Vale.Def.Words_s.nat32",
"Vale.SHA.SHA_helpers.vv",
"FStar.UInt32.add_mod",
"Vale.SHA.SHA_helpers.to_uint32"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks | false | true | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val add_mod32 (x: word) (y: nat32) : nat32 | [] | Vale.SHA.SHA_helpers.add_mod32 | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Vale.SHA.SHA_helpers.word -> y: Vale.Def.Words_s.nat32 -> Vale.Def.Words_s.nat32 | {
"end_col": 71,
"end_line": 54,
"start_col": 43,
"start_line": 54
} |
FStar.Pervasives.Lemma | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi | let update_multi_reveal = | false | null | true | opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"Vale.Def.Opaque_s.opaque_revealer",
"Spec.Hash.Definitions.hash_alg",
"Spec.Hash.Definitions.words_state",
"Spec.Hash.Definitions.extra_state",
"Spec.Hash.Definitions.bytes_blocks",
"Prims.b2t",
"Spec.Agile.Hash.update_multi_pre",
"Prims.l_True",
"Vale.SHA.SHA_helpers.update_multi_opaque_aux",
"Spec.Agile.Hash.update_multi"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val update_multi_reveal : _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.SHA.SHA_helpers.update_multi_opaque_aux == Spec.Agile.Hash.update_multi) | [] | Vale.SHA.SHA_helpers.update_multi_reveal | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.SHA.SHA_helpers.update_multi_opaque_aux == Spec.Agile.Hash.update_multi) | {
"end_col": 118,
"end_line": 47,
"start_col": 38,
"start_line": 47
} |
|
FStar.Pervasives.Lemma | val translate_hash_update (h0 h1 h0' h1' a0 a1: quad32)
: Lemma (requires h0' == add_wrap_quad32 a0 h0 /\ h1' == add_wrap_quad32 a1 h1)
(ensures
(let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
mapped == h')) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let translate_hash_update (h0 h1 h0' h1' a0 a1:quad32) : Lemma
(requires h0' == add_wrap_quad32 a0 h0 /\
h1' == add_wrap_quad32 a1 h1)
(ensures (
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
mapped == h'))
=
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
assert (equal mapped h');
() | val translate_hash_update (h0 h1 h0' h1' a0 a1: quad32)
: Lemma (requires h0' == add_wrap_quad32 a0 h0 /\ h1' == add_wrap_quad32 a1 h1)
(ensures
(let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
mapped == h'))
let translate_hash_update (h0 h1 h0' h1' a0 a1: quad32)
: Lemma (requires h0' == add_wrap_quad32 a0 h0 /\ h1' == add_wrap_quad32 a1 h1)
(ensures
(let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
mapped == h')) = | false | null | true | let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
assert (equal mapped h');
() | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"Vale.Def.Types_s.quad32",
"Prims.unit",
"Prims._assert",
"FStar.Seq.Base.equal",
"Vale.SHA.SHA_helpers.word",
"FStar.Classical.forall_intro_2",
"Vale.Def.Words_s.nat32",
"Prims.eq2",
"Vale.Def.Words_s.natN",
"Vale.Def.Words_s.pow2_32",
"Vale.Def.Types_s.add_wrap",
"Vale.SHA.SHA_helpers.vv",
"FStar.UInt32.add_mod",
"Vale.SHA.SHA_helpers.to_uint32",
"Vale.SHA.SHA_helpers.lemma_add_wrap_is_add_mod",
"FStar.Seq.Base.seq",
"Prims.l_and",
"Prims.b2t",
"Prims.op_Equality",
"Prims.nat",
"FStar.Seq.Base.length",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.op_LessThan",
"FStar.Seq.Base.index",
"Lib.IntTypes.add_mod",
"Lib.IntTypes.U32",
"Lib.IntTypes.SEC",
"Spec.Loops.seq_map2",
"Lib.IntTypes.op_Plus_Dot",
"Vale.SHA.SHA_helpers.hash256",
"Vale.SHA.SHA_helpers.make_hash",
"Vale.Arch.Types.add_wrap_quad32",
"Prims.squash",
"Prims.l_or",
"Prims.int",
"Lib.IntTypes.int_t",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
// Top-level proof for the SHA256_msg1 instruction
let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
=
sha256_msg1_spec_reveal ();
let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
let ws_computed (b:block_w) (t:counter{t < size_k_w_256}): Tot (UInt32.t) =
if t < block_word_length SHA2_256 then to_uint32 (ws_opaque b t)
else
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
let open Lib.IntTypes in
(t16 +. s0 +. t7 +. s1)
#push-options "--max_fuel 1"
let lemma_ws_computed_is_ws (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (ws_computed b t == ws SHA2_256 b t)
=
Pervasives.reveal_opaque (`%ws) ws;
if t < block_word_length SHA2_256 then (
assert (vv (ws_computed b t) == ws_opaque b t);
assert (to_uint32 (ws_opaque b t) == ws SHA2_256 b t);
()
) else (
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
lemma_add_mod_ws_rearrangement s1 t7 s0 t16;
()
)
#pop-options
let lemma_ws_computed_is_ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (vv (ws_computed b t) == ws_opaque b t)
=
lemma_ws_computed_is_ws b t;
Pervasives.reveal_opaque (`%ws) ws;
()
let ws_computed_quad32 (t:counter{t < size_k_w_256 - 3}) (block:block_w) : quad32 =
Mkfour (vv (ws_computed block t))
(vv (ws_computed block (t+1)))
(vv (ws_computed block (t+2)))
(vv (ws_computed block (t+3)))
let lemma_ws_computed_is_ws_quad32 (b:block_w) (t:counter{t < size_k_w_256 - 3}) :
Lemma (ws_computed_quad32 t b == ws_quad32 t b)
=
let w = ws_computed_quad32 t b in
let w' = ws_quad32 t b in
lemma_ws_computed_is_ws_opaque b t;
lemma_ws_computed_is_ws_opaque b (t+1);
lemma_ws_computed_is_ws_opaque b (t+2);
lemma_ws_computed_is_ws_opaque b (t+3);
()
#push-options "--z3rlimit 30"
let lemma_ws_computed_quad32 (t:counter{16 <= t /\ t < size_k_w_256 - 4}) (block:block_w) :
Lemma (let t_minus_16 = ws_quad32 (t-16) block in
let t_minus_15 = ws_quad32 (t-15) block in
let t_minus_7 = ws_quad32 (t - 7) block in
let t_minus_2 = ws_quad32 (t - 2) block in
let m1 = add_mod_quad32 t_minus_16 (_sigma0_quad32 t_minus_15) in
let m2 = add_mod_quad32 m1 t_minus_7 in
let m3 = add_mod_quad32 m2 (_sigma1_quad32 t_minus_2) in
m3 == ws_computed_quad32 t block )
=
()
#pop-options
let sha256_msg1_spec_t (t:counter{t < size_k_w_256 - 1}) (block:block_w) : quad32 =
let init = ws_quad32 t block in
let next = ws_quad32 (t + 1) block in
let msg1 = add_mod_quad32 init (_sigma0_quad32 next) in
msg1
#push-options "--ifuel 1"
let lemma_sha256_msg1_spec_t_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 - 3)
(ensures ws_partial t block == sha256_msg1_spec_t (t-16) block)
=
ws_partial_reveal ();
let init = ws_quad32 (t-16) block in
let next = ws_quad32 (t-15) block in
lemma_add_wrap_quad32_is_add_mod_quad32 init (_sigma0_quad32 next);
()
#pop-options
let lemma_sha256_msg1_spec_t (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w_256 - 4 /\
src1 == ws_quad32 t block /\
src2.lo0 == ws_opaque block (t+4))
(ensures sha256_msg1_spec_t t block == sha256_msg1_spec src1 src2)
=
sha256_msg1_spec_reveal ();
()
#push-options "--z3rlimit 70"
let lemma_sha256_step2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1) /\
(let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
src1 == add_mod_quad32 w mid))
(ensures sha256_msg2_spec src1 src2 == ws_computed_quad32 t block)
=
sha256_msg2_spec_reveal ();
let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
let final = sha256_msg2_spec src1 src2 in
lemma_ws_computed_is_ws_opaque block (t);
lemma_ws_computed_is_ws_opaque block (t+1);
()
#pop-options
// Top-level proof for the SHA256_msg2 instruction
let lemma_sha256_msg2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
(let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
src1 == add_wrap_quad32 step1 t_minus_7 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1)))
(ensures sha256_msg2_spec src1 src2 == ws_quad32 t block)
=
let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
lemma_sha256_msg1_spec_t_partial t block;
// ==> step1 == sha256_msg1_spec_t (t-16) block
lemma_add_wrap_quad32_is_add_mod_quad32 step1 t_minus_7;
lemma_sha256_step2 src1 src2 t block;
lemma_ws_computed_is_ws_quad32 block t;
()
(* Abbreviations and lemmas for the code itself *)
#reset-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block qs
=
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32);
reveal_opaque (`%ws) ws
#reset-options "--max_fuel 0 --max_ifuel 0"
let translate_hash_update (h0 h1 h0' h1' a0 a1:quad32) : Lemma
(requires h0' == add_wrap_quad32 a0 h0 /\
h1' == add_wrap_quad32 a1 h1)
(ensures (
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val translate_hash_update (h0 h1 h0' h1' a0 a1: quad32)
: Lemma (requires h0' == add_wrap_quad32 a0 h0 /\ h1' == add_wrap_quad32 a1 h1)
(ensures
(let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
mapped == h')) | [] | Vale.SHA.SHA_helpers.translate_hash_update | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h0: Vale.Def.Types_s.quad32 ->
h1: Vale.Def.Types_s.quad32 ->
h0': Vale.Def.Types_s.quad32 ->
h1': Vale.Def.Types_s.quad32 ->
a0: Vale.Def.Types_s.quad32 ->
a1: Vale.Def.Types_s.quad32
-> FStar.Pervasives.Lemma
(requires
h0' == Vale.Arch.Types.add_wrap_quad32 a0 h0 /\ h1' == Vale.Arch.Types.add_wrap_quad32 a1 h1
)
(ensures
(let h = Vale.SHA.SHA_helpers.make_hash h0 h1 in
let a = Vale.SHA.SHA_helpers.make_hash a0 a1 in
let h' = Vale.SHA.SHA_helpers.make_hash h0' h1' in
let mapped = Spec.Loops.seq_map2 Lib.IntTypes.op_Plus_Dot h a in
mapped == h')) | {
"end_col": 4,
"end_line": 645,
"start_col": 3,
"start_line": 637
} |
Prims.Tot | val add_mod_quad32 (q0 q1: quad32) : quad32 | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3))) | val add_mod_quad32 (q0 q1: quad32) : quad32
let add_mod_quad32 (q0 q1: quad32) : quad32 = | false | null | false | Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3))) | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"total"
] | [
"Vale.Def.Types_s.quad32",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Vale.SHA.SHA_helpers.vv",
"FStar.UInt32.add_mod",
"Vale.SHA.SHA_helpers.to_uint32",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0 | false | true | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val add_mod_quad32 (q0 q1: quad32) : quad32 | [] | Vale.SHA.SHA_helpers.add_mod_quad32 | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | q0: Vale.Def.Types_s.quad32 -> q1: Vale.Def.Types_s.quad32 -> Vale.Def.Types_s.quad32 | {
"end_col": 61,
"end_line": 433,
"start_col": 2,
"start_line": 430
} |
FStar.Pervasives.Lemma | val update_lemma (src1 src2 src1' src2' h0 h1:quad32) (block:block_w) : Lemma
(requires (let hash_orig = make_hash h0 h1 in
make_hash src1 src2 ==
Spec.Loops.repeat_range 0 size_k_w_256 (shuffle_core_opaque block) hash_orig /\
src1' == add_wrap_quad32 src1 h0 /\
src2' == add_wrap_quad32 src2 h1))
(ensures (let hash_orig = make_hash h0 h1 in
make_hash src1' src2' == update_block hash_orig block)) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let update_lemma (src1 src2 src1' src2' h0 h1:quad32) (block:block_w) : Lemma
(requires (let hash_orig = make_hash h0 h1 in
make_hash src1 src2 ==
Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash_orig /\
src1' == add_wrap_quad32 src1 h0 /\
src2' == add_wrap_quad32 src2 h1))
(ensures (let hash_orig = make_hash h0 h1 in
make_hash src1' src2' == update_block hash_orig block))
=
let hash_orig = make_hash h0 h1 in
let hash_1 = shuffle_opaque SHA2_256 hash_orig block in
Pervasives.reveal_opaque (`%shuffle) shuffle;
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let rec f (i:nat{i <= 64}) : Lemma (
Spec.Loops.repeat_range 0 i (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 i (shuffle_core SHA2_256 block) hash_orig)
=
if i = 0 then (
Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_base 0 (shuffle_core SHA2_256 block) hash_orig
) else (
f (i - 1);
Spec.Loops.repeat_range_induction 0 i (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_induction 0 i (shuffle_core SHA2_256 block) hash_orig
)
in
f 64;
(*
let h = make_hash src1 src2 in
assert (forall (block:block_w) (hash:hash256) . FStar.FunctionalExtensionality.feq (shuffle_core_opaque block hash) (shuffle_core_opaque_aux SHA2_256 block hash));
//assert (forall (block:block_w) . (shuffle_core_opaque block) == (shuffle_core_opaque_aux SHA2_256 block));
assert (shuffle_core_opaque == shuffle_core_opaque_aux SHA2_256);
assert (shuffle_core_opaque == shuffle_core SHA2_256);
assert (shuffle_core_opaque block == shuffle_core SHA2_256 block);
assert (Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 64 (shuffle_core SHA2_256 block) hash_orig);
assert (make_hash src1 src2 == shuffle SHA2_256 hash_orig block);
assert (make_hash src1 src2 == shuffle_opaque SHA2_256 hash_orig block);
*)
translate_hash_update src1 src2 src1' src2' h0 h1;
shuffle_is_shuffle_pre SHA2_256 hash_orig block;
assert (equal (make_hash src1' src2') (update_block hash_orig block));
() | val update_lemma (src1 src2 src1' src2' h0 h1:quad32) (block:block_w) : Lemma
(requires (let hash_orig = make_hash h0 h1 in
make_hash src1 src2 ==
Spec.Loops.repeat_range 0 size_k_w_256 (shuffle_core_opaque block) hash_orig /\
src1' == add_wrap_quad32 src1 h0 /\
src2' == add_wrap_quad32 src2 h1))
(ensures (let hash_orig = make_hash h0 h1 in
make_hash src1' src2' == update_block hash_orig block))
let update_lemma (src1 src2 src1' src2' h0 h1: quad32) (block: block_w)
: Lemma
(requires
(let hash_orig = make_hash h0 h1 in
make_hash src1 src2 == Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash_orig /\
src1' == add_wrap_quad32 src1 h0 /\ src2' == add_wrap_quad32 src2 h1))
(ensures
(let hash_orig = make_hash h0 h1 in
make_hash src1' src2' == update_block hash_orig block)) = | false | null | true | let hash_orig = make_hash h0 h1 in
let hash_1 = shuffle_opaque SHA2_256 hash_orig block in
Pervasives.reveal_opaque (`%shuffle) shuffle;
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let rec f (i: nat{i <= 64})
: Lemma
(Spec.Loops.repeat_range 0 i (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 i (shuffle_core SHA2_256 block) hash_orig) =
if i = 0
then
(Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_base 0 (shuffle_core SHA2_256 block) hash_orig)
else
(f (i - 1);
Spec.Loops.repeat_range_induction 0 i (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_induction 0 i (shuffle_core SHA2_256 block) hash_orig)
in
f 64;
translate_hash_update src1 src2 src1' src2' h0 h1;
shuffle_is_shuffle_pre SHA2_256 hash_orig block;
assert (equal (make_hash src1' src2') (update_block hash_orig block));
() | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"Vale.Def.Types_s.quad32",
"Vale.SHA.SHA_helpers.block_w",
"Prims.unit",
"Prims._assert",
"FStar.Seq.Base.equal",
"Vale.SHA.SHA_helpers.word",
"Vale.SHA.SHA_helpers.make_hash",
"Vale.SHA.SHA_helpers.update_block",
"Spec.SHA2.Lemmas.shuffle_is_shuffle_pre",
"Spec.Hash.Definitions.SHA2_256",
"Vale.SHA.SHA_helpers.translate_hash_update",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"FStar.Seq.Base.seq",
"Prims.l_or",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.state_word_length",
"Spec.Loops.repeat_range",
"Vale.SHA.SHA_helpers.hash256",
"Vale.SHA.SHA_helpers.shuffle_core_opaque",
"Spec.Hash.Definitions.words_state",
"Spec.SHA2.Lemmas.shuffle_core",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Spec.Loops.repeat_range_base",
"Prims.bool",
"Spec.Loops.repeat_range_induction",
"Prims.op_Subtraction",
"FStar.Pervasives.reveal_opaque",
"Spec.Hash.Definitions.sha2_alg",
"Spec.SHA2.block_w",
"Spec.SHA2.counter",
"Prims.op_LessThan",
"Spec.SHA2.size_k_w",
"Spec.SHA2.shuffle",
"Vale.SHA.SHA_helpers.shuffle_opaque",
"Prims.l_and",
"Vale.Arch.Types.add_wrap_quad32"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
// Top-level proof for the SHA256_msg1 instruction
let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
=
sha256_msg1_spec_reveal ();
let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
let ws_computed (b:block_w) (t:counter{t < size_k_w_256}): Tot (UInt32.t) =
if t < block_word_length SHA2_256 then to_uint32 (ws_opaque b t)
else
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
let open Lib.IntTypes in
(t16 +. s0 +. t7 +. s1)
#push-options "--max_fuel 1"
let lemma_ws_computed_is_ws (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (ws_computed b t == ws SHA2_256 b t)
=
Pervasives.reveal_opaque (`%ws) ws;
if t < block_word_length SHA2_256 then (
assert (vv (ws_computed b t) == ws_opaque b t);
assert (to_uint32 (ws_opaque b t) == ws SHA2_256 b t);
()
) else (
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
lemma_add_mod_ws_rearrangement s1 t7 s0 t16;
()
)
#pop-options
let lemma_ws_computed_is_ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (vv (ws_computed b t) == ws_opaque b t)
=
lemma_ws_computed_is_ws b t;
Pervasives.reveal_opaque (`%ws) ws;
()
let ws_computed_quad32 (t:counter{t < size_k_w_256 - 3}) (block:block_w) : quad32 =
Mkfour (vv (ws_computed block t))
(vv (ws_computed block (t+1)))
(vv (ws_computed block (t+2)))
(vv (ws_computed block (t+3)))
let lemma_ws_computed_is_ws_quad32 (b:block_w) (t:counter{t < size_k_w_256 - 3}) :
Lemma (ws_computed_quad32 t b == ws_quad32 t b)
=
let w = ws_computed_quad32 t b in
let w' = ws_quad32 t b in
lemma_ws_computed_is_ws_opaque b t;
lemma_ws_computed_is_ws_opaque b (t+1);
lemma_ws_computed_is_ws_opaque b (t+2);
lemma_ws_computed_is_ws_opaque b (t+3);
()
#push-options "--z3rlimit 30"
let lemma_ws_computed_quad32 (t:counter{16 <= t /\ t < size_k_w_256 - 4}) (block:block_w) :
Lemma (let t_minus_16 = ws_quad32 (t-16) block in
let t_minus_15 = ws_quad32 (t-15) block in
let t_minus_7 = ws_quad32 (t - 7) block in
let t_minus_2 = ws_quad32 (t - 2) block in
let m1 = add_mod_quad32 t_minus_16 (_sigma0_quad32 t_minus_15) in
let m2 = add_mod_quad32 m1 t_minus_7 in
let m3 = add_mod_quad32 m2 (_sigma1_quad32 t_minus_2) in
m3 == ws_computed_quad32 t block )
=
()
#pop-options
let sha256_msg1_spec_t (t:counter{t < size_k_w_256 - 1}) (block:block_w) : quad32 =
let init = ws_quad32 t block in
let next = ws_quad32 (t + 1) block in
let msg1 = add_mod_quad32 init (_sigma0_quad32 next) in
msg1
#push-options "--ifuel 1"
let lemma_sha256_msg1_spec_t_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 - 3)
(ensures ws_partial t block == sha256_msg1_spec_t (t-16) block)
=
ws_partial_reveal ();
let init = ws_quad32 (t-16) block in
let next = ws_quad32 (t-15) block in
lemma_add_wrap_quad32_is_add_mod_quad32 init (_sigma0_quad32 next);
()
#pop-options
let lemma_sha256_msg1_spec_t (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w_256 - 4 /\
src1 == ws_quad32 t block /\
src2.lo0 == ws_opaque block (t+4))
(ensures sha256_msg1_spec_t t block == sha256_msg1_spec src1 src2)
=
sha256_msg1_spec_reveal ();
()
#push-options "--z3rlimit 70"
let lemma_sha256_step2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1) /\
(let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
src1 == add_mod_quad32 w mid))
(ensures sha256_msg2_spec src1 src2 == ws_computed_quad32 t block)
=
sha256_msg2_spec_reveal ();
let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
let final = sha256_msg2_spec src1 src2 in
lemma_ws_computed_is_ws_opaque block (t);
lemma_ws_computed_is_ws_opaque block (t+1);
()
#pop-options
// Top-level proof for the SHA256_msg2 instruction
let lemma_sha256_msg2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
(let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
src1 == add_wrap_quad32 step1 t_minus_7 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1)))
(ensures sha256_msg2_spec src1 src2 == ws_quad32 t block)
=
let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
lemma_sha256_msg1_spec_t_partial t block;
// ==> step1 == sha256_msg1_spec_t (t-16) block
lemma_add_wrap_quad32_is_add_mod_quad32 step1 t_minus_7;
lemma_sha256_step2 src1 src2 t block;
lemma_ws_computed_is_ws_quad32 block t;
()
(* Abbreviations and lemmas for the code itself *)
#reset-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block qs
=
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32);
reveal_opaque (`%ws) ws
#reset-options "--max_fuel 0 --max_ifuel 0"
let translate_hash_update (h0 h1 h0' h1' a0 a1:quad32) : Lemma
(requires h0' == add_wrap_quad32 a0 h0 /\
h1' == add_wrap_quad32 a1 h1)
(ensures (
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
mapped == h'))
=
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
assert (equal mapped h');
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_lemma (src1 src2 src1' src2' h0 h1:quad32) (block:block_w) : Lemma
(requires (let hash_orig = make_hash h0 h1 in
make_hash src1 src2 ==
Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash_orig /\
src1' == add_wrap_quad32 src1 h0 /\
src2' == add_wrap_quad32 src2 h1))
(ensures (let hash_orig = make_hash h0 h1 in | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val update_lemma (src1 src2 src1' src2' h0 h1:quad32) (block:block_w) : Lemma
(requires (let hash_orig = make_hash h0 h1 in
make_hash src1 src2 ==
Spec.Loops.repeat_range 0 size_k_w_256 (shuffle_core_opaque block) hash_orig /\
src1' == add_wrap_quad32 src1 h0 /\
src2' == add_wrap_quad32 src2 h1))
(ensures (let hash_orig = make_hash h0 h1 in
make_hash src1' src2' == update_block hash_orig block)) | [] | Vale.SHA.SHA_helpers.update_lemma | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
src1: Vale.Def.Types_s.quad32 ->
src2: Vale.Def.Types_s.quad32 ->
src1': Vale.Def.Types_s.quad32 ->
src2': Vale.Def.Types_s.quad32 ->
h0: Vale.Def.Types_s.quad32 ->
h1: Vale.Def.Types_s.quad32 ->
block: Vale.SHA.SHA_helpers.block_w
-> FStar.Pervasives.Lemma
(requires
(let hash_orig = Vale.SHA.SHA_helpers.make_hash h0 h1 in
Vale.SHA.SHA_helpers.make_hash src1 src2 ==
Spec.Loops.repeat_range 0
Vale.SHA.SHA_helpers.size_k_w_256
(Vale.SHA.SHA_helpers.shuffle_core_opaque block)
hash_orig /\ src1' == Vale.Arch.Types.add_wrap_quad32 src1 h0 /\
src2' == Vale.Arch.Types.add_wrap_quad32 src2 h1))
(ensures
(let hash_orig = Vale.SHA.SHA_helpers.make_hash h0 h1 in
Vale.SHA.SHA_helpers.make_hash src1' src2' ==
Vale.SHA.SHA_helpers.update_block hash_orig block)) | {
"end_col": 4,
"end_line": 706,
"start_col": 3,
"start_line": 672
} |
FStar.Pervasives.Lemma | val lemma_sha256_rnds2_spec_update_is_shuffle_core
(hash: hash256)
(wk: UInt32.t)
(t: counter)
(block: block_w)
: Lemma
(requires
t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[ t ] (ws_opaque block t))
)
(ensures
(let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[ 0 ]
hash.[ 1 ]
hash.[ 2 ]
hash.[ 3 ]
hash.[ 4 ]
hash.[ 5 ]
hash.[ 6 ]
hash.[ 7 ]
wk
in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c)) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk | val lemma_sha256_rnds2_spec_update_is_shuffle_core
(hash: hash256)
(wk: UInt32.t)
(t: counter)
(block: block_w)
: Lemma
(requires
t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[ t ] (ws_opaque block t))
)
(ensures
(let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[ 0 ]
hash.[ 1 ]
hash.[ 2 ]
hash.[ 3 ]
hash.[ 4 ]
hash.[ 5 ]
hash.[ 6 ]
hash.[ 7 ]
wk
in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
let lemma_sha256_rnds2_spec_update_is_shuffle_core
(hash: hash256)
(wk: UInt32.t)
(t: counter)
(block: block_w)
: Lemma
(requires
t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[ t ] (ws_opaque block t))
)
(ensures
(let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[ 0 ]
hash.[ 1 ]
hash.[ 2 ]
hash.[ 3 ]
hash.[ 4 ]
hash.[ 5 ]
hash.[ 6 ]
hash.[ 7 ]
wk
in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c)) = | false | null | true | let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[ 0 ]
hash.[ 1 ]
hash.[ 2 ]
hash.[ 3 ]
hash.[ 4 ]
hash.[ 5 ]
hash.[ 6 ]
hash.[ 7 ]
wk
in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[ 0 ]
hash.[ 1 ]
hash.[ 2 ]
hash.[ 3 ]
hash.[ 4 ]
hash.[ 5 ]
hash.[ 6 ]
hash.[ 7 ]
wk;
lemma_add_mod_e hash.[ 0 ]
hash.[ 1 ]
hash.[ 2 ]
hash.[ 3 ]
hash.[ 4 ]
hash.[ 5 ]
hash.[ 6 ]
hash.[ 7 ]
wk | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"Vale.SHA.SHA_helpers.hash256",
"FStar.UInt32.t",
"Vale.SHA.SHA_helpers.counter",
"Vale.SHA.SHA_helpers.block_w",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.SHA2_256",
"Vale.SHA.SHA_helpers.lemma_add_mod_e",
"Spec.SHA2.op_String_Access",
"Vale.SHA.SHA_helpers.word",
"Prims.unit",
"Vale.SHA.SHA_helpers.lemma_add_mod_a",
"FStar.Classical.forall_intro_3",
"Prims.eq2",
"FStar.UInt32.add_mod",
"Vale.SHA.SHA_helpers.lemma_add_mod_associates_U32",
"FStar.Seq.Properties.elim_of_list",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.SEC",
"Vale.SHA.SHA_helpers.shuffle_core_properties",
"FStar.Pervasives.reveal_opaque",
"Spec.Hash.Definitions.sha2_alg",
"Spec.SHA2.block_w",
"Spec.SHA2.counter",
"Prims.b2t",
"Prims.op_LessThan",
"Spec.SHA2.size_k_w",
"Spec.SHA2.Lemmas.ws",
"Spec.Hash.Definitions.words_state",
"Spec.SHA2.Lemmas.shuffle_core",
"Vale.SHA.SHA_helpers.shuffle_core_opaque",
"FStar.Pervasives.assert_norm",
"Prims.int",
"FStar.List.Tot.Base.length",
"FStar.Seq.Base.seq",
"FStar.Seq.Properties.seq_of_list",
"Prims.list",
"Prims.Cons",
"Prims.Nil",
"FStar.Pervasives.Native.tuple8",
"Vale.X64.CryptoInstructions_s.sha256_rnds2_spec_update",
"Prims.l_and",
"Vale.SHA.SHA_helpers.to_uint32",
"Vale.SHA.SHA_helpers.add_mod32",
"Spec.SHA2.k0",
"Vale.SHA.SHA_helpers.ws_opaque",
"Prims.squash",
"Prims.l_or",
"Prims.op_Equality",
"FStar.Seq.Base.length",
"Prims.nat",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val lemma_sha256_rnds2_spec_update_is_shuffle_core
(hash: hash256)
(wk: UInt32.t)
(t: counter)
(block: block_w)
: Lemma
(requires
t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[ t ] (ws_opaque block t))
)
(ensures
(let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[ 0 ]
hash.[ 1 ]
hash.[ 2 ]
hash.[ 3 ]
hash.[ 4 ]
hash.[ 5 ]
hash.[ 6 ]
hash.[ 7 ]
wk
in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c)) | [] | Vale.SHA.SHA_helpers.lemma_sha256_rnds2_spec_update_is_shuffle_core | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
hash: Vale.SHA.SHA_helpers.hash256 ->
wk: FStar.UInt32.t ->
t: Vale.SHA.SHA_helpers.counter ->
block: Vale.SHA.SHA_helpers.block_w
-> FStar.Pervasives.Lemma
(requires
t < Spec.SHA2.size_k_w Spec.Hash.Definitions.SHA2_256 /\
wk ==
Vale.SHA.SHA_helpers.to_uint32 (Vale.SHA.SHA_helpers.add_mod32 (Spec.SHA2.k0 Spec.Hash.Definitions.SHA2_256
).[ t ]
(Vale.SHA.SHA_helpers.ws_opaque block t)))
(ensures
(let _ =
Vale.X64.CryptoInstructions_s.sha256_rnds2_spec_update hash.[ 0 ]
hash.[ 1 ]
hash.[ 2 ]
hash.[ 3 ]
hash.[ 4 ]
hash.[ 5 ]
hash.[ 6 ]
hash.[ 7 ]
wk
in
(let FStar.Pervasives.Native.Mktuple8 #_ #_ #_ #_ #_ #_ #_ #_ a' b' c' d' e' f' g' h' =
_
in
let u121 = FStar.Seq.Properties.seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = Vale.SHA.SHA_helpers.shuffle_core_opaque block hash t in
u121 == c)
<:
Type0)) | {
"end_col": 92,
"end_line": 305,
"start_col": 3,
"start_line": 291
} |
FStar.Pervasives.Lemma | val shuffle_core_properties (block: block_w) (hash: hash256) (t: counter{t < size_k_w_256})
: Lemma
(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[ 0 ] in
let b0 = hash.[ 1 ] in
let c0 = hash.[ 2 ] in
let d0 = hash.[ 3 ] in
let e0 = hash.[ 4 ] in
let f0 = hash.[ 5 ] in
let g0 = hash.[ 6 ] in
let h0 = hash.[ 7 ] in
let t1 =
h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[ t ] +.
(ws SHA2_256 block t)
in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[ 0 ] == t1 +. t2 /\ h.[ 1 ] == a0 /\ h.[ 2 ] == b0 /\ h.[ 3 ] == c0 /\ h.[ 4 ] == d0 +. t1 /\
h.[ 5 ] == e0 /\ h.[ 6 ] == f0 /\ h.[ 7 ] == g0) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
() | val shuffle_core_properties (block: block_w) (hash: hash256) (t: counter{t < size_k_w_256})
: Lemma
(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[ 0 ] in
let b0 = hash.[ 1 ] in
let c0 = hash.[ 2 ] in
let d0 = hash.[ 3 ] in
let e0 = hash.[ 4 ] in
let f0 = hash.[ 5 ] in
let g0 = hash.[ 6 ] in
let h0 = hash.[ 7 ] in
let t1 =
h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[ t ] +.
(ws SHA2_256 block t)
in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[ 0 ] == t1 +. t2 /\ h.[ 1 ] == a0 /\ h.[ 2 ] == b0 /\ h.[ 3 ] == c0 /\ h.[ 4 ] == d0 +. t1 /\
h.[ 5 ] == e0 /\ h.[ 6 ] == f0 /\ h.[ 7 ] == g0)
let shuffle_core_properties (block: block_w) (hash: hash256) (t: counter{t < size_k_w_256})
: Lemma
(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[ 0 ] in
let b0 = hash.[ 1 ] in
let c0 = hash.[ 2 ] in
let d0 = hash.[ 3 ] in
let e0 = hash.[ 4 ] in
let f0 = hash.[ 5 ] in
let g0 = hash.[ 6 ] in
let h0 = hash.[ 7 ] in
let t1 =
h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[ t ] +.
(ws SHA2_256 block t)
in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[ 0 ] == t1 +. t2 /\ h.[ 1 ] == a0 /\ h.[ 2 ] == b0 /\ h.[ 3 ] == c0 /\ h.[ 4 ] == d0 +. t1 /\
h.[ 5 ] == e0 /\ h.[ 6 ] == f0 /\ h.[ 7 ] == g0) = | false | null | true | Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[ 0 ] in
let b0 = hash.[ 1 ] in
let c0 = hash.[ 2 ] in
let d0 = hash.[ 3 ] in
let e0 = hash.[ 4 ] in
let f0 = hash.[ 5 ] in
let g0 = hash.[ 6 ] in
let h0 = hash.[ 7 ] in
let t1 =
h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[ t ] +.
(ws SHA2_256 block t)
in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0] in
assert (h == seq_of_list l);
elim_of_list l;
() | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"Vale.SHA.SHA_helpers.block_w",
"Vale.SHA.SHA_helpers.hash256",
"Vale.SHA.SHA_helpers.counter",
"Prims.b2t",
"Prims.op_LessThan",
"Vale.SHA.SHA_helpers.size_k_w_256",
"Prims.unit",
"FStar.Seq.Properties.elim_of_list",
"FStar.UInt32.t",
"Prims._assert",
"Prims.eq2",
"FStar.Seq.Base.seq",
"Prims.l_or",
"Prims.op_Equality",
"Prims.nat",
"FStar.List.Tot.Base.length",
"FStar.Seq.Base.length",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.SHA2_256",
"Spec.Hash.Definitions.state_word_length",
"FStar.Seq.Properties.seq_of_list",
"Prims.list",
"Prims.Cons",
"Spec.SHA2.op_Plus_Dot",
"Prims.Nil",
"Spec.SHA2._Sigma0",
"Spec.SHA2._Maj",
"Spec.SHA2._Sigma1",
"Spec.SHA2._Ch",
"Spec.SHA2.op_String_Access",
"Spec.SHA2.k0",
"Spec.SHA2.Lemmas.ws",
"Vale.SHA.SHA_helpers.word",
"Spec.Hash.Definitions.words_state",
"Spec.SHA2.Lemmas.shuffle_core",
"FStar.Pervasives.reveal_opaque",
"Spec.Hash.Definitions.sha2_alg",
"Spec.SHA2.block_w",
"Spec.SHA2.counter",
"Spec.SHA2.size_k_w",
"Prims.l_True",
"Prims.squash",
"Prims.l_and",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Plus_Dot",
"Vale.SHA.SHA_helpers.shuffle_core_opaque",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0) | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val shuffle_core_properties (block: block_w) (hash: hash256) (t: counter{t < size_k_w_256})
: Lemma
(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[ 0 ] in
let b0 = hash.[ 1 ] in
let c0 = hash.[ 2 ] in
let d0 = hash.[ 3 ] in
let e0 = hash.[ 4 ] in
let f0 = hash.[ 5 ] in
let g0 = hash.[ 6 ] in
let h0 = hash.[ 7 ] in
let t1 =
h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[ t ] +.
(ws SHA2_256 block t)
in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[ 0 ] == t1 +. t2 /\ h.[ 1 ] == a0 /\ h.[ 2 ] == b0 /\ h.[ 3 ] == c0 /\ h.[ 4 ] == d0 +. t1 /\
h.[ 5 ] == e0 /\ h.[ 6 ] == f0 /\ h.[ 7 ] == g0) | [] | Vale.SHA.SHA_helpers.shuffle_core_properties | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
block: Vale.SHA.SHA_helpers.block_w ->
hash: Vale.SHA.SHA_helpers.hash256 ->
t: Vale.SHA.SHA_helpers.counter{t < Vale.SHA.SHA_helpers.size_k_w_256}
-> FStar.Pervasives.Lemma
(ensures
(let h = Vale.SHA.SHA_helpers.shuffle_core_opaque block hash t in
let a0 = hash.[ 0 ] in
let b0 = hash.[ 1 ] in
let c0 = hash.[ 2 ] in
let d0 = hash.[ 3 ] in
let e0 = hash.[ 4 ] in
let f0 = hash.[ 5 ] in
let g0 = hash.[ 6 ] in
let h0 = hash.[ 7 ] in
let t1 =
h0 +. Spec.SHA2._Sigma1 Spec.Hash.Definitions.SHA2_256 e0 +.
Spec.SHA2._Ch Spec.Hash.Definitions.SHA2_256 e0 f0 g0 +.
(Spec.SHA2.k0 Spec.Hash.Definitions.SHA2_256).[ t ] +.
Spec.SHA2.Lemmas.ws Spec.Hash.Definitions.SHA2_256 block t
in
let t2 =
Spec.SHA2._Sigma0 Spec.Hash.Definitions.SHA2_256 a0 +.
Spec.SHA2._Maj Spec.Hash.Definitions.SHA2_256 a0 b0 c0
in
h.[ 0 ] == t1 +. t2 /\ h.[ 1 ] == a0 /\ h.[ 2 ] == b0 /\ h.[ 3 ] == c0 /\
h.[ 4 ] == d0 +. t1 /\ h.[ 5 ] == e0 /\ h.[ 6 ] == f0 /\ h.[ 7 ] == g0)) | {
"end_col": 4,
"end_line": 155,
"start_col": 2,
"start_line": 140
} |
Prims.Tot | val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32 | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t) | val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32
let ws_opaque (b: block_w) (t: counter{t < size_k_w_256}) : nat32 = | false | null | false | vv (ws_opaque_aux SHA2_256 b t) | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"total"
] | [
"Vale.SHA.SHA_helpers.block_w",
"Vale.SHA.SHA_helpers.counter",
"Prims.b2t",
"Prims.op_LessThan",
"Vale.SHA.SHA_helpers.size_k_w_256",
"Vale.SHA.SHA_helpers.vv",
"Vale.SHA.SHA_helpers.ws_opaque_aux",
"Spec.Hash.Definitions.SHA2_256",
"Vale.Def.Words_s.nat32"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val ws_opaque (b:block_w) (t:counter{t < size_k_w_256}):nat32 | [] | Vale.SHA.SHA_helpers.ws_opaque | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Vale.SHA.SHA_helpers.block_w ->
t: Vale.SHA.SHA_helpers.counter{t < Vale.SHA.SHA_helpers.size_k_w_256}
-> Vale.Def.Words_s.nat32 | {
"end_col": 33,
"end_line": 40,
"start_col": 2,
"start_line": 40
} |
Prims.Tot | val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks) | val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256
let update_multi_opaque (hash: hash256) (blocks: bytes_blocks) : hash256 = | false | null | false | (update_multi_opaque_aux SHA2_256 hash () blocks) | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"total"
] | [
"Vale.SHA.SHA_helpers.hash256",
"Vale.SHA.SHA_helpers.bytes_blocks",
"Vale.SHA.SHA_helpers.update_multi_opaque_aux",
"Spec.Hash.Definitions.SHA2_256"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi | false | true | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 | [] | Vale.SHA.SHA_helpers.update_multi_opaque | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | hash: Vale.SHA.SHA_helpers.hash256 -> blocks: Vale.SHA.SHA_helpers.bytes_blocks
-> Vale.SHA.SHA_helpers.hash256 | {
"end_col": 51,
"end_line": 49,
"start_col": 2,
"start_line": 49
} |
FStar.Pervasives.Lemma | val lemma_add_wrap_is_add_mod (n0 n1: nat32)
: Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1))) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
() | val lemma_add_wrap_is_add_mod (n0 n1: nat32)
: Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
let lemma_add_wrap_is_add_mod (n0 n1: nat32)
: Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1))) = | false | null | true | assert_norm (pow2 32 == pow2_32);
() | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"Vale.Def.Words_s.nat32",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"Prims.pow2",
"Vale.Def.Words_s.pow2_32",
"Prims.l_True",
"Prims.squash",
"Vale.Def.Words_s.natN",
"Vale.Def.Types_s.add_wrap",
"Vale.SHA.SHA_helpers.vv",
"FStar.UInt32.add_mod",
"Vale.SHA.SHA_helpers.to_uint32",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1))) | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val lemma_add_wrap_is_add_mod (n0 n1: nat32)
: Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1))) | [] | Vale.SHA.SHA_helpers.lemma_add_wrap_is_add_mod | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | n0: Vale.Def.Words_s.nat32 -> n1: Vale.Def.Words_s.nat32
-> FStar.Pervasives.Lemma
(ensures
Vale.Def.Types_s.add_wrap n0 n1 ==
Vale.SHA.SHA_helpers.vv (FStar.UInt32.add_mod (Vale.SHA.SHA_helpers.to_uint32 n0)
(Vale.SHA.SHA_helpers.to_uint32 n1))) | {
"end_col": 4,
"end_line": 219,
"start_col": 2,
"start_line": 218
} |
Prims.Tot | val _sigma1_quad32 (q: quad32) : quad32 | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3))) | val _sigma1_quad32 (q: quad32) : quad32
let _sigma1_quad32 (q: quad32) : quad32 = | false | null | false | Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3))) | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"total"
] | [
"Vale.Def.Types_s.quad32",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Vale.SHA.SHA_helpers.vv",
"Spec.SHA2._sigma1",
"Spec.Hash.Definitions.SHA2_256",
"Vale.SHA.SHA_helpers.to_uint32",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3))) | false | true | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val _sigma1_quad32 (q: quad32) : quad32 | [] | Vale.SHA.SHA_helpers._sigma1_quad32 | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | q: Vale.Def.Types_s.quad32 -> Vale.Def.Types_s.quad32 | {
"end_col": 50,
"end_line": 418,
"start_col": 2,
"start_line": 415
} |
FStar.Pervasives.Lemma | val lemma_ws_computed_is_ws_opaque (b: block_w) (t: counter{t < size_k_w_256})
: Lemma (vv (ws_computed b t) == ws_opaque b t) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_ws_computed_is_ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (vv (ws_computed b t) == ws_opaque b t)
=
lemma_ws_computed_is_ws b t;
Pervasives.reveal_opaque (`%ws) ws;
() | val lemma_ws_computed_is_ws_opaque (b: block_w) (t: counter{t < size_k_w_256})
: Lemma (vv (ws_computed b t) == ws_opaque b t)
let lemma_ws_computed_is_ws_opaque (b: block_w) (t: counter{t < size_k_w_256})
: Lemma (vv (ws_computed b t) == ws_opaque b t) = | false | null | true | lemma_ws_computed_is_ws b t;
Pervasives.reveal_opaque (`%ws) ws;
() | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"Vale.SHA.SHA_helpers.block_w",
"Vale.SHA.SHA_helpers.counter",
"Prims.b2t",
"Prims.op_LessThan",
"Vale.SHA.SHA_helpers.size_k_w_256",
"Prims.unit",
"FStar.Pervasives.reveal_opaque",
"Spec.Hash.Definitions.sha2_alg",
"Spec.SHA2.block_w",
"Spec.SHA2.counter",
"Spec.SHA2.size_k_w",
"Spec.Hash.Definitions.word",
"Spec.SHA2.Lemmas.ws",
"Vale.SHA.SHA_helpers.lemma_ws_computed_is_ws",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"Vale.Def.Words_s.nat32",
"Vale.SHA.SHA_helpers.vv",
"Vale.SHA.SHA_helpers.ws_computed",
"Vale.SHA.SHA_helpers.ws_opaque",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
// Top-level proof for the SHA256_msg1 instruction
let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
=
sha256_msg1_spec_reveal ();
let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
let ws_computed (b:block_w) (t:counter{t < size_k_w_256}): Tot (UInt32.t) =
if t < block_word_length SHA2_256 then to_uint32 (ws_opaque b t)
else
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
let open Lib.IntTypes in
(t16 +. s0 +. t7 +. s1)
#push-options "--max_fuel 1"
let lemma_ws_computed_is_ws (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (ws_computed b t == ws SHA2_256 b t)
=
Pervasives.reveal_opaque (`%ws) ws;
if t < block_word_length SHA2_256 then (
assert (vv (ws_computed b t) == ws_opaque b t);
assert (to_uint32 (ws_opaque b t) == ws SHA2_256 b t);
()
) else (
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
lemma_add_mod_ws_rearrangement s1 t7 s0 t16;
()
)
#pop-options
let lemma_ws_computed_is_ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (vv (ws_computed b t) == ws_opaque b t) | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val lemma_ws_computed_is_ws_opaque (b: block_w) (t: counter{t < size_k_w_256})
: Lemma (vv (ws_computed b t) == ws_opaque b t) | [] | Vale.SHA.SHA_helpers.lemma_ws_computed_is_ws_opaque | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Vale.SHA.SHA_helpers.block_w ->
t: Vale.SHA.SHA_helpers.counter{t < Vale.SHA.SHA_helpers.size_k_w_256}
-> FStar.Pervasives.Lemma
(ensures
Vale.SHA.SHA_helpers.vv (Vale.SHA.SHA_helpers.ws_computed b t) ==
Vale.SHA.SHA_helpers.ws_opaque b t) | {
"end_col": 4,
"end_line": 516,
"start_col": 2,
"start_line": 514
} |
Prims.Tot | val update_block (hash:hash256) (block:block_w): hash256 | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1 | val update_block (hash:hash256) (block:block_w): hash256
let update_block (hash: hash256) (block: block_w) : Tot (hash256) = | false | null | false | let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in Spec.Loops.seq_map2 ( +. ) hash hash_1 | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"total"
] | [
"Vale.SHA.SHA_helpers.hash256",
"Vale.SHA.SHA_helpers.block_w",
"Spec.Loops.seq_map2",
"Vale.SHA.SHA_helpers.word",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.SHA2_256",
"Lib.IntTypes.op_Plus_Dot",
"Lib.IntTypes.U32",
"Lib.IntTypes.SEC",
"Spec.Hash.Definitions.words_state",
"Vale.SHA.SHA_helpers.shuffle_opaque"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
// Top-level proof for the SHA256_msg1 instruction
let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
=
sha256_msg1_spec_reveal ();
let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
let ws_computed (b:block_w) (t:counter{t < size_k_w_256}): Tot (UInt32.t) =
if t < block_word_length SHA2_256 then to_uint32 (ws_opaque b t)
else
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
let open Lib.IntTypes in
(t16 +. s0 +. t7 +. s1)
#push-options "--max_fuel 1"
let lemma_ws_computed_is_ws (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (ws_computed b t == ws SHA2_256 b t)
=
Pervasives.reveal_opaque (`%ws) ws;
if t < block_word_length SHA2_256 then (
assert (vv (ws_computed b t) == ws_opaque b t);
assert (to_uint32 (ws_opaque b t) == ws SHA2_256 b t);
()
) else (
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
lemma_add_mod_ws_rearrangement s1 t7 s0 t16;
()
)
#pop-options
let lemma_ws_computed_is_ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (vv (ws_computed b t) == ws_opaque b t)
=
lemma_ws_computed_is_ws b t;
Pervasives.reveal_opaque (`%ws) ws;
()
let ws_computed_quad32 (t:counter{t < size_k_w_256 - 3}) (block:block_w) : quad32 =
Mkfour (vv (ws_computed block t))
(vv (ws_computed block (t+1)))
(vv (ws_computed block (t+2)))
(vv (ws_computed block (t+3)))
let lemma_ws_computed_is_ws_quad32 (b:block_w) (t:counter{t < size_k_w_256 - 3}) :
Lemma (ws_computed_quad32 t b == ws_quad32 t b)
=
let w = ws_computed_quad32 t b in
let w' = ws_quad32 t b in
lemma_ws_computed_is_ws_opaque b t;
lemma_ws_computed_is_ws_opaque b (t+1);
lemma_ws_computed_is_ws_opaque b (t+2);
lemma_ws_computed_is_ws_opaque b (t+3);
()
#push-options "--z3rlimit 30"
let lemma_ws_computed_quad32 (t:counter{16 <= t /\ t < size_k_w_256 - 4}) (block:block_w) :
Lemma (let t_minus_16 = ws_quad32 (t-16) block in
let t_minus_15 = ws_quad32 (t-15) block in
let t_minus_7 = ws_quad32 (t - 7) block in
let t_minus_2 = ws_quad32 (t - 2) block in
let m1 = add_mod_quad32 t_minus_16 (_sigma0_quad32 t_minus_15) in
let m2 = add_mod_quad32 m1 t_minus_7 in
let m3 = add_mod_quad32 m2 (_sigma1_quad32 t_minus_2) in
m3 == ws_computed_quad32 t block )
=
()
#pop-options
let sha256_msg1_spec_t (t:counter{t < size_k_w_256 - 1}) (block:block_w) : quad32 =
let init = ws_quad32 t block in
let next = ws_quad32 (t + 1) block in
let msg1 = add_mod_quad32 init (_sigma0_quad32 next) in
msg1
#push-options "--ifuel 1"
let lemma_sha256_msg1_spec_t_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 - 3)
(ensures ws_partial t block == sha256_msg1_spec_t (t-16) block)
=
ws_partial_reveal ();
let init = ws_quad32 (t-16) block in
let next = ws_quad32 (t-15) block in
lemma_add_wrap_quad32_is_add_mod_quad32 init (_sigma0_quad32 next);
()
#pop-options
let lemma_sha256_msg1_spec_t (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w_256 - 4 /\
src1 == ws_quad32 t block /\
src2.lo0 == ws_opaque block (t+4))
(ensures sha256_msg1_spec_t t block == sha256_msg1_spec src1 src2)
=
sha256_msg1_spec_reveal ();
()
#push-options "--z3rlimit 70"
let lemma_sha256_step2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1) /\
(let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
src1 == add_mod_quad32 w mid))
(ensures sha256_msg2_spec src1 src2 == ws_computed_quad32 t block)
=
sha256_msg2_spec_reveal ();
let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
let final = sha256_msg2_spec src1 src2 in
lemma_ws_computed_is_ws_opaque block (t);
lemma_ws_computed_is_ws_opaque block (t+1);
()
#pop-options
// Top-level proof for the SHA256_msg2 instruction
let lemma_sha256_msg2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
(let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
src1 == add_wrap_quad32 step1 t_minus_7 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1)))
(ensures sha256_msg2_spec src1 src2 == ws_quad32 t block)
=
let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
lemma_sha256_msg1_spec_t_partial t block;
// ==> step1 == sha256_msg1_spec_t (t-16) block
lemma_add_wrap_quad32_is_add_mod_quad32 step1 t_minus_7;
lemma_sha256_step2 src1 src2 t block;
lemma_ws_computed_is_ws_quad32 block t;
()
(* Abbreviations and lemmas for the code itself *)
#reset-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block qs
=
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32);
reveal_opaque (`%ws) ws
#reset-options "--max_fuel 0 --max_ifuel 0"
let translate_hash_update (h0 h1 h0' h1' a0 a1:quad32) : Lemma
(requires h0' == add_wrap_quad32 a0 h0 /\
h1' == add_wrap_quad32 a1 h1)
(ensures (
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
mapped == h'))
=
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
assert (equal mapped h');
()
unfold let shuffle_opaque = shuffle | false | true | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val update_block (hash:hash256) (block:block_w): hash256 | [] | Vale.SHA.SHA_helpers.update_block | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | hash: Vale.SHA.SHA_helpers.hash256 -> block: Vale.SHA.SHA_helpers.block_w
-> Vale.SHA.SHA_helpers.hash256 | {
"end_col": 40,
"end_line": 652,
"start_col": 64,
"start_line": 649
} |
Prims.Tot | val make_hash_def (abef cdgh: quad32)
: (hash:
words_state SHA2_256
{ length hash == 8 /\ hash.[ 0 ] == to_uint32 abef.hi3 /\ hash.[ 1 ] == to_uint32 abef.hi2 /\
hash.[ 2 ] == to_uint32 cdgh.hi3 /\ hash.[ 3 ] == to_uint32 cdgh.hi2 /\
hash.[ 4 ] == to_uint32 abef.lo1 /\ hash.[ 5 ] == to_uint32 abef.lo0 /\
hash.[ 6 ] == to_uint32 cdgh.lo1 /\ hash.[ 7 ] == to_uint32 cdgh.lo0 }) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash | val make_hash_def (abef cdgh: quad32)
: (hash:
words_state SHA2_256
{ length hash == 8 /\ hash.[ 0 ] == to_uint32 abef.hi3 /\ hash.[ 1 ] == to_uint32 abef.hi2 /\
hash.[ 2 ] == to_uint32 cdgh.hi3 /\ hash.[ 3 ] == to_uint32 cdgh.hi2 /\
hash.[ 4 ] == to_uint32 abef.lo1 /\ hash.[ 5 ] == to_uint32 abef.lo0 /\
hash.[ 6 ] == to_uint32 cdgh.lo1 /\ hash.[ 7 ] == to_uint32 cdgh.lo0 })
let make_hash_def (abef cdgh: quad32)
: (hash:
words_state SHA2_256
{ length hash == 8 /\ hash.[ 0 ] == to_uint32 abef.hi3 /\ hash.[ 1 ] == to_uint32 abef.hi2 /\
hash.[ 2 ] == to_uint32 cdgh.hi3 /\ hash.[ 3 ] == to_uint32 cdgh.hi2 /\
hash.[ 4 ] == to_uint32 abef.lo1 /\ hash.[ 5 ] == to_uint32 abef.lo0 /\
hash.[ 6 ] == to_uint32 cdgh.lo1 /\ hash.[ 7 ] == to_uint32 cdgh.lo0 }) = | false | null | false | let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"total"
] | [
"Vale.Def.Types_s.quad32",
"Prims.unit",
"FStar.Seq.Properties.elim_of_list",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.SHA2_256",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"FStar.Seq.Base.seq",
"Prims.b2t",
"Prims.op_Equality",
"Prims.nat",
"FStar.List.Tot.Base.length",
"FStar.Seq.Properties.seq_of_list",
"Prims.list",
"Prims.Cons",
"Prims.Nil",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.SEC",
"Vale.SHA.SHA_helpers.to_uint32",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0",
"Vale.Def.Types_s.nat32",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Spec.Hash.Definitions.words_state",
"Prims.l_and",
"FStar.UInt32.t",
"Spec.SHA2.op_String_Access"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\ | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val make_hash_def (abef cdgh: quad32)
: (hash:
words_state SHA2_256
{ length hash == 8 /\ hash.[ 0 ] == to_uint32 abef.hi3 /\ hash.[ 1 ] == to_uint32 abef.hi2 /\
hash.[ 2 ] == to_uint32 cdgh.hi3 /\ hash.[ 3 ] == to_uint32 cdgh.hi2 /\
hash.[ 4 ] == to_uint32 abef.lo1 /\ hash.[ 5 ] == to_uint32 abef.lo0 /\
hash.[ 6 ] == to_uint32 cdgh.lo1 /\ hash.[ 7 ] == to_uint32 cdgh.lo0 }) | [] | Vale.SHA.SHA_helpers.make_hash_def | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | abef: Vale.Def.Types_s.quad32 -> cdgh: Vale.Def.Types_s.quad32
-> hash:
Spec.Hash.Definitions.words_state Spec.Hash.Definitions.SHA2_256
{ FStar.Seq.Base.length hash == 8 /\
hash.[ 0 ] == Vale.SHA.SHA_helpers.to_uint32 (Mkfour?.hi3 abef) /\
hash.[ 1 ] == Vale.SHA.SHA_helpers.to_uint32 (Mkfour?.hi2 abef) /\
hash.[ 2 ] == Vale.SHA.SHA_helpers.to_uint32 (Mkfour?.hi3 cdgh) /\
hash.[ 3 ] == Vale.SHA.SHA_helpers.to_uint32 (Mkfour?.hi2 cdgh) /\
hash.[ 4 ] == Vale.SHA.SHA_helpers.to_uint32 (Mkfour?.lo1 abef) /\
hash.[ 5 ] == Vale.SHA.SHA_helpers.to_uint32 (Mkfour?.lo0 abef) /\
hash.[ 6 ] == Vale.SHA.SHA_helpers.to_uint32 (Mkfour?.lo1 cdgh) /\
hash.[ 7 ] == Vale.SHA.SHA_helpers.to_uint32 (Mkfour?.lo0 cdgh) } | {
"end_col": 8,
"end_line": 85,
"start_col": 9,
"start_line": 71
} |
FStar.Pervasives.Lemma | val lemma_add_mod_a (a b c d e f g h wk: UInt32.t)
: Lemma
(let u =
add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))))
in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
() | val lemma_add_mod_a (a b c d e f g h wk: UInt32.t)
: Lemma
(let u =
add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))))
in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
let lemma_add_mod_a (a b c d e f g h wk: UInt32.t)
: Lemma
(let u =
add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))))
in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core) = | false | null | true | let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk))
h
(add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core ==
add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk))
(add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e))
wk
(add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core ==
add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e))
(add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g)
(_Sigma1 SHA2_256 e)
(add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
() | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"FStar.UInt32.t",
"Prims.unit",
"Vale.SHA.SHA_helpers.lemma_add_mod_associates_U32",
"Spec.SHA2._Ch",
"Spec.Hash.Definitions.SHA2_256",
"Spec.SHA2._Sigma1",
"FStar.UInt32.add_mod",
"Spec.SHA2._Maj",
"Spec.SHA2._Sigma0",
"Prims._assert",
"Prims.eq2",
"Vale.SHA.SHA_helpers.lemma_add_mod_commutes",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val lemma_add_mod_a (a b c d e f g h wk: UInt32.t)
: Lemma
(let u =
add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))))
in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core) | [] | Vale.SHA.SHA_helpers.lemma_add_mod_a | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: FStar.UInt32.t ->
b: FStar.UInt32.t ->
c: FStar.UInt32.t ->
d: FStar.UInt32.t ->
e: FStar.UInt32.t ->
f: FStar.UInt32.t ->
g: FStar.UInt32.t ->
h: FStar.UInt32.t ->
wk: FStar.UInt32.t
-> FStar.Pervasives.Lemma
(ensures
(let u97 =
FStar.UInt32.add_mod (Spec.SHA2._Ch Spec.Hash.Definitions.SHA2_256 e f g)
(FStar.UInt32.add_mod (Spec.SHA2._Sigma1 Spec.Hash.Definitions.SHA2_256 e)
(FStar.UInt32.add_mod wk
(FStar.UInt32.add_mod h
(FStar.UInt32.add_mod (Spec.SHA2._Maj Spec.Hash.Definitions.SHA2_256 a b c)
(Spec.SHA2._Sigma0 Spec.Hash.Definitions.SHA2_256 a)))))
in
let t1 =
FStar.UInt32.add_mod h
(FStar.UInt32.add_mod (Spec.SHA2._Sigma1 Spec.Hash.Definitions.SHA2_256 e)
(FStar.UInt32.add_mod (Spec.SHA2._Ch Spec.Hash.Definitions.SHA2_256 e f g) wk))
in
let t2 =
FStar.UInt32.add_mod (Spec.SHA2._Sigma0 Spec.Hash.Definitions.SHA2_256 a)
(Spec.SHA2._Maj Spec.Hash.Definitions.SHA2_256 a b c)
in
let core = FStar.UInt32.add_mod t1 t2 in
u97 == core)) | {
"end_col": 4,
"end_line": 255,
"start_col": 3,
"start_line": 238
} |
FStar.Pervasives.Lemma | val lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
() | val lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
let lemma_sha256_rnds2 (abef cdgh xmm0: quad32) (t: counter) (block: block_w) (hash_in: hash256)
: Lemma
(requires
t + 1 < size_k_w_256 /\ xmm0.lo0 == add_wrap (word_to_nat32 k.[ t ]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[ t + 1 ]) (ws_opaque block (t + 1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in)
(ensures
make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t + 2) (shuffle_core_opaque block) hash_in) = | false | null | true | lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[ t ]) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[ t + 1 ]) (ws_opaque block (t + 1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
() | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"Vale.Def.Types_s.quad32",
"Vale.SHA.SHA_helpers.counter",
"Vale.SHA.SHA_helpers.block_w",
"Vale.SHA.SHA_helpers.hash256",
"Prims.unit",
"Spec.Loops.repeat_range_induction",
"Prims.op_Addition",
"Vale.SHA.SHA_helpers.shuffle_core_opaque",
"Vale.SHA.SHA_helpers.lemma_sha256_rnds2_two_steps",
"Vale.SHA.SHA_helpers.lemma_add_wrap_is_add_mod",
"Vale.SHA.SHA_helpers.vv",
"Spec.SHA2.op_String_Access",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.SHA2_256",
"Spec.SHA2.k0",
"Vale.SHA.SHA_helpers.ws_opaque",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Vale.SHA.SHA_helpers.size_k_w_256",
"Prims.eq2",
"Vale.Def.Words_s.natN",
"Vale.Def.Words_s.pow2_32",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0",
"Vale.Def.Types_s.nat32",
"Vale.Def.Types_s.add_wrap",
"Vale.SHA.SHA_helpers.word_to_nat32",
"Vale.SHA.SHA_helpers.word",
"Vale.SHA.SHA_helpers.k",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Vale.SHA.SHA_helpers.make_hash",
"Spec.Loops.repeat_range",
"Prims.squash",
"Vale.X64.CryptoInstructions_s.sha256_rnds2_spec",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in) | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in) | [] | Vale.SHA.SHA_helpers.lemma_sha256_rnds2 | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
abef: Vale.Def.Types_s.quad32 ->
cdgh: Vale.Def.Types_s.quad32 ->
xmm0: Vale.Def.Types_s.quad32 ->
t: Vale.SHA.SHA_helpers.counter ->
block: Vale.SHA.SHA_helpers.block_w ->
hash_in: Vale.SHA.SHA_helpers.hash256
-> FStar.Pervasives.Lemma
(requires
t + 1 < Vale.SHA.SHA_helpers.size_k_w_256 /\
Mkfour?.lo0 xmm0 ==
Vale.Def.Types_s.add_wrap (Vale.SHA.SHA_helpers.word_to_nat32 Vale.SHA.SHA_helpers.k.[ t ])
(Vale.SHA.SHA_helpers.ws_opaque block t) /\
Mkfour?.lo1 xmm0 ==
Vale.Def.Types_s.add_wrap (Vale.SHA.SHA_helpers.word_to_nat32 Vale.SHA.SHA_helpers.k.[ t + 1
])
(Vale.SHA.SHA_helpers.ws_opaque block (t + 1)) /\
Vale.SHA.SHA_helpers.make_hash abef cdgh ==
Spec.Loops.repeat_range 0 t (Vale.SHA.SHA_helpers.shuffle_core_opaque block) hash_in)
(ensures
Vale.SHA.SHA_helpers.make_hash (Vale.X64.CryptoInstructions_s.sha256_rnds2_spec cdgh
abef
xmm0)
abef ==
Spec.Loops.repeat_range 0 (t + 2) (Vale.SHA.SHA_helpers.shuffle_core_opaque block) hash_in) | {
"end_col": 4,
"end_line": 405,
"start_col": 2,
"start_line": 400
} |
FStar.Pervasives.Lemma | val sha256_rnds2_spec_quad32_is_shuffle_core_x2
(abef cdgh wk: quad32)
(block: block_w)
(t: counter{t < size_k_w_256 - 1})
: Lemma
(requires
wk.lo0 == add_mod32 (k0 SHA2_256).[ t ] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[ t + 1 ] (ws_opaque block (t + 1)))
(ensures
(let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef)) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
() | val sha256_rnds2_spec_quad32_is_shuffle_core_x2
(abef cdgh wk: quad32)
(block: block_w)
(t: counter{t < size_k_w_256 - 1})
: Lemma
(requires
wk.lo0 == add_mod32 (k0 SHA2_256).[ t ] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[ t + 1 ] (ws_opaque block (t + 1)))
(ensures
(let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
let sha256_rnds2_spec_quad32_is_shuffle_core_x2
(abef cdgh wk: quad32)
(block: block_w)
(t: counter{t < size_k_w_256 - 1})
: Lemma
(requires
wk.lo0 == add_mod32 (k0 SHA2_256).[ t ] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[ t + 1 ] (ws_opaque block (t + 1)))
(ensures
(let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef)) = | false | null | true | lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
() | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"Vale.Def.Types_s.quad32",
"Vale.SHA.SHA_helpers.block_w",
"Vale.SHA.SHA_helpers.counter",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_Subtraction",
"Vale.SHA.SHA_helpers.size_k_w_256",
"Prims.unit",
"Vale.SHA.SHA_helpers.sha256_rnds2_spec_update_quad32_x2_shifts",
"Vale.SHA.SHA_helpers.to_uint32",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0",
"Vale.Def.Types_s.nat32",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Vale.SHA.SHA_helpers.lemma_rnds2_spec_quad32_is_shuffle_core_x2",
"Prims.l_and",
"Prims.eq2",
"Vale.Def.Words_s.nat32",
"Vale.SHA.SHA_helpers.add_mod32",
"Spec.SHA2.op_String_Access",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.SHA2_256",
"Spec.SHA2.k0",
"Vale.SHA.SHA_helpers.ws_opaque",
"Prims.op_Addition",
"Prims.squash",
"Vale.SHA.SHA_helpers.hash256",
"Vale.SHA.SHA_helpers.make_hash",
"Vale.SHA.SHA_helpers.sha256_rnds2_spec_quad32",
"Vale.SHA.SHA_helpers.shuffle_core_opaque",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef)) | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val sha256_rnds2_spec_quad32_is_shuffle_core_x2
(abef cdgh wk: quad32)
(block: block_w)
(t: counter{t < size_k_w_256 - 1})
: Lemma
(requires
wk.lo0 == add_mod32 (k0 SHA2_256).[ t ] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[ t + 1 ] (ws_opaque block (t + 1)))
(ensures
(let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef)) | [] | Vale.SHA.SHA_helpers.sha256_rnds2_spec_quad32_is_shuffle_core_x2 | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
abef: Vale.Def.Types_s.quad32 ->
cdgh: Vale.Def.Types_s.quad32 ->
wk: Vale.Def.Types_s.quad32 ->
block: Vale.SHA.SHA_helpers.block_w ->
t: Vale.SHA.SHA_helpers.counter{t < Vale.SHA.SHA_helpers.size_k_w_256 - 1}
-> FStar.Pervasives.Lemma
(requires
Mkfour?.lo0 wk ==
Vale.SHA.SHA_helpers.add_mod32 (Spec.SHA2.k0 Spec.Hash.Definitions.SHA2_256).[ t ]
(Vale.SHA.SHA_helpers.ws_opaque block t) /\
Mkfour?.lo1 wk ==
Vale.SHA.SHA_helpers.add_mod32 (Spec.SHA2.k0 Spec.Hash.Definitions.SHA2_256).[ t + 1 ]
(Vale.SHA.SHA_helpers.ws_opaque block (t + 1)))
(ensures
(let hash0 = Vale.SHA.SHA_helpers.make_hash abef cdgh in
let hash1 = Vale.SHA.SHA_helpers.shuffle_core_opaque block hash0 t in
let hash2 = Vale.SHA.SHA_helpers.shuffle_core_opaque block hash1 (t + 1) in
let abef' = Vale.SHA.SHA_helpers.sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == Vale.SHA.SHA_helpers.make_hash abef' abef)) | {
"end_col": 4,
"end_line": 370,
"start_col": 2,
"start_line": 368
} |
FStar.Pervasives.Lemma | val lemma_le_bytes_to_hash_quads_part1 (s: seq quad32)
: Lemma (requires length s == 2)
(ensures
le_bytes_to_hash (le_seq_quad32_to_bytes s) ==
Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s)) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_le_bytes_to_hash_quads_part1 (s:seq quad32) : Lemma
(requires length s == 2)
(ensures le_bytes_to_hash (le_seq_quad32_to_bytes s) ==
Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s))
=
let lhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
assert (lhs == Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)));
le_seq_quad32_to_bytes_reveal ();
Vale.Def.Words.Seq.seq_nat8_to_seq_nat32_to_seq_nat8_LE (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s);
() | val lemma_le_bytes_to_hash_quads_part1 (s: seq quad32)
: Lemma (requires length s == 2)
(ensures
le_bytes_to_hash (le_seq_quad32_to_bytes s) ==
Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s))
let lemma_le_bytes_to_hash_quads_part1 (s: seq quad32)
: Lemma (requires length s == 2)
(ensures
le_bytes_to_hash (le_seq_quad32_to_bytes s) ==
Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s)) = | false | null | true | let lhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
assert (lhs ==
Vale.Lib.Seqs_s.seq_map nat32_to_word
(Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)));
le_seq_quad32_to_bytes_reveal ();
Vale.Def.Words.Seq.seq_nat8_to_seq_nat32_to_seq_nat8_LE (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s);
() | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.quad32",
"Prims.unit",
"Vale.Def.Words.Seq.seq_nat8_to_seq_nat32_to_seq_nat8_LE",
"Vale.Def.Words.Seq_s.seq_four_to_seq_LE",
"Vale.Def.Types_s.nat32",
"Vale.Def.Types_s.le_seq_quad32_to_bytes_reveal",
"Prims._assert",
"Prims.eq2",
"Vale.SHA.SHA_helpers.word",
"Vale.Lib.Seqs_s.seq_map",
"Vale.Def.Words_s.nat32",
"Vale.SHA.SHA_helpers.nat32_to_word",
"Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE",
"Vale.Def.Types_s.le_seq_quad32_to_bytes",
"Vale.SHA.SHA_helpers.hash256",
"Vale.SHA.SHA_helpers.le_bytes_to_hash",
"Prims.int",
"FStar.Seq.Base.length",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
// Top-level proof for the SHA256_msg1 instruction
let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
=
sha256_msg1_spec_reveal ();
let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
let ws_computed (b:block_w) (t:counter{t < size_k_w_256}): Tot (UInt32.t) =
if t < block_word_length SHA2_256 then to_uint32 (ws_opaque b t)
else
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
let open Lib.IntTypes in
(t16 +. s0 +. t7 +. s1)
#push-options "--max_fuel 1"
let lemma_ws_computed_is_ws (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (ws_computed b t == ws SHA2_256 b t)
=
Pervasives.reveal_opaque (`%ws) ws;
if t < block_word_length SHA2_256 then (
assert (vv (ws_computed b t) == ws_opaque b t);
assert (to_uint32 (ws_opaque b t) == ws SHA2_256 b t);
()
) else (
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
lemma_add_mod_ws_rearrangement s1 t7 s0 t16;
()
)
#pop-options
let lemma_ws_computed_is_ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (vv (ws_computed b t) == ws_opaque b t)
=
lemma_ws_computed_is_ws b t;
Pervasives.reveal_opaque (`%ws) ws;
()
let ws_computed_quad32 (t:counter{t < size_k_w_256 - 3}) (block:block_w) : quad32 =
Mkfour (vv (ws_computed block t))
(vv (ws_computed block (t+1)))
(vv (ws_computed block (t+2)))
(vv (ws_computed block (t+3)))
let lemma_ws_computed_is_ws_quad32 (b:block_w) (t:counter{t < size_k_w_256 - 3}) :
Lemma (ws_computed_quad32 t b == ws_quad32 t b)
=
let w = ws_computed_quad32 t b in
let w' = ws_quad32 t b in
lemma_ws_computed_is_ws_opaque b t;
lemma_ws_computed_is_ws_opaque b (t+1);
lemma_ws_computed_is_ws_opaque b (t+2);
lemma_ws_computed_is_ws_opaque b (t+3);
()
#push-options "--z3rlimit 30"
let lemma_ws_computed_quad32 (t:counter{16 <= t /\ t < size_k_w_256 - 4}) (block:block_w) :
Lemma (let t_minus_16 = ws_quad32 (t-16) block in
let t_minus_15 = ws_quad32 (t-15) block in
let t_minus_7 = ws_quad32 (t - 7) block in
let t_minus_2 = ws_quad32 (t - 2) block in
let m1 = add_mod_quad32 t_minus_16 (_sigma0_quad32 t_minus_15) in
let m2 = add_mod_quad32 m1 t_minus_7 in
let m3 = add_mod_quad32 m2 (_sigma1_quad32 t_minus_2) in
m3 == ws_computed_quad32 t block )
=
()
#pop-options
let sha256_msg1_spec_t (t:counter{t < size_k_w_256 - 1}) (block:block_w) : quad32 =
let init = ws_quad32 t block in
let next = ws_quad32 (t + 1) block in
let msg1 = add_mod_quad32 init (_sigma0_quad32 next) in
msg1
#push-options "--ifuel 1"
let lemma_sha256_msg1_spec_t_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 - 3)
(ensures ws_partial t block == sha256_msg1_spec_t (t-16) block)
=
ws_partial_reveal ();
let init = ws_quad32 (t-16) block in
let next = ws_quad32 (t-15) block in
lemma_add_wrap_quad32_is_add_mod_quad32 init (_sigma0_quad32 next);
()
#pop-options
let lemma_sha256_msg1_spec_t (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w_256 - 4 /\
src1 == ws_quad32 t block /\
src2.lo0 == ws_opaque block (t+4))
(ensures sha256_msg1_spec_t t block == sha256_msg1_spec src1 src2)
=
sha256_msg1_spec_reveal ();
()
#push-options "--z3rlimit 70"
let lemma_sha256_step2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1) /\
(let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
src1 == add_mod_quad32 w mid))
(ensures sha256_msg2_spec src1 src2 == ws_computed_quad32 t block)
=
sha256_msg2_spec_reveal ();
let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
let final = sha256_msg2_spec src1 src2 in
lemma_ws_computed_is_ws_opaque block (t);
lemma_ws_computed_is_ws_opaque block (t+1);
()
#pop-options
// Top-level proof for the SHA256_msg2 instruction
let lemma_sha256_msg2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
(let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
src1 == add_wrap_quad32 step1 t_minus_7 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1)))
(ensures sha256_msg2_spec src1 src2 == ws_quad32 t block)
=
let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
lemma_sha256_msg1_spec_t_partial t block;
// ==> step1 == sha256_msg1_spec_t (t-16) block
lemma_add_wrap_quad32_is_add_mod_quad32 step1 t_minus_7;
lemma_sha256_step2 src1 src2 t block;
lemma_ws_computed_is_ws_quad32 block t;
()
(* Abbreviations and lemmas for the code itself *)
#reset-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block qs
=
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32);
reveal_opaque (`%ws) ws
#reset-options "--max_fuel 0 --max_ifuel 0"
let translate_hash_update (h0 h1 h0' h1' a0 a1:quad32) : Lemma
(requires h0' == add_wrap_quad32 a0 h0 /\
h1' == add_wrap_quad32 a1 h1)
(ensures (
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
mapped == h'))
=
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
assert (equal mapped h');
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_lemma (src1 src2 src1' src2' h0 h1:quad32) (block:block_w) : Lemma
(requires (let hash_orig = make_hash h0 h1 in
make_hash src1 src2 ==
Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash_orig /\
src1' == add_wrap_quad32 src1 h0 /\
src2' == add_wrap_quad32 src2 h1))
(ensures (let hash_orig = make_hash h0 h1 in
make_hash src1' src2' == update_block hash_orig block))
=
let hash_orig = make_hash h0 h1 in
let hash_1 = shuffle_opaque SHA2_256 hash_orig block in
Pervasives.reveal_opaque (`%shuffle) shuffle;
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let rec f (i:nat{i <= 64}) : Lemma (
Spec.Loops.repeat_range 0 i (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 i (shuffle_core SHA2_256 block) hash_orig)
=
if i = 0 then (
Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_base 0 (shuffle_core SHA2_256 block) hash_orig
) else (
f (i - 1);
Spec.Loops.repeat_range_induction 0 i (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_induction 0 i (shuffle_core SHA2_256 block) hash_orig
)
in
f 64;
(*
let h = make_hash src1 src2 in
assert (forall (block:block_w) (hash:hash256) . FStar.FunctionalExtensionality.feq (shuffle_core_opaque block hash) (shuffle_core_opaque_aux SHA2_256 block hash));
//assert (forall (block:block_w) . (shuffle_core_opaque block) == (shuffle_core_opaque_aux SHA2_256 block));
assert (shuffle_core_opaque == shuffle_core_opaque_aux SHA2_256);
assert (shuffle_core_opaque == shuffle_core SHA2_256);
assert (shuffle_core_opaque block == shuffle_core SHA2_256 block);
assert (Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 64 (shuffle_core SHA2_256 block) hash_orig);
assert (make_hash src1 src2 == shuffle SHA2_256 hash_orig block);
assert (make_hash src1 src2 == shuffle_opaque SHA2_256 hash_orig block);
*)
translate_hash_update src1 src2 src1' src2' h0 h1;
shuffle_is_shuffle_pre SHA2_256 hash_orig block;
assert (equal (make_hash src1' src2') (update_block hash_orig block));
()
let lemma_le_bytes_to_seq_quad32_empty (b:seq nat8) : Lemma
(requires b == empty)
(ensures le_bytes_to_seq_quad32 b == empty)
=
reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32;
assert (equal (le_bytes_to_seq_quad32 b) empty)
let lemma_le_bytes_to_seq_quad32_length (b:seq nat8) : Lemma
(requires length b % 16 == 0)
(ensures length (le_bytes_to_seq_quad32 b) == length b / 16)
=
reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32;
()
#push-options "--max_fuel 1" // Without this, F* refuses to do even one unfolding of recursive functions :(
let lemma_slice_commutes_reverse_bytes_nat32_quad32_seq (s:seq quad32) (pivot:nat) : Lemma
(requires pivot <= length s)
(ensures slice (reverse_bytes_nat32_quad32_seq s) 0 pivot == reverse_bytes_nat32_quad32_seq (slice s 0 pivot))
=
let rs = reverse_bytes_nat32_quad32_seq s in
let srs = slice (reverse_bytes_nat32_quad32_seq s) 0 pivot in
let ss = slice s 0 pivot in
let rss = reverse_bytes_nat32_quad32_seq ss in
if pivot = 0 then (
assert (equal ss empty);
assert (equal srs empty);
assert (equal empty (reverse_bytes_nat32_quad32_seq empty));
()
) else (
assert (equal srs rss)
)
// One level of expansion that we can use in places that can't use fuel
let lemma_update_multi_quads_unfold (s:seq quad32) (hash_orig:hash256) : Lemma
(requires length s >= 4)
(ensures (let prefix, qs = split s (length s - 4) in
let h_prefix = update_multi_quads prefix hash_orig in
let hash = update_block h_prefix (quads_to_block qs) in
update_multi_quads s hash_orig == hash))
=
()
let lemma_update_multi_quads_short (s:seq quad32) (hash_orig:hash256) : Lemma
(requires length s < 4)
(ensures update_multi_quads s hash_orig == hash_orig)
=
()
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
#pop-options
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 40"
let lemma_endian_relation (quads qs:seq quad32) (input2:seq UInt8.t) : Lemma
(requires length qs == 4 /\ length input2 == 64 /\
qs == reverse_bytes_nat32_quad32_seq quads /\
input2 == seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads))
(ensures quads_to_block qs == words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2)
=
let fi (i:nat{i < length (quads_to_block qs)}) : Lemma
((quads_to_block qs).[i] == (words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2).[i])
=
let open Vale.Def.Words.Four_s in
let open Vale.Lib.Seqs_s in
let ni = (seq_four_to_seq_LE quads).[i] in
let b = slice input2 (4 * i) (4 * i + 4) in
// FStar.Krml.Endianness.lemma_be_to_n_is_bounded b;
calc (==) {
b;
== {}
slice input2 (4 * i) (4 * i + 4);
== {}
slice (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) (4 * i) (4 * i + 4);
== {le_seq_quad32_to_bytes_reveal ()}
slice (seq_nat8_to_seq_uint8 (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE quads))) (4 * i) (4 * i + 4);
equal {}
seq_nat8_to_seq_uint8 (slice (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE quads)) (4 * i) (4 * i + 4));
== {}
seq_nat8_to_seq_uint8 (slice (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE quads))) (4 * i) (4 * i + 4));
== {slice_commutes_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE quads)) i (i + 1)}
seq_nat8_to_seq_uint8 (seq_four_to_seq_LE (slice (seq_map (nat_to_four 8) (seq_four_to_seq_LE quads)) i (i + 1)));
equal {reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat8)}
seq_nat8_to_seq_uint8 (four_to_seq_LE (nat_to_four 8 (seq_four_to_seq_LE quads).[i]));
};
let open Lib.IntTypes in
calc (==) {
(words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2).[i];
== { }
(Lib.ByteSequence.uints_from_bytes_be #U32 #SEC #(block_word_length SHA2_256) input2).[i];
== { Lib.ByteSequence.index_uints_from_bytes_be #U32 #SEC #(block_word_length SHA2_256) input2 i }
Lib.ByteSequence.uint_from_bytes_be (Lib.Sequence.sub #uint8 #64 input2 (i * 4) 4);
== { let open Lib.Sequence in
calc (==) {
sub #uint8 #64 input2 (i * 4) 4;
== { }
Seq.slice input2 (4 * i) (4 * i + 4);
}
}
Lib.ByteSequence.uint_from_bytes_be #U32 #SEC b;
== { calc (==) {
Lib.ByteSequence.nat_from_bytes_be #SEC b;
(==) { }
Lib.ByteSequence.nat_from_bytes_be #SEC (seq_nat8_to_seq_uint8 (four_to_seq_LE (nat_to_four 8 ni)));
(==) { lemma_be_to_n_4 (four_to_seq_LE (nat_to_four 8 ni)) }
be_bytes_to_nat32 (four_to_seq_LE (nat_to_four 8 ni));
};
v_inj (Lib.ByteSequence.uint_from_bytes_be #U32 #SEC b)
(u32 (be_bytes_to_nat32 (four_to_seq_LE (nat_to_four 8 ni))))
}
nat32_to_word (be_bytes_to_nat32 (four_to_seq_LE (nat_to_four 8 ni)));
== {}
nat32_to_word (be_bytes_to_nat32 (reverse_seq (nat32_to_be_bytes ni)));
== {reverse_bytes_nat32_reveal ()}
nat32_to_word (reverse_bytes_nat32 ni);
== {}
nat32_to_word (reverse_bytes_nat32 (seq_four_to_seq_LE quads).[i]);
== {reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32)}
nat32_to_word (seq_four_to_seq_LE qs).[i];
== {}
(quads_to_block qs).[i];
}
in
FStar.Classical.forall_intro fi;
assert (equal (quads_to_block qs) (words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2))
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
#reset-options "--max_fuel 0 --ifuel 1 --z3rlimit 20"
let rec lemma_update_multi_equiv_vale (hash hash':hash256) (quads:seq quad32) (r_quads:seq quad32)
(nat8s:seq nat8) (blocks:seq UInt8.t) :
Lemma (requires length quads % 4 == 0 /\
r_quads == reverse_bytes_nat32_quad32_seq quads /\
nat8s == le_seq_quad32_to_bytes quads /\
blocks == seq_nat8_to_seq_uint8 nat8s /\
hash' == update_multi_quads r_quads hash)
(ensures
length blocks % 64 == 0 /\
hash' == update_multi_opaque_vale hash blocks)
(decreases (length quads))
=
lemma_mod_transform quads;
assert (length blocks % 64 == 0);
update_multi_reveal ();
if length quads = 0 then begin
lemma_le_seq_quad32_to_bytes_length quads;
//assert (length nat8s == 0);
//assert (length r_quads == 0);
lemma_update_multi_quads_short r_quads hash;
//assert (hash' == hash);
//assert (length blocks == 0);
assert (equal blocks empty);
update_multi_zero SHA2_256 hash;
//assert (update_multi SHA2_256 hash blocks == hash);
()
end else begin
let num_blocks = (length quads) / 4 in
let bytes_pivot = (num_blocks - 1) * 64 in
// Use associativity of update_multi to rearrange recursion to better match update_multi_quads' recursion
let input1,input2 = Lib.UpdateMulti.split_block block_length blocks (bytes_pivot / 64) in
let h_bytes1 = update_multi SHA2_256 hash () input1 in
let h_bytes2 = update_multi SHA2_256 h_bytes1 () input2 in
update_multi_associative SHA2_256 hash input1 input2;
assert (input1 `Seq.append` input2 == blocks);
Seq.lemma_eq_intro h_bytes2 (update_multi SHA2_256 hash () blocks);
assert (h_bytes2 == update_multi SHA2_256 hash () blocks);
// Unfold update_multi_quads one level, so we can start matching parts up
let prefix, qs = split r_quads (length r_quads - 4) in
let h_prefix = update_multi_quads prefix hash in
let h_final = update_block h_prefix (quads_to_block qs) in
lemma_update_multi_quads_unfold r_quads hash;
// hash' == update_multi_quads r_quads hash == h_final
(*+ Goal: h_bytes_2 == h_final +*)
(* Step 1: Show that h_prefix == h_bytes1 *)
// Inductive hypothesis says that we roughly line up on input1
let r_prefix = reverse_bytes_nat32_quad32_seq prefix in
lemma_update_multi_equiv_vale hash h_prefix r_prefix prefix
(le_seq_quad32_to_bytes r_prefix)
(seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes r_prefix));
assert (h_prefix == update_multi SHA2_256 hash () (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes r_prefix)));
// To show that h_prefix == h_bytes1, we need to show that:
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes r_prefix) == input1
// calc {
// input1
// slice blocks 0 bytes_pivot
// slice ( (le_seq_quad32_to_bytes quads)) 0 bytes_pivot
assert (equal (slice (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) 0 bytes_pivot)
(seq_nat8_to_seq_uint8 (slice (le_seq_quad32_to_bytes quads) 0 bytes_pivot)));
// seq_nat8_to_seq_U8 (slice (le_seq_quad32_to_bytes quads) 0 bytes_pivot)
slice_commutes_le_seq_quad32_to_bytes0 quads (bytes_pivot / 16);
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads 0 (bytes_pivot / 16)))
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads 0 ((num_blocks - 1) * 4)))
assert (bytes_pivot / 16 == length quads - 4);
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads 0 (length quads - 4)))
//
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads 0 (length quads - 4)))))
assert (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq (slice quads 0 (length quads - 4))) == slice quads 0 (length quads - 4));
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq (slice quads 0 (length quads - 4)))))
Vale.Lib.Seqs.slice_seq_map_commute reverse_bytes_nat32_quad32 quads 0 (length quads - 4);
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (reverse_bytes_nat32_quad32_seq (slice (reverse_bytes_nat32_quad32_seq quads) 0 (length quads - 4)))
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes r_prefix)
// }
// assert (seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes r_prefix) == input1); // Conclusion of the calc
assert (Seq.equal h_prefix h_bytes1); // Conclusion of Step 1
// To invoke lemma_endian_relation below,
// we need to show (1):
// calc {
// qs
Vale.Lib.Seqs.slice_seq_map_commute reverse_bytes_nat32_quad32 quads (length quads - 4) (length quads);
// slice (reverse_bytes_nat32_quad32_seq quads) (length quads - 4) (length quads))
// reverse_bytes_nat32_quad32_seq (slice quads (length quads - 4) (length quads))
// }
// And (2):
// calc {
// input2
// slice blocks bytes_pivot (length blocks)
// slice (seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes quads)) bytes_pivot (length blocks)
// assert (equal (slice (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) bytes_pivot (length blocks))
// (seq_nat8_to_seq_uint8 (slice (le_seq_quad32_to_bytes quads) bytes_pivot (length blocks))));
// seq_nat8_to_seq_U8 (slice (le_seq_quad32_to_bytes quads) bytes_pivot (length blocks))
slice_commutes_le_seq_quad32_to_bytes quads (bytes_pivot/16) ((length blocks)/16);
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads bytes_pivot/16 (length blocks)/16)
//
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads (length quads - 4) (length quads))))
// }
//assert (input2 == seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads (length quads - 4) (length quads)))); // Conclusion of the calc
(* Step 2: Show that update_block SHA2_256 h_prefix (quads_to_block qs) == update_multi SHA2_256 h_bytes1 input2 *)
// calc {
// update_block SHA2_256 h_prefix (quads_to_block qs)
// { from Step 1 }
// update_block SHA2_256 h_bytes1 (quads_to_block qs)
//
assert (equal input2 (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (slice quads (length quads - 4) (length quads)))));
lemma_endian_relation (slice quads (length quads - 4) (length quads)) qs
input2; // ==> quads_to_block qs == words_of_bytes SHA2_256 block_word_length input2
// update_block SHA2_256 h_bytes1 (words_of_bytes SHA2_256 16 input2)
lemma_update_block_equiv h_bytes1 input2;
// update SHA2_256 h_bytes1 input2
update_multi_one h_bytes1 input2;
// update_multi SHA2_256 h_bytes1 input2
// }
//
// assert (update_block SHA2_256 h_prefix (quads_to_block qs) == update_multi SHA2_256 h_bytes1 input2); // Conclusion of calc
// assert (h_final == h_bytes2); // Conclusion of Goal
()
end
//
#push-options "--max_fuel 1" // Without this, F* refuses to do even one unfolding of update_multi_quads :(
let lemma_update_multi_quads (s:seq quad32) (hash_orig:hash256) (bound:nat) : Lemma
(requires bound + 4 <= length s)
(ensures (let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_nat32_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_nat32_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound+4) in
let input_BE = reverse_bytes_nat32_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block block_quads_BE) in
h == update_multi_quads input_BE hash_orig))
=
let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_nat32_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_nat32_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound+4) in
let input_BE = reverse_bytes_nat32_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block block_quads_BE) in
lemma_slice_commutes_reverse_bytes_nat32_quad32_seq s bound;
lemma_slice_commutes_reverse_bytes_nat32_quad32_seq s (bound + 4);
assert (prefix_BE == slice (reverse_bytes_nat32_quad32_seq s) 0 bound);
assert (input_BE == slice (reverse_bytes_nat32_quad32_seq s) 0 (bound + 4));
if bound = 0 then ()
else (
let prefix, qs = split input_BE (length input_BE - 4) in
assert (equal prefix prefix_BE);
assert (equal qs block_quads_BE);
()
)
#pop-options
let lemma_le_bytes_to_hash_quads_part1 (s:seq quad32) : Lemma
(requires length s == 2)
(ensures le_bytes_to_hash (le_seq_quad32_to_bytes s) == | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": 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"
} | null | val lemma_le_bytes_to_hash_quads_part1 (s: seq quad32)
: Lemma (requires length s == 2)
(ensures
le_bytes_to_hash (le_seq_quad32_to_bytes s) ==
Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s)) | [] | Vale.SHA.SHA_helpers.lemma_le_bytes_to_hash_quads_part1 | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: FStar.Seq.Base.seq Vale.Def.Types_s.quad32
-> FStar.Pervasives.Lemma (requires FStar.Seq.Base.length s == 2)
(ensures
Vale.SHA.SHA_helpers.le_bytes_to_hash (Vale.Def.Types_s.le_seq_quad32_to_bytes s) ==
Vale.Lib.Seqs_s.seq_map Vale.SHA.SHA_helpers.nat32_to_word
(Vale.Def.Words.Seq_s.seq_four_to_seq_LE s)) | {
"end_col": 4,
"end_line": 1047,
"start_col": 3,
"start_line": 1042
} |
FStar.Pervasives.Lemma | val lemma_le_bytes_to_seq_quad32_length (b: seq nat8)
: Lemma (requires length b % 16 == 0)
(ensures length (le_bytes_to_seq_quad32 b) == length b / 16) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_le_bytes_to_seq_quad32_length (b:seq nat8) : Lemma
(requires length b % 16 == 0)
(ensures length (le_bytes_to_seq_quad32 b) == length b / 16)
=
reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32;
() | val lemma_le_bytes_to_seq_quad32_length (b: seq nat8)
: Lemma (requires length b % 16 == 0)
(ensures length (le_bytes_to_seq_quad32 b) == length b / 16)
let lemma_le_bytes_to_seq_quad32_length (b: seq nat8)
: Lemma (requires length b % 16 == 0)
(ensures length (le_bytes_to_seq_quad32 b) == length b / 16) = | false | null | true | reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32;
() | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"FStar.Seq.Base.seq",
"Vale.Def.Words_s.nat8",
"Prims.unit",
"FStar.Pervasives.reveal_opaque",
"Vale.Def.Types_s.nat8",
"Vale.Def.Types_s.quad32",
"Prims.eq2",
"Prims.int",
"Prims.op_Modulus",
"FStar.Seq.Base.length",
"Prims.l_True",
"Vale.Def.Types_s.le_bytes_to_seq_quad32",
"Prims.squash",
"Prims.op_Division",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
// Top-level proof for the SHA256_msg1 instruction
let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
=
sha256_msg1_spec_reveal ();
let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
let ws_computed (b:block_w) (t:counter{t < size_k_w_256}): Tot (UInt32.t) =
if t < block_word_length SHA2_256 then to_uint32 (ws_opaque b t)
else
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
let open Lib.IntTypes in
(t16 +. s0 +. t7 +. s1)
#push-options "--max_fuel 1"
let lemma_ws_computed_is_ws (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (ws_computed b t == ws SHA2_256 b t)
=
Pervasives.reveal_opaque (`%ws) ws;
if t < block_word_length SHA2_256 then (
assert (vv (ws_computed b t) == ws_opaque b t);
assert (to_uint32 (ws_opaque b t) == ws SHA2_256 b t);
()
) else (
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
lemma_add_mod_ws_rearrangement s1 t7 s0 t16;
()
)
#pop-options
let lemma_ws_computed_is_ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (vv (ws_computed b t) == ws_opaque b t)
=
lemma_ws_computed_is_ws b t;
Pervasives.reveal_opaque (`%ws) ws;
()
let ws_computed_quad32 (t:counter{t < size_k_w_256 - 3}) (block:block_w) : quad32 =
Mkfour (vv (ws_computed block t))
(vv (ws_computed block (t+1)))
(vv (ws_computed block (t+2)))
(vv (ws_computed block (t+3)))
let lemma_ws_computed_is_ws_quad32 (b:block_w) (t:counter{t < size_k_w_256 - 3}) :
Lemma (ws_computed_quad32 t b == ws_quad32 t b)
=
let w = ws_computed_quad32 t b in
let w' = ws_quad32 t b in
lemma_ws_computed_is_ws_opaque b t;
lemma_ws_computed_is_ws_opaque b (t+1);
lemma_ws_computed_is_ws_opaque b (t+2);
lemma_ws_computed_is_ws_opaque b (t+3);
()
#push-options "--z3rlimit 30"
let lemma_ws_computed_quad32 (t:counter{16 <= t /\ t < size_k_w_256 - 4}) (block:block_w) :
Lemma (let t_minus_16 = ws_quad32 (t-16) block in
let t_minus_15 = ws_quad32 (t-15) block in
let t_minus_7 = ws_quad32 (t - 7) block in
let t_minus_2 = ws_quad32 (t - 2) block in
let m1 = add_mod_quad32 t_minus_16 (_sigma0_quad32 t_minus_15) in
let m2 = add_mod_quad32 m1 t_minus_7 in
let m3 = add_mod_quad32 m2 (_sigma1_quad32 t_minus_2) in
m3 == ws_computed_quad32 t block )
=
()
#pop-options
let sha256_msg1_spec_t (t:counter{t < size_k_w_256 - 1}) (block:block_w) : quad32 =
let init = ws_quad32 t block in
let next = ws_quad32 (t + 1) block in
let msg1 = add_mod_quad32 init (_sigma0_quad32 next) in
msg1
#push-options "--ifuel 1"
let lemma_sha256_msg1_spec_t_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 - 3)
(ensures ws_partial t block == sha256_msg1_spec_t (t-16) block)
=
ws_partial_reveal ();
let init = ws_quad32 (t-16) block in
let next = ws_quad32 (t-15) block in
lemma_add_wrap_quad32_is_add_mod_quad32 init (_sigma0_quad32 next);
()
#pop-options
let lemma_sha256_msg1_spec_t (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w_256 - 4 /\
src1 == ws_quad32 t block /\
src2.lo0 == ws_opaque block (t+4))
(ensures sha256_msg1_spec_t t block == sha256_msg1_spec src1 src2)
=
sha256_msg1_spec_reveal ();
()
#push-options "--z3rlimit 70"
let lemma_sha256_step2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1) /\
(let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
src1 == add_mod_quad32 w mid))
(ensures sha256_msg2_spec src1 src2 == ws_computed_quad32 t block)
=
sha256_msg2_spec_reveal ();
let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
let final = sha256_msg2_spec src1 src2 in
lemma_ws_computed_is_ws_opaque block (t);
lemma_ws_computed_is_ws_opaque block (t+1);
()
#pop-options
// Top-level proof for the SHA256_msg2 instruction
let lemma_sha256_msg2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
(let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
src1 == add_wrap_quad32 step1 t_minus_7 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1)))
(ensures sha256_msg2_spec src1 src2 == ws_quad32 t block)
=
let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
lemma_sha256_msg1_spec_t_partial t block;
// ==> step1 == sha256_msg1_spec_t (t-16) block
lemma_add_wrap_quad32_is_add_mod_quad32 step1 t_minus_7;
lemma_sha256_step2 src1 src2 t block;
lemma_ws_computed_is_ws_quad32 block t;
()
(* Abbreviations and lemmas for the code itself *)
#reset-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block qs
=
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32);
reveal_opaque (`%ws) ws
#reset-options "--max_fuel 0 --max_ifuel 0"
let translate_hash_update (h0 h1 h0' h1' a0 a1:quad32) : Lemma
(requires h0' == add_wrap_quad32 a0 h0 /\
h1' == add_wrap_quad32 a1 h1)
(ensures (
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
mapped == h'))
=
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
assert (equal mapped h');
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_lemma (src1 src2 src1' src2' h0 h1:quad32) (block:block_w) : Lemma
(requires (let hash_orig = make_hash h0 h1 in
make_hash src1 src2 ==
Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash_orig /\
src1' == add_wrap_quad32 src1 h0 /\
src2' == add_wrap_quad32 src2 h1))
(ensures (let hash_orig = make_hash h0 h1 in
make_hash src1' src2' == update_block hash_orig block))
=
let hash_orig = make_hash h0 h1 in
let hash_1 = shuffle_opaque SHA2_256 hash_orig block in
Pervasives.reveal_opaque (`%shuffle) shuffle;
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let rec f (i:nat{i <= 64}) : Lemma (
Spec.Loops.repeat_range 0 i (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 i (shuffle_core SHA2_256 block) hash_orig)
=
if i = 0 then (
Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_base 0 (shuffle_core SHA2_256 block) hash_orig
) else (
f (i - 1);
Spec.Loops.repeat_range_induction 0 i (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_induction 0 i (shuffle_core SHA2_256 block) hash_orig
)
in
f 64;
(*
let h = make_hash src1 src2 in
assert (forall (block:block_w) (hash:hash256) . FStar.FunctionalExtensionality.feq (shuffle_core_opaque block hash) (shuffle_core_opaque_aux SHA2_256 block hash));
//assert (forall (block:block_w) . (shuffle_core_opaque block) == (shuffle_core_opaque_aux SHA2_256 block));
assert (shuffle_core_opaque == shuffle_core_opaque_aux SHA2_256);
assert (shuffle_core_opaque == shuffle_core SHA2_256);
assert (shuffle_core_opaque block == shuffle_core SHA2_256 block);
assert (Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 64 (shuffle_core SHA2_256 block) hash_orig);
assert (make_hash src1 src2 == shuffle SHA2_256 hash_orig block);
assert (make_hash src1 src2 == shuffle_opaque SHA2_256 hash_orig block);
*)
translate_hash_update src1 src2 src1' src2' h0 h1;
shuffle_is_shuffle_pre SHA2_256 hash_orig block;
assert (equal (make_hash src1' src2') (update_block hash_orig block));
()
let lemma_le_bytes_to_seq_quad32_empty (b:seq nat8) : Lemma
(requires b == empty)
(ensures le_bytes_to_seq_quad32 b == empty)
=
reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32;
assert (equal (le_bytes_to_seq_quad32 b) empty)
let lemma_le_bytes_to_seq_quad32_length (b:seq nat8) : Lemma
(requires length b % 16 == 0)
(ensures length (le_bytes_to_seq_quad32 b) == length b / 16) | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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"
} | null | val lemma_le_bytes_to_seq_quad32_length (b: seq nat8)
: Lemma (requires length b % 16 == 0)
(ensures length (le_bytes_to_seq_quad32 b) == length b / 16) | [] | Vale.SHA.SHA_helpers.lemma_le_bytes_to_seq_quad32_length | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: FStar.Seq.Base.seq Vale.Def.Words_s.nat8
-> FStar.Pervasives.Lemma (requires FStar.Seq.Base.length b % 16 == 0)
(ensures
FStar.Seq.Base.length (Vale.Def.Types_s.le_bytes_to_seq_quad32 b) ==
FStar.Seq.Base.length b / 16) | {
"end_col": 4,
"end_line": 721,
"start_col": 2,
"start_line": 720
} |
FStar.Pervasives.Lemma | val lemma_slice_commutes_reverse_bytes_nat32_quad32_seq (s: seq quad32) (pivot: nat)
: Lemma (requires pivot <= length s)
(ensures
slice (reverse_bytes_nat32_quad32_seq s) 0 pivot ==
reverse_bytes_nat32_quad32_seq (slice s 0 pivot)) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_slice_commutes_reverse_bytes_nat32_quad32_seq (s:seq quad32) (pivot:nat) : Lemma
(requires pivot <= length s)
(ensures slice (reverse_bytes_nat32_quad32_seq s) 0 pivot == reverse_bytes_nat32_quad32_seq (slice s 0 pivot))
=
let rs = reverse_bytes_nat32_quad32_seq s in
let srs = slice (reverse_bytes_nat32_quad32_seq s) 0 pivot in
let ss = slice s 0 pivot in
let rss = reverse_bytes_nat32_quad32_seq ss in
if pivot = 0 then (
assert (equal ss empty);
assert (equal srs empty);
assert (equal empty (reverse_bytes_nat32_quad32_seq empty));
()
) else (
assert (equal srs rss)
) | val lemma_slice_commutes_reverse_bytes_nat32_quad32_seq (s: seq quad32) (pivot: nat)
: Lemma (requires pivot <= length s)
(ensures
slice (reverse_bytes_nat32_quad32_seq s) 0 pivot ==
reverse_bytes_nat32_quad32_seq (slice s 0 pivot))
let lemma_slice_commutes_reverse_bytes_nat32_quad32_seq (s: seq quad32) (pivot: nat)
: Lemma (requires pivot <= length s)
(ensures
slice (reverse_bytes_nat32_quad32_seq s) 0 pivot ==
reverse_bytes_nat32_quad32_seq (slice s 0 pivot)) = | false | null | true | let rs = reverse_bytes_nat32_quad32_seq s in
let srs = slice (reverse_bytes_nat32_quad32_seq s) 0 pivot in
let ss = slice s 0 pivot in
let rss = reverse_bytes_nat32_quad32_seq ss in
if pivot = 0
then
(assert (equal ss empty);
assert (equal srs empty);
assert (equal empty (reverse_bytes_nat32_quad32_seq empty));
())
else (assert (equal srs rss)) | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.quad32",
"Prims.nat",
"Prims.op_Equality",
"Prims.int",
"Prims.unit",
"Prims._assert",
"FStar.Seq.Base.equal",
"FStar.Seq.Base.empty",
"Vale.Arch.Types.reverse_bytes_nat32_quad32_seq",
"Prims.bool",
"FStar.Seq.Base.slice",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Seq.Base.length",
"Prims.squash",
"Prims.eq2",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
// Top-level proof for the SHA256_msg1 instruction
let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
=
sha256_msg1_spec_reveal ();
let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
let ws_computed (b:block_w) (t:counter{t < size_k_w_256}): Tot (UInt32.t) =
if t < block_word_length SHA2_256 then to_uint32 (ws_opaque b t)
else
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
let open Lib.IntTypes in
(t16 +. s0 +. t7 +. s1)
#push-options "--max_fuel 1"
let lemma_ws_computed_is_ws (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (ws_computed b t == ws SHA2_256 b t)
=
Pervasives.reveal_opaque (`%ws) ws;
if t < block_word_length SHA2_256 then (
assert (vv (ws_computed b t) == ws_opaque b t);
assert (to_uint32 (ws_opaque b t) == ws SHA2_256 b t);
()
) else (
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
lemma_add_mod_ws_rearrangement s1 t7 s0 t16;
()
)
#pop-options
let lemma_ws_computed_is_ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (vv (ws_computed b t) == ws_opaque b t)
=
lemma_ws_computed_is_ws b t;
Pervasives.reveal_opaque (`%ws) ws;
()
let ws_computed_quad32 (t:counter{t < size_k_w_256 - 3}) (block:block_w) : quad32 =
Mkfour (vv (ws_computed block t))
(vv (ws_computed block (t+1)))
(vv (ws_computed block (t+2)))
(vv (ws_computed block (t+3)))
let lemma_ws_computed_is_ws_quad32 (b:block_w) (t:counter{t < size_k_w_256 - 3}) :
Lemma (ws_computed_quad32 t b == ws_quad32 t b)
=
let w = ws_computed_quad32 t b in
let w' = ws_quad32 t b in
lemma_ws_computed_is_ws_opaque b t;
lemma_ws_computed_is_ws_opaque b (t+1);
lemma_ws_computed_is_ws_opaque b (t+2);
lemma_ws_computed_is_ws_opaque b (t+3);
()
#push-options "--z3rlimit 30"
let lemma_ws_computed_quad32 (t:counter{16 <= t /\ t < size_k_w_256 - 4}) (block:block_w) :
Lemma (let t_minus_16 = ws_quad32 (t-16) block in
let t_minus_15 = ws_quad32 (t-15) block in
let t_minus_7 = ws_quad32 (t - 7) block in
let t_minus_2 = ws_quad32 (t - 2) block in
let m1 = add_mod_quad32 t_minus_16 (_sigma0_quad32 t_minus_15) in
let m2 = add_mod_quad32 m1 t_minus_7 in
let m3 = add_mod_quad32 m2 (_sigma1_quad32 t_minus_2) in
m3 == ws_computed_quad32 t block )
=
()
#pop-options
let sha256_msg1_spec_t (t:counter{t < size_k_w_256 - 1}) (block:block_w) : quad32 =
let init = ws_quad32 t block in
let next = ws_quad32 (t + 1) block in
let msg1 = add_mod_quad32 init (_sigma0_quad32 next) in
msg1
#push-options "--ifuel 1"
let lemma_sha256_msg1_spec_t_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 - 3)
(ensures ws_partial t block == sha256_msg1_spec_t (t-16) block)
=
ws_partial_reveal ();
let init = ws_quad32 (t-16) block in
let next = ws_quad32 (t-15) block in
lemma_add_wrap_quad32_is_add_mod_quad32 init (_sigma0_quad32 next);
()
#pop-options
let lemma_sha256_msg1_spec_t (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w_256 - 4 /\
src1 == ws_quad32 t block /\
src2.lo0 == ws_opaque block (t+4))
(ensures sha256_msg1_spec_t t block == sha256_msg1_spec src1 src2)
=
sha256_msg1_spec_reveal ();
()
#push-options "--z3rlimit 70"
let lemma_sha256_step2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1) /\
(let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
src1 == add_mod_quad32 w mid))
(ensures sha256_msg2_spec src1 src2 == ws_computed_quad32 t block)
=
sha256_msg2_spec_reveal ();
let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
let final = sha256_msg2_spec src1 src2 in
lemma_ws_computed_is_ws_opaque block (t);
lemma_ws_computed_is_ws_opaque block (t+1);
()
#pop-options
// Top-level proof for the SHA256_msg2 instruction
let lemma_sha256_msg2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
(let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
src1 == add_wrap_quad32 step1 t_minus_7 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1)))
(ensures sha256_msg2_spec src1 src2 == ws_quad32 t block)
=
let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
lemma_sha256_msg1_spec_t_partial t block;
// ==> step1 == sha256_msg1_spec_t (t-16) block
lemma_add_wrap_quad32_is_add_mod_quad32 step1 t_minus_7;
lemma_sha256_step2 src1 src2 t block;
lemma_ws_computed_is_ws_quad32 block t;
()
(* Abbreviations and lemmas for the code itself *)
#reset-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block qs
=
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32);
reveal_opaque (`%ws) ws
#reset-options "--max_fuel 0 --max_ifuel 0"
let translate_hash_update (h0 h1 h0' h1' a0 a1:quad32) : Lemma
(requires h0' == add_wrap_quad32 a0 h0 /\
h1' == add_wrap_quad32 a1 h1)
(ensures (
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
mapped == h'))
=
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
assert (equal mapped h');
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_lemma (src1 src2 src1' src2' h0 h1:quad32) (block:block_w) : Lemma
(requires (let hash_orig = make_hash h0 h1 in
make_hash src1 src2 ==
Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash_orig /\
src1' == add_wrap_quad32 src1 h0 /\
src2' == add_wrap_quad32 src2 h1))
(ensures (let hash_orig = make_hash h0 h1 in
make_hash src1' src2' == update_block hash_orig block))
=
let hash_orig = make_hash h0 h1 in
let hash_1 = shuffle_opaque SHA2_256 hash_orig block in
Pervasives.reveal_opaque (`%shuffle) shuffle;
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let rec f (i:nat{i <= 64}) : Lemma (
Spec.Loops.repeat_range 0 i (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 i (shuffle_core SHA2_256 block) hash_orig)
=
if i = 0 then (
Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_base 0 (shuffle_core SHA2_256 block) hash_orig
) else (
f (i - 1);
Spec.Loops.repeat_range_induction 0 i (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_induction 0 i (shuffle_core SHA2_256 block) hash_orig
)
in
f 64;
(*
let h = make_hash src1 src2 in
assert (forall (block:block_w) (hash:hash256) . FStar.FunctionalExtensionality.feq (shuffle_core_opaque block hash) (shuffle_core_opaque_aux SHA2_256 block hash));
//assert (forall (block:block_w) . (shuffle_core_opaque block) == (shuffle_core_opaque_aux SHA2_256 block));
assert (shuffle_core_opaque == shuffle_core_opaque_aux SHA2_256);
assert (shuffle_core_opaque == shuffle_core SHA2_256);
assert (shuffle_core_opaque block == shuffle_core SHA2_256 block);
assert (Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 64 (shuffle_core SHA2_256 block) hash_orig);
assert (make_hash src1 src2 == shuffle SHA2_256 hash_orig block);
assert (make_hash src1 src2 == shuffle_opaque SHA2_256 hash_orig block);
*)
translate_hash_update src1 src2 src1' src2' h0 h1;
shuffle_is_shuffle_pre SHA2_256 hash_orig block;
assert (equal (make_hash src1' src2') (update_block hash_orig block));
()
let lemma_le_bytes_to_seq_quad32_empty (b:seq nat8) : Lemma
(requires b == empty)
(ensures le_bytes_to_seq_quad32 b == empty)
=
reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32;
assert (equal (le_bytes_to_seq_quad32 b) empty)
let lemma_le_bytes_to_seq_quad32_length (b:seq nat8) : Lemma
(requires length b % 16 == 0)
(ensures length (le_bytes_to_seq_quad32 b) == length b / 16)
=
reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32;
()
#push-options "--max_fuel 1" // Without this, F* refuses to do even one unfolding of recursive functions :(
let lemma_slice_commutes_reverse_bytes_nat32_quad32_seq (s:seq quad32) (pivot:nat) : Lemma
(requires pivot <= length s) | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"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": 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"
} | null | val lemma_slice_commutes_reverse_bytes_nat32_quad32_seq (s: seq quad32) (pivot: nat)
: Lemma (requires pivot <= length s)
(ensures
slice (reverse_bytes_nat32_quad32_seq s) 0 pivot ==
reverse_bytes_nat32_quad32_seq (slice s 0 pivot)) | [] | Vale.SHA.SHA_helpers.lemma_slice_commutes_reverse_bytes_nat32_quad32_seq | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> pivot: Prims.nat
-> FStar.Pervasives.Lemma (requires pivot <= FStar.Seq.Base.length s)
(ensures
FStar.Seq.Base.slice (Vale.Arch.Types.reverse_bytes_nat32_quad32_seq s) 0 pivot ==
Vale.Arch.Types.reverse_bytes_nat32_quad32_seq (FStar.Seq.Base.slice s 0 pivot)) | {
"end_col": 3,
"end_line": 739,
"start_col": 3,
"start_line": 727
} |
FStar.Pervasives.Lemma | val lemma_update_block_equiv (hash: hash256) (block: bytes{length block = block_length})
: Lemma
(update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) ==
update SHA2_256 hash block) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
() | val lemma_update_block_equiv (hash: hash256) (block: bytes{length block = block_length})
: Lemma
(update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) ==
update SHA2_256 hash block)
let lemma_update_block_equiv (hash: hash256) (block: bytes{length block = block_length})
: Lemma
(update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) ==
update SHA2_256 hash block) = | false | null | true | Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block))
(update SHA2_256 hash block));
() | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"Vale.SHA.SHA_helpers.hash256",
"Vale.SHA.SHA_helpers.bytes",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"Vale.SHA.SHA_helpers.byte",
"Vale.SHA.SHA_helpers.block_length",
"Prims.unit",
"Prims._assert",
"FStar.Seq.Base.equal",
"Vale.SHA.SHA_helpers.word",
"Vale.SHA.SHA_helpers.update_block",
"Spec.Hash.Definitions.words_of_bytes",
"Spec.Hash.Definitions.SHA2_256",
"Spec.Hash.Definitions.block_word_length",
"Spec.Agile.Hash.update",
"FStar.Pervasives.reveal_opaque",
"Spec.Hash.Definitions.sha2_alg",
"Spec.Hash.Definitions.words_state",
"Spec.SHA2.block_w",
"Spec.SHA2.shuffle",
"Spec.Hash.Definitions.update_t",
"Spec.SHA2.update",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"FStar.Seq.Base.seq",
"Prims.l_or",
"Prims.nat",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.state_word_length",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
// Top-level proof for the SHA256_msg1 instruction
let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
=
sha256_msg1_spec_reveal ();
let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
let ws_computed (b:block_w) (t:counter{t < size_k_w_256}): Tot (UInt32.t) =
if t < block_word_length SHA2_256 then to_uint32 (ws_opaque b t)
else
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
let open Lib.IntTypes in
(t16 +. s0 +. t7 +. s1)
#push-options "--max_fuel 1"
let lemma_ws_computed_is_ws (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (ws_computed b t == ws SHA2_256 b t)
=
Pervasives.reveal_opaque (`%ws) ws;
if t < block_word_length SHA2_256 then (
assert (vv (ws_computed b t) == ws_opaque b t);
assert (to_uint32 (ws_opaque b t) == ws SHA2_256 b t);
()
) else (
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
lemma_add_mod_ws_rearrangement s1 t7 s0 t16;
()
)
#pop-options
let lemma_ws_computed_is_ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (vv (ws_computed b t) == ws_opaque b t)
=
lemma_ws_computed_is_ws b t;
Pervasives.reveal_opaque (`%ws) ws;
()
let ws_computed_quad32 (t:counter{t < size_k_w_256 - 3}) (block:block_w) : quad32 =
Mkfour (vv (ws_computed block t))
(vv (ws_computed block (t+1)))
(vv (ws_computed block (t+2)))
(vv (ws_computed block (t+3)))
let lemma_ws_computed_is_ws_quad32 (b:block_w) (t:counter{t < size_k_w_256 - 3}) :
Lemma (ws_computed_quad32 t b == ws_quad32 t b)
=
let w = ws_computed_quad32 t b in
let w' = ws_quad32 t b in
lemma_ws_computed_is_ws_opaque b t;
lemma_ws_computed_is_ws_opaque b (t+1);
lemma_ws_computed_is_ws_opaque b (t+2);
lemma_ws_computed_is_ws_opaque b (t+3);
()
#push-options "--z3rlimit 30"
let lemma_ws_computed_quad32 (t:counter{16 <= t /\ t < size_k_w_256 - 4}) (block:block_w) :
Lemma (let t_minus_16 = ws_quad32 (t-16) block in
let t_minus_15 = ws_quad32 (t-15) block in
let t_minus_7 = ws_quad32 (t - 7) block in
let t_minus_2 = ws_quad32 (t - 2) block in
let m1 = add_mod_quad32 t_minus_16 (_sigma0_quad32 t_minus_15) in
let m2 = add_mod_quad32 m1 t_minus_7 in
let m3 = add_mod_quad32 m2 (_sigma1_quad32 t_minus_2) in
m3 == ws_computed_quad32 t block )
=
()
#pop-options
let sha256_msg1_spec_t (t:counter{t < size_k_w_256 - 1}) (block:block_w) : quad32 =
let init = ws_quad32 t block in
let next = ws_quad32 (t + 1) block in
let msg1 = add_mod_quad32 init (_sigma0_quad32 next) in
msg1
#push-options "--ifuel 1"
let lemma_sha256_msg1_spec_t_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 - 3)
(ensures ws_partial t block == sha256_msg1_spec_t (t-16) block)
=
ws_partial_reveal ();
let init = ws_quad32 (t-16) block in
let next = ws_quad32 (t-15) block in
lemma_add_wrap_quad32_is_add_mod_quad32 init (_sigma0_quad32 next);
()
#pop-options
let lemma_sha256_msg1_spec_t (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w_256 - 4 /\
src1 == ws_quad32 t block /\
src2.lo0 == ws_opaque block (t+4))
(ensures sha256_msg1_spec_t t block == sha256_msg1_spec src1 src2)
=
sha256_msg1_spec_reveal ();
()
#push-options "--z3rlimit 70"
let lemma_sha256_step2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1) /\
(let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
src1 == add_mod_quad32 w mid))
(ensures sha256_msg2_spec src1 src2 == ws_computed_quad32 t block)
=
sha256_msg2_spec_reveal ();
let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
let final = sha256_msg2_spec src1 src2 in
lemma_ws_computed_is_ws_opaque block (t);
lemma_ws_computed_is_ws_opaque block (t+1);
()
#pop-options
// Top-level proof for the SHA256_msg2 instruction
let lemma_sha256_msg2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
(let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
src1 == add_wrap_quad32 step1 t_minus_7 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1)))
(ensures sha256_msg2_spec src1 src2 == ws_quad32 t block)
=
let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
lemma_sha256_msg1_spec_t_partial t block;
// ==> step1 == sha256_msg1_spec_t (t-16) block
lemma_add_wrap_quad32_is_add_mod_quad32 step1 t_minus_7;
lemma_sha256_step2 src1 src2 t block;
lemma_ws_computed_is_ws_quad32 block t;
()
(* Abbreviations and lemmas for the code itself *)
#reset-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block qs
=
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32);
reveal_opaque (`%ws) ws
#reset-options "--max_fuel 0 --max_ifuel 0"
let translate_hash_update (h0 h1 h0' h1' a0 a1:quad32) : Lemma
(requires h0' == add_wrap_quad32 a0 h0 /\
h1' == add_wrap_quad32 a1 h1)
(ensures (
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
mapped == h'))
=
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
assert (equal mapped h');
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block) | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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",
"smt.arith.nl=true"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_update_block_equiv (hash: hash256) (block: bytes{length block = block_length})
: Lemma
(update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) ==
update SHA2_256 hash block) | [] | Vale.SHA.SHA_helpers.lemma_update_block_equiv | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
hash: Vale.SHA.SHA_helpers.hash256 ->
block:
Vale.SHA.SHA_helpers.bytes{FStar.Seq.Base.length block = Vale.SHA.SHA_helpers.block_length}
-> FStar.Pervasives.Lemma
(ensures
Vale.SHA.SHA_helpers.update_block hash
(Spec.Hash.Definitions.words_of_bytes Spec.Hash.Definitions.SHA2_256 block) ==
Spec.Agile.Hash.update Spec.Hash.Definitions.SHA2_256 hash block) | {
"end_col": 4,
"end_line": 661,
"start_col": 2,
"start_line": 658
} |
FStar.Pervasives.Lemma | val lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma
(requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma
(requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks)
=
update_multi_reveal ();
() | val lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma
(requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks)
let lemma_update_multi_opaque_vale_is_update_multi (hash: hash256) (blocks: bytes)
: Lemma (requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks) = | false | null | true | update_multi_reveal ();
() | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"Vale.SHA.SHA_helpers.hash256",
"Vale.SHA.SHA_helpers.bytes",
"Prims.unit",
"Vale.SHA.SHA_helpers.update_multi_reveal",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"FStar.Seq.Base.length",
"Vale.SHA.SHA_helpers.byte",
"Prims.squash",
"Prims.eq2",
"Vale.SHA.SHA_helpers.update_multi_opaque_vale",
"Vale.SHA.SHA_helpers.update_multi_transparent",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
// Top-level proof for the SHA256_msg1 instruction
let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
=
sha256_msg1_spec_reveal ();
let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
let ws_computed (b:block_w) (t:counter{t < size_k_w_256}): Tot (UInt32.t) =
if t < block_word_length SHA2_256 then to_uint32 (ws_opaque b t)
else
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
let open Lib.IntTypes in
(t16 +. s0 +. t7 +. s1)
#push-options "--max_fuel 1"
let lemma_ws_computed_is_ws (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (ws_computed b t == ws SHA2_256 b t)
=
Pervasives.reveal_opaque (`%ws) ws;
if t < block_word_length SHA2_256 then (
assert (vv (ws_computed b t) == ws_opaque b t);
assert (to_uint32 (ws_opaque b t) == ws SHA2_256 b t);
()
) else (
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
lemma_add_mod_ws_rearrangement s1 t7 s0 t16;
()
)
#pop-options
let lemma_ws_computed_is_ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (vv (ws_computed b t) == ws_opaque b t)
=
lemma_ws_computed_is_ws b t;
Pervasives.reveal_opaque (`%ws) ws;
()
let ws_computed_quad32 (t:counter{t < size_k_w_256 - 3}) (block:block_w) : quad32 =
Mkfour (vv (ws_computed block t))
(vv (ws_computed block (t+1)))
(vv (ws_computed block (t+2)))
(vv (ws_computed block (t+3)))
let lemma_ws_computed_is_ws_quad32 (b:block_w) (t:counter{t < size_k_w_256 - 3}) :
Lemma (ws_computed_quad32 t b == ws_quad32 t b)
=
let w = ws_computed_quad32 t b in
let w' = ws_quad32 t b in
lemma_ws_computed_is_ws_opaque b t;
lemma_ws_computed_is_ws_opaque b (t+1);
lemma_ws_computed_is_ws_opaque b (t+2);
lemma_ws_computed_is_ws_opaque b (t+3);
()
#push-options "--z3rlimit 30"
let lemma_ws_computed_quad32 (t:counter{16 <= t /\ t < size_k_w_256 - 4}) (block:block_w) :
Lemma (let t_minus_16 = ws_quad32 (t-16) block in
let t_minus_15 = ws_quad32 (t-15) block in
let t_minus_7 = ws_quad32 (t - 7) block in
let t_minus_2 = ws_quad32 (t - 2) block in
let m1 = add_mod_quad32 t_minus_16 (_sigma0_quad32 t_minus_15) in
let m2 = add_mod_quad32 m1 t_minus_7 in
let m3 = add_mod_quad32 m2 (_sigma1_quad32 t_minus_2) in
m3 == ws_computed_quad32 t block )
=
()
#pop-options
let sha256_msg1_spec_t (t:counter{t < size_k_w_256 - 1}) (block:block_w) : quad32 =
let init = ws_quad32 t block in
let next = ws_quad32 (t + 1) block in
let msg1 = add_mod_quad32 init (_sigma0_quad32 next) in
msg1
#push-options "--ifuel 1"
let lemma_sha256_msg1_spec_t_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 - 3)
(ensures ws_partial t block == sha256_msg1_spec_t (t-16) block)
=
ws_partial_reveal ();
let init = ws_quad32 (t-16) block in
let next = ws_quad32 (t-15) block in
lemma_add_wrap_quad32_is_add_mod_quad32 init (_sigma0_quad32 next);
()
#pop-options
let lemma_sha256_msg1_spec_t (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w_256 - 4 /\
src1 == ws_quad32 t block /\
src2.lo0 == ws_opaque block (t+4))
(ensures sha256_msg1_spec_t t block == sha256_msg1_spec src1 src2)
=
sha256_msg1_spec_reveal ();
()
#push-options "--z3rlimit 70"
let lemma_sha256_step2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1) /\
(let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
src1 == add_mod_quad32 w mid))
(ensures sha256_msg2_spec src1 src2 == ws_computed_quad32 t block)
=
sha256_msg2_spec_reveal ();
let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
let final = sha256_msg2_spec src1 src2 in
lemma_ws_computed_is_ws_opaque block (t);
lemma_ws_computed_is_ws_opaque block (t+1);
()
#pop-options
// Top-level proof for the SHA256_msg2 instruction
let lemma_sha256_msg2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
(let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
src1 == add_wrap_quad32 step1 t_minus_7 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1)))
(ensures sha256_msg2_spec src1 src2 == ws_quad32 t block)
=
let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
lemma_sha256_msg1_spec_t_partial t block;
// ==> step1 == sha256_msg1_spec_t (t-16) block
lemma_add_wrap_quad32_is_add_mod_quad32 step1 t_minus_7;
lemma_sha256_step2 src1 src2 t block;
lemma_ws_computed_is_ws_quad32 block t;
()
(* Abbreviations and lemmas for the code itself *)
#reset-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block qs
=
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32);
reveal_opaque (`%ws) ws
#reset-options "--max_fuel 0 --max_ifuel 0"
let translate_hash_update (h0 h1 h0' h1' a0 a1:quad32) : Lemma
(requires h0' == add_wrap_quad32 a0 h0 /\
h1' == add_wrap_quad32 a1 h1)
(ensures (
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
mapped == h'))
=
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
assert (equal mapped h');
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_lemma (src1 src2 src1' src2' h0 h1:quad32) (block:block_w) : Lemma
(requires (let hash_orig = make_hash h0 h1 in
make_hash src1 src2 ==
Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash_orig /\
src1' == add_wrap_quad32 src1 h0 /\
src2' == add_wrap_quad32 src2 h1))
(ensures (let hash_orig = make_hash h0 h1 in
make_hash src1' src2' == update_block hash_orig block))
=
let hash_orig = make_hash h0 h1 in
let hash_1 = shuffle_opaque SHA2_256 hash_orig block in
Pervasives.reveal_opaque (`%shuffle) shuffle;
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let rec f (i:nat{i <= 64}) : Lemma (
Spec.Loops.repeat_range 0 i (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 i (shuffle_core SHA2_256 block) hash_orig)
=
if i = 0 then (
Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_base 0 (shuffle_core SHA2_256 block) hash_orig
) else (
f (i - 1);
Spec.Loops.repeat_range_induction 0 i (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_induction 0 i (shuffle_core SHA2_256 block) hash_orig
)
in
f 64;
(*
let h = make_hash src1 src2 in
assert (forall (block:block_w) (hash:hash256) . FStar.FunctionalExtensionality.feq (shuffle_core_opaque block hash) (shuffle_core_opaque_aux SHA2_256 block hash));
//assert (forall (block:block_w) . (shuffle_core_opaque block) == (shuffle_core_opaque_aux SHA2_256 block));
assert (shuffle_core_opaque == shuffle_core_opaque_aux SHA2_256);
assert (shuffle_core_opaque == shuffle_core SHA2_256);
assert (shuffle_core_opaque block == shuffle_core SHA2_256 block);
assert (Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 64 (shuffle_core SHA2_256 block) hash_orig);
assert (make_hash src1 src2 == shuffle SHA2_256 hash_orig block);
assert (make_hash src1 src2 == shuffle_opaque SHA2_256 hash_orig block);
*)
translate_hash_update src1 src2 src1' src2' h0 h1;
shuffle_is_shuffle_pre SHA2_256 hash_orig block;
assert (equal (make_hash src1' src2') (update_block hash_orig block));
()
let lemma_le_bytes_to_seq_quad32_empty (b:seq nat8) : Lemma
(requires b == empty)
(ensures le_bytes_to_seq_quad32 b == empty)
=
reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32;
assert (equal (le_bytes_to_seq_quad32 b) empty)
let lemma_le_bytes_to_seq_quad32_length (b:seq nat8) : Lemma
(requires length b % 16 == 0)
(ensures length (le_bytes_to_seq_quad32 b) == length b / 16)
=
reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32;
()
#push-options "--max_fuel 1" // Without this, F* refuses to do even one unfolding of recursive functions :(
let lemma_slice_commutes_reverse_bytes_nat32_quad32_seq (s:seq quad32) (pivot:nat) : Lemma
(requires pivot <= length s)
(ensures slice (reverse_bytes_nat32_quad32_seq s) 0 pivot == reverse_bytes_nat32_quad32_seq (slice s 0 pivot))
=
let rs = reverse_bytes_nat32_quad32_seq s in
let srs = slice (reverse_bytes_nat32_quad32_seq s) 0 pivot in
let ss = slice s 0 pivot in
let rss = reverse_bytes_nat32_quad32_seq ss in
if pivot = 0 then (
assert (equal ss empty);
assert (equal srs empty);
assert (equal empty (reverse_bytes_nat32_quad32_seq empty));
()
) else (
assert (equal srs rss)
)
// One level of expansion that we can use in places that can't use fuel
let lemma_update_multi_quads_unfold (s:seq quad32) (hash_orig:hash256) : Lemma
(requires length s >= 4)
(ensures (let prefix, qs = split s (length s - 4) in
let h_prefix = update_multi_quads prefix hash_orig in
let hash = update_block h_prefix (quads_to_block qs) in
update_multi_quads s hash_orig == hash))
=
()
let lemma_update_multi_quads_short (s:seq quad32) (hash_orig:hash256) : Lemma
(requires length s < 4)
(ensures update_multi_quads s hash_orig == hash_orig)
=
()
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
#pop-options
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 40"
let lemma_endian_relation (quads qs:seq quad32) (input2:seq UInt8.t) : Lemma
(requires length qs == 4 /\ length input2 == 64 /\
qs == reverse_bytes_nat32_quad32_seq quads /\
input2 == seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads))
(ensures quads_to_block qs == words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2)
=
let fi (i:nat{i < length (quads_to_block qs)}) : Lemma
((quads_to_block qs).[i] == (words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2).[i])
=
let open Vale.Def.Words.Four_s in
let open Vale.Lib.Seqs_s in
let ni = (seq_four_to_seq_LE quads).[i] in
let b = slice input2 (4 * i) (4 * i + 4) in
// FStar.Krml.Endianness.lemma_be_to_n_is_bounded b;
calc (==) {
b;
== {}
slice input2 (4 * i) (4 * i + 4);
== {}
slice (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) (4 * i) (4 * i + 4);
== {le_seq_quad32_to_bytes_reveal ()}
slice (seq_nat8_to_seq_uint8 (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE quads))) (4 * i) (4 * i + 4);
equal {}
seq_nat8_to_seq_uint8 (slice (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE quads)) (4 * i) (4 * i + 4));
== {}
seq_nat8_to_seq_uint8 (slice (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE quads))) (4 * i) (4 * i + 4));
== {slice_commutes_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE quads)) i (i + 1)}
seq_nat8_to_seq_uint8 (seq_four_to_seq_LE (slice (seq_map (nat_to_four 8) (seq_four_to_seq_LE quads)) i (i + 1)));
equal {reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat8)}
seq_nat8_to_seq_uint8 (four_to_seq_LE (nat_to_four 8 (seq_four_to_seq_LE quads).[i]));
};
let open Lib.IntTypes in
calc (==) {
(words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2).[i];
== { }
(Lib.ByteSequence.uints_from_bytes_be #U32 #SEC #(block_word_length SHA2_256) input2).[i];
== { Lib.ByteSequence.index_uints_from_bytes_be #U32 #SEC #(block_word_length SHA2_256) input2 i }
Lib.ByteSequence.uint_from_bytes_be (Lib.Sequence.sub #uint8 #64 input2 (i * 4) 4);
== { let open Lib.Sequence in
calc (==) {
sub #uint8 #64 input2 (i * 4) 4;
== { }
Seq.slice input2 (4 * i) (4 * i + 4);
}
}
Lib.ByteSequence.uint_from_bytes_be #U32 #SEC b;
== { calc (==) {
Lib.ByteSequence.nat_from_bytes_be #SEC b;
(==) { }
Lib.ByteSequence.nat_from_bytes_be #SEC (seq_nat8_to_seq_uint8 (four_to_seq_LE (nat_to_four 8 ni)));
(==) { lemma_be_to_n_4 (four_to_seq_LE (nat_to_four 8 ni)) }
be_bytes_to_nat32 (four_to_seq_LE (nat_to_four 8 ni));
};
v_inj (Lib.ByteSequence.uint_from_bytes_be #U32 #SEC b)
(u32 (be_bytes_to_nat32 (four_to_seq_LE (nat_to_four 8 ni))))
}
nat32_to_word (be_bytes_to_nat32 (four_to_seq_LE (nat_to_four 8 ni)));
== {}
nat32_to_word (be_bytes_to_nat32 (reverse_seq (nat32_to_be_bytes ni)));
== {reverse_bytes_nat32_reveal ()}
nat32_to_word (reverse_bytes_nat32 ni);
== {}
nat32_to_word (reverse_bytes_nat32 (seq_four_to_seq_LE quads).[i]);
== {reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32)}
nat32_to_word (seq_four_to_seq_LE qs).[i];
== {}
(quads_to_block qs).[i];
}
in
FStar.Classical.forall_intro fi;
assert (equal (quads_to_block qs) (words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2))
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
#reset-options "--max_fuel 0 --ifuel 1 --z3rlimit 20"
let rec lemma_update_multi_equiv_vale (hash hash':hash256) (quads:seq quad32) (r_quads:seq quad32)
(nat8s:seq nat8) (blocks:seq UInt8.t) :
Lemma (requires length quads % 4 == 0 /\
r_quads == reverse_bytes_nat32_quad32_seq quads /\
nat8s == le_seq_quad32_to_bytes quads /\
blocks == seq_nat8_to_seq_uint8 nat8s /\
hash' == update_multi_quads r_quads hash)
(ensures
length blocks % 64 == 0 /\
hash' == update_multi_opaque_vale hash blocks)
(decreases (length quads))
=
lemma_mod_transform quads;
assert (length blocks % 64 == 0);
update_multi_reveal ();
if length quads = 0 then begin
lemma_le_seq_quad32_to_bytes_length quads;
//assert (length nat8s == 0);
//assert (length r_quads == 0);
lemma_update_multi_quads_short r_quads hash;
//assert (hash' == hash);
//assert (length blocks == 0);
assert (equal blocks empty);
update_multi_zero SHA2_256 hash;
//assert (update_multi SHA2_256 hash blocks == hash);
()
end else begin
let num_blocks = (length quads) / 4 in
let bytes_pivot = (num_blocks - 1) * 64 in
// Use associativity of update_multi to rearrange recursion to better match update_multi_quads' recursion
let input1,input2 = Lib.UpdateMulti.split_block block_length blocks (bytes_pivot / 64) in
let h_bytes1 = update_multi SHA2_256 hash () input1 in
let h_bytes2 = update_multi SHA2_256 h_bytes1 () input2 in
update_multi_associative SHA2_256 hash input1 input2;
assert (input1 `Seq.append` input2 == blocks);
Seq.lemma_eq_intro h_bytes2 (update_multi SHA2_256 hash () blocks);
assert (h_bytes2 == update_multi SHA2_256 hash () blocks);
// Unfold update_multi_quads one level, so we can start matching parts up
let prefix, qs = split r_quads (length r_quads - 4) in
let h_prefix = update_multi_quads prefix hash in
let h_final = update_block h_prefix (quads_to_block qs) in
lemma_update_multi_quads_unfold r_quads hash;
// hash' == update_multi_quads r_quads hash == h_final
(*+ Goal: h_bytes_2 == h_final +*)
(* Step 1: Show that h_prefix == h_bytes1 *)
// Inductive hypothesis says that we roughly line up on input1
let r_prefix = reverse_bytes_nat32_quad32_seq prefix in
lemma_update_multi_equiv_vale hash h_prefix r_prefix prefix
(le_seq_quad32_to_bytes r_prefix)
(seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes r_prefix));
assert (h_prefix == update_multi SHA2_256 hash () (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes r_prefix)));
// To show that h_prefix == h_bytes1, we need to show that:
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes r_prefix) == input1
// calc {
// input1
// slice blocks 0 bytes_pivot
// slice ( (le_seq_quad32_to_bytes quads)) 0 bytes_pivot
assert (equal (slice (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) 0 bytes_pivot)
(seq_nat8_to_seq_uint8 (slice (le_seq_quad32_to_bytes quads) 0 bytes_pivot)));
// seq_nat8_to_seq_U8 (slice (le_seq_quad32_to_bytes quads) 0 bytes_pivot)
slice_commutes_le_seq_quad32_to_bytes0 quads (bytes_pivot / 16);
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads 0 (bytes_pivot / 16)))
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads 0 ((num_blocks - 1) * 4)))
assert (bytes_pivot / 16 == length quads - 4);
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads 0 (length quads - 4)))
//
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads 0 (length quads - 4)))))
assert (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq (slice quads 0 (length quads - 4))) == slice quads 0 (length quads - 4));
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq (slice quads 0 (length quads - 4)))))
Vale.Lib.Seqs.slice_seq_map_commute reverse_bytes_nat32_quad32 quads 0 (length quads - 4);
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (reverse_bytes_nat32_quad32_seq (slice (reverse_bytes_nat32_quad32_seq quads) 0 (length quads - 4)))
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes r_prefix)
// }
// assert (seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes r_prefix) == input1); // Conclusion of the calc
assert (Seq.equal h_prefix h_bytes1); // Conclusion of Step 1
// To invoke lemma_endian_relation below,
// we need to show (1):
// calc {
// qs
Vale.Lib.Seqs.slice_seq_map_commute reverse_bytes_nat32_quad32 quads (length quads - 4) (length quads);
// slice (reverse_bytes_nat32_quad32_seq quads) (length quads - 4) (length quads))
// reverse_bytes_nat32_quad32_seq (slice quads (length quads - 4) (length quads))
// }
// And (2):
// calc {
// input2
// slice blocks bytes_pivot (length blocks)
// slice (seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes quads)) bytes_pivot (length blocks)
// assert (equal (slice (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) bytes_pivot (length blocks))
// (seq_nat8_to_seq_uint8 (slice (le_seq_quad32_to_bytes quads) bytes_pivot (length blocks))));
// seq_nat8_to_seq_U8 (slice (le_seq_quad32_to_bytes quads) bytes_pivot (length blocks))
slice_commutes_le_seq_quad32_to_bytes quads (bytes_pivot/16) ((length blocks)/16);
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads bytes_pivot/16 (length blocks)/16)
//
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads (length quads - 4) (length quads))))
// }
//assert (input2 == seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads (length quads - 4) (length quads)))); // Conclusion of the calc
(* Step 2: Show that update_block SHA2_256 h_prefix (quads_to_block qs) == update_multi SHA2_256 h_bytes1 input2 *)
// calc {
// update_block SHA2_256 h_prefix (quads_to_block qs)
// { from Step 1 }
// update_block SHA2_256 h_bytes1 (quads_to_block qs)
//
assert (equal input2 (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (slice quads (length quads - 4) (length quads)))));
lemma_endian_relation (slice quads (length quads - 4) (length quads)) qs
input2; // ==> quads_to_block qs == words_of_bytes SHA2_256 block_word_length input2
// update_block SHA2_256 h_bytes1 (words_of_bytes SHA2_256 16 input2)
lemma_update_block_equiv h_bytes1 input2;
// update SHA2_256 h_bytes1 input2
update_multi_one h_bytes1 input2;
// update_multi SHA2_256 h_bytes1 input2
// }
//
// assert (update_block SHA2_256 h_prefix (quads_to_block qs) == update_multi SHA2_256 h_bytes1 input2); // Conclusion of calc
// assert (h_final == h_bytes2); // Conclusion of Goal
()
end
//
#push-options "--max_fuel 1" // Without this, F* refuses to do even one unfolding of update_multi_quads :(
let lemma_update_multi_quads (s:seq quad32) (hash_orig:hash256) (bound:nat) : Lemma
(requires bound + 4 <= length s)
(ensures (let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_nat32_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_nat32_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound+4) in
let input_BE = reverse_bytes_nat32_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block block_quads_BE) in
h == update_multi_quads input_BE hash_orig))
=
let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_nat32_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_nat32_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound+4) in
let input_BE = reverse_bytes_nat32_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block block_quads_BE) in
lemma_slice_commutes_reverse_bytes_nat32_quad32_seq s bound;
lemma_slice_commutes_reverse_bytes_nat32_quad32_seq s (bound + 4);
assert (prefix_BE == slice (reverse_bytes_nat32_quad32_seq s) 0 bound);
assert (input_BE == slice (reverse_bytes_nat32_quad32_seq s) 0 (bound + 4));
if bound = 0 then ()
else (
let prefix, qs = split input_BE (length input_BE - 4) in
assert (equal prefix prefix_BE);
assert (equal qs block_quads_BE);
()
)
#pop-options
let lemma_le_bytes_to_hash_quads_part1 (s:seq quad32) : Lemma
(requires length s == 2)
(ensures le_bytes_to_hash (le_seq_quad32_to_bytes s) ==
Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s))
=
let lhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
assert (lhs == Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)));
le_seq_quad32_to_bytes_reveal ();
Vale.Def.Words.Seq.seq_nat8_to_seq_nat32_to_seq_nat8_LE (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s);
()
//
#push-options "--z3rlimit 30"
let lemma_le_bytes_to_hash_quads (s:seq quad32) : Lemma
(requires length s == 2)
(ensures (let rhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
rhs.[0] == to_uint32 (s.[0]).lo0 /\
rhs.[1] == to_uint32 (s.[0]).lo1 /\
rhs.[2] == to_uint32 (s.[0]).hi2 /\
rhs.[3] == to_uint32 (s.[0]).hi3 /\
rhs.[4] == to_uint32 (s.[1]).lo0 /\
rhs.[5] == to_uint32 (s.[1]).lo1 /\
rhs.[6] == to_uint32 (s.[1]).hi2 /\
rhs.[7] == to_uint32 (s.[1]).hi3 /\
length rhs == 8))
=
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32);
let rhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
lemma_le_bytes_to_hash_quads_part1 s;
assert (rhs == Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s));
()
#pop-options
let lemma_hash_to_bytes (s:seq quad32) : Lemma
(requires length s == 2)
(ensures make_ordered_hash s.[0] s.[1] == le_bytes_to_hash (le_seq_quad32_to_bytes s))
=
lemma_le_bytes_to_hash_quads s;
assert (equal (make_ordered_hash s.[0] s.[1]) (le_bytes_to_hash (le_seq_quad32_to_bytes s)));
()
let lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma
(requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks) | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": 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"
} | null | val lemma_update_multi_opaque_vale_is_update_multi (hash:hash256) (blocks:bytes) : Lemma
(requires length blocks % 64 = 0)
(ensures update_multi_opaque_vale hash blocks == update_multi_transparent hash blocks) | [] | Vale.SHA.SHA_helpers.lemma_update_multi_opaque_vale_is_update_multi | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | hash: Vale.SHA.SHA_helpers.hash256 -> blocks: Vale.SHA.SHA_helpers.bytes
-> FStar.Pervasives.Lemma (requires FStar.Seq.Base.length blocks % 64 = 0)
(ensures
Vale.SHA.SHA_helpers.update_multi_opaque_vale hash blocks ==
Vale.SHA.SHA_helpers.update_multi_transparent hash blocks) | {
"end_col": 4,
"end_line": 1084,
"start_col": 2,
"start_line": 1083
} |
FStar.Pervasives.Lemma | val update_multi_one (h: hash256) (b: bytes_blocks{length b = block_length})
: Lemma (ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b | val update_multi_one (h: hash256) (b: bytes_blocks{length b = block_length})
: Lemma (ensures (update_multi SHA2_256 h () b == update SHA2_256 h b))
let update_multi_one (h: hash256) (b: bytes_blocks{length b = block_length})
: Lemma (ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) = | false | null | true | update_multi_update SHA2_256 h b | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"Vale.SHA.SHA_helpers.hash256",
"Vale.SHA.SHA_helpers.bytes_blocks",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"Vale.SHA.SHA_helpers.byte",
"Vale.SHA.SHA_helpers.block_length",
"Spec.Hash.Lemmas.update_multi_update",
"Spec.Hash.Definitions.SHA2_256",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"Spec.Hash.Definitions.words_state",
"Spec.Agile.Hash.update_multi",
"Spec.Agile.Hash.update",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
// Top-level proof for the SHA256_msg1 instruction
let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
=
sha256_msg1_spec_reveal ();
let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
let ws_computed (b:block_w) (t:counter{t < size_k_w_256}): Tot (UInt32.t) =
if t < block_word_length SHA2_256 then to_uint32 (ws_opaque b t)
else
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
let open Lib.IntTypes in
(t16 +. s0 +. t7 +. s1)
#push-options "--max_fuel 1"
let lemma_ws_computed_is_ws (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (ws_computed b t == ws SHA2_256 b t)
=
Pervasives.reveal_opaque (`%ws) ws;
if t < block_word_length SHA2_256 then (
assert (vv (ws_computed b t) == ws_opaque b t);
assert (to_uint32 (ws_opaque b t) == ws SHA2_256 b t);
()
) else (
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
lemma_add_mod_ws_rearrangement s1 t7 s0 t16;
()
)
#pop-options
let lemma_ws_computed_is_ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (vv (ws_computed b t) == ws_opaque b t)
=
lemma_ws_computed_is_ws b t;
Pervasives.reveal_opaque (`%ws) ws;
()
let ws_computed_quad32 (t:counter{t < size_k_w_256 - 3}) (block:block_w) : quad32 =
Mkfour (vv (ws_computed block t))
(vv (ws_computed block (t+1)))
(vv (ws_computed block (t+2)))
(vv (ws_computed block (t+3)))
let lemma_ws_computed_is_ws_quad32 (b:block_w) (t:counter{t < size_k_w_256 - 3}) :
Lemma (ws_computed_quad32 t b == ws_quad32 t b)
=
let w = ws_computed_quad32 t b in
let w' = ws_quad32 t b in
lemma_ws_computed_is_ws_opaque b t;
lemma_ws_computed_is_ws_opaque b (t+1);
lemma_ws_computed_is_ws_opaque b (t+2);
lemma_ws_computed_is_ws_opaque b (t+3);
()
#push-options "--z3rlimit 30"
let lemma_ws_computed_quad32 (t:counter{16 <= t /\ t < size_k_w_256 - 4}) (block:block_w) :
Lemma (let t_minus_16 = ws_quad32 (t-16) block in
let t_minus_15 = ws_quad32 (t-15) block in
let t_minus_7 = ws_quad32 (t - 7) block in
let t_minus_2 = ws_quad32 (t - 2) block in
let m1 = add_mod_quad32 t_minus_16 (_sigma0_quad32 t_minus_15) in
let m2 = add_mod_quad32 m1 t_minus_7 in
let m3 = add_mod_quad32 m2 (_sigma1_quad32 t_minus_2) in
m3 == ws_computed_quad32 t block )
=
()
#pop-options
let sha256_msg1_spec_t (t:counter{t < size_k_w_256 - 1}) (block:block_w) : quad32 =
let init = ws_quad32 t block in
let next = ws_quad32 (t + 1) block in
let msg1 = add_mod_quad32 init (_sigma0_quad32 next) in
msg1
#push-options "--ifuel 1"
let lemma_sha256_msg1_spec_t_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 - 3)
(ensures ws_partial t block == sha256_msg1_spec_t (t-16) block)
=
ws_partial_reveal ();
let init = ws_quad32 (t-16) block in
let next = ws_quad32 (t-15) block in
lemma_add_wrap_quad32_is_add_mod_quad32 init (_sigma0_quad32 next);
()
#pop-options
let lemma_sha256_msg1_spec_t (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w_256 - 4 /\
src1 == ws_quad32 t block /\
src2.lo0 == ws_opaque block (t+4))
(ensures sha256_msg1_spec_t t block == sha256_msg1_spec src1 src2)
=
sha256_msg1_spec_reveal ();
()
#push-options "--z3rlimit 70"
let lemma_sha256_step2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1) /\
(let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
src1 == add_mod_quad32 w mid))
(ensures sha256_msg2_spec src1 src2 == ws_computed_quad32 t block)
=
sha256_msg2_spec_reveal ();
let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
let final = sha256_msg2_spec src1 src2 in
lemma_ws_computed_is_ws_opaque block (t);
lemma_ws_computed_is_ws_opaque block (t+1);
()
#pop-options
// Top-level proof for the SHA256_msg2 instruction
let lemma_sha256_msg2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
(let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
src1 == add_wrap_quad32 step1 t_minus_7 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1)))
(ensures sha256_msg2_spec src1 src2 == ws_quad32 t block)
=
let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
lemma_sha256_msg1_spec_t_partial t block;
// ==> step1 == sha256_msg1_spec_t (t-16) block
lemma_add_wrap_quad32_is_add_mod_quad32 step1 t_minus_7;
lemma_sha256_step2 src1 src2 t block;
lemma_ws_computed_is_ws_quad32 block t;
()
(* Abbreviations and lemmas for the code itself *)
#reset-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block qs
=
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32);
reveal_opaque (`%ws) ws
#reset-options "--max_fuel 0 --max_ifuel 0"
let translate_hash_update (h0 h1 h0' h1' a0 a1:quad32) : Lemma
(requires h0' == add_wrap_quad32 a0 h0 /\
h1' == add_wrap_quad32 a1 h1)
(ensures (
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
mapped == h'))
=
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
assert (equal mapped h');
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_lemma (src1 src2 src1' src2' h0 h1:quad32) (block:block_w) : Lemma
(requires (let hash_orig = make_hash h0 h1 in
make_hash src1 src2 ==
Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash_orig /\
src1' == add_wrap_quad32 src1 h0 /\
src2' == add_wrap_quad32 src2 h1))
(ensures (let hash_orig = make_hash h0 h1 in
make_hash src1' src2' == update_block hash_orig block))
=
let hash_orig = make_hash h0 h1 in
let hash_1 = shuffle_opaque SHA2_256 hash_orig block in
Pervasives.reveal_opaque (`%shuffle) shuffle;
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let rec f (i:nat{i <= 64}) : Lemma (
Spec.Loops.repeat_range 0 i (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 i (shuffle_core SHA2_256 block) hash_orig)
=
if i = 0 then (
Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_base 0 (shuffle_core SHA2_256 block) hash_orig
) else (
f (i - 1);
Spec.Loops.repeat_range_induction 0 i (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_induction 0 i (shuffle_core SHA2_256 block) hash_orig
)
in
f 64;
(*
let h = make_hash src1 src2 in
assert (forall (block:block_w) (hash:hash256) . FStar.FunctionalExtensionality.feq (shuffle_core_opaque block hash) (shuffle_core_opaque_aux SHA2_256 block hash));
//assert (forall (block:block_w) . (shuffle_core_opaque block) == (shuffle_core_opaque_aux SHA2_256 block));
assert (shuffle_core_opaque == shuffle_core_opaque_aux SHA2_256);
assert (shuffle_core_opaque == shuffle_core SHA2_256);
assert (shuffle_core_opaque block == shuffle_core SHA2_256 block);
assert (Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 64 (shuffle_core SHA2_256 block) hash_orig);
assert (make_hash src1 src2 == shuffle SHA2_256 hash_orig block);
assert (make_hash src1 src2 == shuffle_opaque SHA2_256 hash_orig block);
*)
translate_hash_update src1 src2 src1' src2' h0 h1;
shuffle_is_shuffle_pre SHA2_256 hash_orig block;
assert (equal (make_hash src1' src2') (update_block hash_orig block));
()
let lemma_le_bytes_to_seq_quad32_empty (b:seq nat8) : Lemma
(requires b == empty)
(ensures le_bytes_to_seq_quad32 b == empty)
=
reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32;
assert (equal (le_bytes_to_seq_quad32 b) empty)
let lemma_le_bytes_to_seq_quad32_length (b:seq nat8) : Lemma
(requires length b % 16 == 0)
(ensures length (le_bytes_to_seq_quad32 b) == length b / 16)
=
reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32;
()
#push-options "--max_fuel 1" // Without this, F* refuses to do even one unfolding of recursive functions :(
let lemma_slice_commutes_reverse_bytes_nat32_quad32_seq (s:seq quad32) (pivot:nat) : Lemma
(requires pivot <= length s)
(ensures slice (reverse_bytes_nat32_quad32_seq s) 0 pivot == reverse_bytes_nat32_quad32_seq (slice s 0 pivot))
=
let rs = reverse_bytes_nat32_quad32_seq s in
let srs = slice (reverse_bytes_nat32_quad32_seq s) 0 pivot in
let ss = slice s 0 pivot in
let rss = reverse_bytes_nat32_quad32_seq ss in
if pivot = 0 then (
assert (equal ss empty);
assert (equal srs empty);
assert (equal empty (reverse_bytes_nat32_quad32_seq empty));
()
) else (
assert (equal srs rss)
)
// One level of expansion that we can use in places that can't use fuel
let lemma_update_multi_quads_unfold (s:seq quad32) (hash_orig:hash256) : Lemma
(requires length s >= 4)
(ensures (let prefix, qs = split s (length s - 4) in
let h_prefix = update_multi_quads prefix hash_orig in
let hash = update_block h_prefix (quads_to_block qs) in
update_multi_quads s hash_orig == hash))
=
()
let lemma_update_multi_quads_short (s:seq quad32) (hash_orig:hash256) : Lemma
(requires length s < 4)
(ensures update_multi_quads s hash_orig == hash_orig)
=
()
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"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": 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"
} | null | val update_multi_one (h: hash256) (b: bytes_blocks{length b = block_length})
: Lemma (ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) | [] | Vale.SHA.SHA_helpers.update_multi_one | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h: Vale.SHA.SHA_helpers.hash256 ->
b:
Vale.SHA.SHA_helpers.bytes_blocks{FStar.Seq.Base.length b = Vale.SHA.SHA_helpers.block_length}
-> FStar.Pervasives.Lemma
(ensures
Spec.Agile.Hash.update_multi Spec.Hash.Definitions.SHA2_256 h () b ==
Spec.Agile.Hash.update Spec.Hash.Definitions.SHA2_256 h b) | {
"end_col": 34,
"end_line": 759,
"start_col": 2,
"start_line": 759
} |
FStar.Pervasives.Lemma | val lemma_be_to_n_4 (s: seq4 nat8)
: Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) ==
be_bytes_to_nat32 s) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
} | val lemma_be_to_n_4 (s: seq4 nat8)
: Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) ==
be_bytes_to_nat32 s)
let lemma_be_to_n_4 (s: seq4 nat8)
: Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) ==
be_bytes_to_nat32 s) = | false | null | true | let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc ( == ) {
f x <: nat;
( == ) { () }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
( == ) { () }
index s 3 + pow2 8 * f (slice x 0 3);
( == ) { () }
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
( == ) { () }
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
( == ) { () }
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 +
pow2 32 * f (slice x 0 0);
( == ) { () }
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
( == ) { () }
four_to_nat_unfold 8 (seq_to_four_BE s);
( == ) { reveal_opaque (`%four_to_nat) four_to_nat }
be_bytes_to_nat32 s;
} | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"Vale.Def.Words.Seq_s.seq4",
"Vale.Def.Words_s.nat8",
"FStar.Calc.calc_finish",
"Prims.nat",
"Prims.eq2",
"Vale.Def.Types_s.be_bytes_to_nat32",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"Vale.Def.Words.Four_s.four_to_nat_unfold",
"Vale.Def.Words.Seq_s.seq_to_four_BE",
"Prims.op_Addition",
"FStar.Seq.Base.index",
"FStar.Mul.op_Star",
"Prims.pow2",
"FStar.Seq.Base.slice",
"FStar.UInt8.t",
"FStar.UInt8.v",
"FStar.Seq.Properties.last",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Prims.squash",
"FStar.Pervasives.reveal_opaque",
"Vale.Def.Words_s.four",
"Vale.Def.Words_s.natN",
"Vale.Def.Words.Four_s.four_to_nat",
"Lib.Sequence.seq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_Multiply",
"Lib.Sequence.length",
"Lib.ByteSequence.nat_from_intseq_be_",
"FStar.Seq.Base.seq",
"Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8",
"FStar.Pervasives.assert_norm",
"Prims.op_Equality",
"Prims.int",
"Prims._assert",
"Prims.l_True",
"Prims.l_or",
"Lib.IntTypes.uint_t",
"Vale.Def.Words_s.pow2_32",
"Lib.ByteSequence.nat_from_bytes_be",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
// Top-level proof for the SHA256_msg1 instruction
let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
=
sha256_msg1_spec_reveal ();
let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
let ws_computed (b:block_w) (t:counter{t < size_k_w_256}): Tot (UInt32.t) =
if t < block_word_length SHA2_256 then to_uint32 (ws_opaque b t)
else
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
let open Lib.IntTypes in
(t16 +. s0 +. t7 +. s1)
#push-options "--max_fuel 1"
let lemma_ws_computed_is_ws (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (ws_computed b t == ws SHA2_256 b t)
=
Pervasives.reveal_opaque (`%ws) ws;
if t < block_word_length SHA2_256 then (
assert (vv (ws_computed b t) == ws_opaque b t);
assert (to_uint32 (ws_opaque b t) == ws SHA2_256 b t);
()
) else (
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
lemma_add_mod_ws_rearrangement s1 t7 s0 t16;
()
)
#pop-options
let lemma_ws_computed_is_ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (vv (ws_computed b t) == ws_opaque b t)
=
lemma_ws_computed_is_ws b t;
Pervasives.reveal_opaque (`%ws) ws;
()
let ws_computed_quad32 (t:counter{t < size_k_w_256 - 3}) (block:block_w) : quad32 =
Mkfour (vv (ws_computed block t))
(vv (ws_computed block (t+1)))
(vv (ws_computed block (t+2)))
(vv (ws_computed block (t+3)))
let lemma_ws_computed_is_ws_quad32 (b:block_w) (t:counter{t < size_k_w_256 - 3}) :
Lemma (ws_computed_quad32 t b == ws_quad32 t b)
=
let w = ws_computed_quad32 t b in
let w' = ws_quad32 t b in
lemma_ws_computed_is_ws_opaque b t;
lemma_ws_computed_is_ws_opaque b (t+1);
lemma_ws_computed_is_ws_opaque b (t+2);
lemma_ws_computed_is_ws_opaque b (t+3);
()
#push-options "--z3rlimit 30"
let lemma_ws_computed_quad32 (t:counter{16 <= t /\ t < size_k_w_256 - 4}) (block:block_w) :
Lemma (let t_minus_16 = ws_quad32 (t-16) block in
let t_minus_15 = ws_quad32 (t-15) block in
let t_minus_7 = ws_quad32 (t - 7) block in
let t_minus_2 = ws_quad32 (t - 2) block in
let m1 = add_mod_quad32 t_minus_16 (_sigma0_quad32 t_minus_15) in
let m2 = add_mod_quad32 m1 t_minus_7 in
let m3 = add_mod_quad32 m2 (_sigma1_quad32 t_minus_2) in
m3 == ws_computed_quad32 t block )
=
()
#pop-options
let sha256_msg1_spec_t (t:counter{t < size_k_w_256 - 1}) (block:block_w) : quad32 =
let init = ws_quad32 t block in
let next = ws_quad32 (t + 1) block in
let msg1 = add_mod_quad32 init (_sigma0_quad32 next) in
msg1
#push-options "--ifuel 1"
let lemma_sha256_msg1_spec_t_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 - 3)
(ensures ws_partial t block == sha256_msg1_spec_t (t-16) block)
=
ws_partial_reveal ();
let init = ws_quad32 (t-16) block in
let next = ws_quad32 (t-15) block in
lemma_add_wrap_quad32_is_add_mod_quad32 init (_sigma0_quad32 next);
()
#pop-options
let lemma_sha256_msg1_spec_t (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w_256 - 4 /\
src1 == ws_quad32 t block /\
src2.lo0 == ws_opaque block (t+4))
(ensures sha256_msg1_spec_t t block == sha256_msg1_spec src1 src2)
=
sha256_msg1_spec_reveal ();
()
#push-options "--z3rlimit 70"
let lemma_sha256_step2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1) /\
(let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
src1 == add_mod_quad32 w mid))
(ensures sha256_msg2_spec src1 src2 == ws_computed_quad32 t block)
=
sha256_msg2_spec_reveal ();
let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
let final = sha256_msg2_spec src1 src2 in
lemma_ws_computed_is_ws_opaque block (t);
lemma_ws_computed_is_ws_opaque block (t+1);
()
#pop-options
// Top-level proof for the SHA256_msg2 instruction
let lemma_sha256_msg2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
(let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
src1 == add_wrap_quad32 step1 t_minus_7 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1)))
(ensures sha256_msg2_spec src1 src2 == ws_quad32 t block)
=
let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
lemma_sha256_msg1_spec_t_partial t block;
// ==> step1 == sha256_msg1_spec_t (t-16) block
lemma_add_wrap_quad32_is_add_mod_quad32 step1 t_minus_7;
lemma_sha256_step2 src1 src2 t block;
lemma_ws_computed_is_ws_quad32 block t;
()
(* Abbreviations and lemmas for the code itself *)
#reset-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block qs
=
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32);
reveal_opaque (`%ws) ws
#reset-options "--max_fuel 0 --max_ifuel 0"
let translate_hash_update (h0 h1 h0' h1' a0 a1:quad32) : Lemma
(requires h0' == add_wrap_quad32 a0 h0 /\
h1' == add_wrap_quad32 a1 h1)
(ensures (
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
mapped == h'))
=
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
assert (equal mapped h');
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_lemma (src1 src2 src1' src2' h0 h1:quad32) (block:block_w) : Lemma
(requires (let hash_orig = make_hash h0 h1 in
make_hash src1 src2 ==
Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash_orig /\
src1' == add_wrap_quad32 src1 h0 /\
src2' == add_wrap_quad32 src2 h1))
(ensures (let hash_orig = make_hash h0 h1 in
make_hash src1' src2' == update_block hash_orig block))
=
let hash_orig = make_hash h0 h1 in
let hash_1 = shuffle_opaque SHA2_256 hash_orig block in
Pervasives.reveal_opaque (`%shuffle) shuffle;
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let rec f (i:nat{i <= 64}) : Lemma (
Spec.Loops.repeat_range 0 i (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 i (shuffle_core SHA2_256 block) hash_orig)
=
if i = 0 then (
Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_base 0 (shuffle_core SHA2_256 block) hash_orig
) else (
f (i - 1);
Spec.Loops.repeat_range_induction 0 i (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_induction 0 i (shuffle_core SHA2_256 block) hash_orig
)
in
f 64;
(*
let h = make_hash src1 src2 in
assert (forall (block:block_w) (hash:hash256) . FStar.FunctionalExtensionality.feq (shuffle_core_opaque block hash) (shuffle_core_opaque_aux SHA2_256 block hash));
//assert (forall (block:block_w) . (shuffle_core_opaque block) == (shuffle_core_opaque_aux SHA2_256 block));
assert (shuffle_core_opaque == shuffle_core_opaque_aux SHA2_256);
assert (shuffle_core_opaque == shuffle_core SHA2_256);
assert (shuffle_core_opaque block == shuffle_core SHA2_256 block);
assert (Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 64 (shuffle_core SHA2_256 block) hash_orig);
assert (make_hash src1 src2 == shuffle SHA2_256 hash_orig block);
assert (make_hash src1 src2 == shuffle_opaque SHA2_256 hash_orig block);
*)
translate_hash_update src1 src2 src1' src2' h0 h1;
shuffle_is_shuffle_pre SHA2_256 hash_orig block;
assert (equal (make_hash src1' src2') (update_block hash_orig block));
()
let lemma_le_bytes_to_seq_quad32_empty (b:seq nat8) : Lemma
(requires b == empty)
(ensures le_bytes_to_seq_quad32 b == empty)
=
reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32;
assert (equal (le_bytes_to_seq_quad32 b) empty)
let lemma_le_bytes_to_seq_quad32_length (b:seq nat8) : Lemma
(requires length b % 16 == 0)
(ensures length (le_bytes_to_seq_quad32 b) == length b / 16)
=
reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32;
()
#push-options "--max_fuel 1" // Without this, F* refuses to do even one unfolding of recursive functions :(
let lemma_slice_commutes_reverse_bytes_nat32_quad32_seq (s:seq quad32) (pivot:nat) : Lemma
(requires pivot <= length s)
(ensures slice (reverse_bytes_nat32_quad32_seq s) 0 pivot == reverse_bytes_nat32_quad32_seq (slice s 0 pivot))
=
let rs = reverse_bytes_nat32_quad32_seq s in
let srs = slice (reverse_bytes_nat32_quad32_seq s) 0 pivot in
let ss = slice s 0 pivot in
let rss = reverse_bytes_nat32_quad32_seq ss in
if pivot = 0 then (
assert (equal ss empty);
assert (equal srs empty);
assert (equal empty (reverse_bytes_nat32_quad32_seq empty));
()
) else (
assert (equal srs rss)
)
// One level of expansion that we can use in places that can't use fuel
let lemma_update_multi_quads_unfold (s:seq quad32) (hash_orig:hash256) : Lemma
(requires length s >= 4)
(ensures (let prefix, qs = split s (length s - 4) in
let h_prefix = update_multi_quads prefix hash_orig in
let hash = update_block h_prefix (quads_to_block qs) in
update_multi_quads s hash_orig == hash))
=
()
let lemma_update_multi_quads_short (s:seq quad32) (hash_orig:hash256) : Lemma
(requires length s < 4)
(ensures update_multi_quads s hash_orig == hash_orig)
=
()
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
#pop-options
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s) | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"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": 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",
"smt.arith.nl=true"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_be_to_n_4 (s: seq4 nat8)
: Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) ==
be_bytes_to_nat32 s) | [] | Vale.SHA.SHA_helpers.lemma_be_to_n_4 | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: Vale.Def.Words.Seq_s.seq4 Vale.Def.Words_s.nat8
-> FStar.Pervasives.Lemma
(ensures
Lib.ByteSequence.nat_from_bytes_be (Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 s) ==
Vale.Def.Types_s.be_bytes_to_nat32 s) | {
"end_col": 3,
"end_line": 794,
"start_col": 2,
"start_line": 769
} |
FStar.Pervasives.Lemma | val lemma_update_multi_equiv_vale (hash hash':hash256) (quads:seq quad32) (r_quads:seq quad32)
(nat8s:seq nat8) (blocks:seq byte) :
Lemma (requires length quads % 4 == 0 /\
r_quads == reverse_bytes_nat32_quad32_seq quads /\
nat8s == le_seq_quad32_to_bytes quads /\
blocks == seq_nat8_to_seq_uint8 nat8s /\
hash' == update_multi_quads r_quads hash)
(ensures
length blocks % size_k_w_256 == 0 /\
hash' == update_multi_opaque_vale hash blocks) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec lemma_update_multi_equiv_vale (hash hash':hash256) (quads:seq quad32) (r_quads:seq quad32)
(nat8s:seq nat8) (blocks:seq UInt8.t) :
Lemma (requires length quads % 4 == 0 /\
r_quads == reverse_bytes_nat32_quad32_seq quads /\
nat8s == le_seq_quad32_to_bytes quads /\
blocks == seq_nat8_to_seq_uint8 nat8s /\
hash' == update_multi_quads r_quads hash)
(ensures
length blocks % 64 == 0 /\
hash' == update_multi_opaque_vale hash blocks)
(decreases (length quads))
=
lemma_mod_transform quads;
assert (length blocks % 64 == 0);
update_multi_reveal ();
if length quads = 0 then begin
lemma_le_seq_quad32_to_bytes_length quads;
//assert (length nat8s == 0);
//assert (length r_quads == 0);
lemma_update_multi_quads_short r_quads hash;
//assert (hash' == hash);
//assert (length blocks == 0);
assert (equal blocks empty);
update_multi_zero SHA2_256 hash;
//assert (update_multi SHA2_256 hash blocks == hash);
()
end else begin
let num_blocks = (length quads) / 4 in
let bytes_pivot = (num_blocks - 1) * 64 in
// Use associativity of update_multi to rearrange recursion to better match update_multi_quads' recursion
let input1,input2 = Lib.UpdateMulti.split_block block_length blocks (bytes_pivot / 64) in
let h_bytes1 = update_multi SHA2_256 hash () input1 in
let h_bytes2 = update_multi SHA2_256 h_bytes1 () input2 in
update_multi_associative SHA2_256 hash input1 input2;
assert (input1 `Seq.append` input2 == blocks);
Seq.lemma_eq_intro h_bytes2 (update_multi SHA2_256 hash () blocks);
assert (h_bytes2 == update_multi SHA2_256 hash () blocks);
// Unfold update_multi_quads one level, so we can start matching parts up
let prefix, qs = split r_quads (length r_quads - 4) in
let h_prefix = update_multi_quads prefix hash in
let h_final = update_block h_prefix (quads_to_block qs) in
lemma_update_multi_quads_unfold r_quads hash;
// hash' == update_multi_quads r_quads hash == h_final
(*+ Goal: h_bytes_2 == h_final +*)
(* Step 1: Show that h_prefix == h_bytes1 *)
// Inductive hypothesis says that we roughly line up on input1
let r_prefix = reverse_bytes_nat32_quad32_seq prefix in
lemma_update_multi_equiv_vale hash h_prefix r_prefix prefix
(le_seq_quad32_to_bytes r_prefix)
(seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes r_prefix));
assert (h_prefix == update_multi SHA2_256 hash () (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes r_prefix)));
// To show that h_prefix == h_bytes1, we need to show that:
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes r_prefix) == input1
// calc {
// input1
// slice blocks 0 bytes_pivot
// slice ( (le_seq_quad32_to_bytes quads)) 0 bytes_pivot
assert (equal (slice (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) 0 bytes_pivot)
(seq_nat8_to_seq_uint8 (slice (le_seq_quad32_to_bytes quads) 0 bytes_pivot)));
// seq_nat8_to_seq_U8 (slice (le_seq_quad32_to_bytes quads) 0 bytes_pivot)
slice_commutes_le_seq_quad32_to_bytes0 quads (bytes_pivot / 16);
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads 0 (bytes_pivot / 16)))
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads 0 ((num_blocks - 1) * 4)))
assert (bytes_pivot / 16 == length quads - 4);
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads 0 (length quads - 4)))
//
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads 0 (length quads - 4)))))
assert (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq (slice quads 0 (length quads - 4))) == slice quads 0 (length quads - 4));
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq (slice quads 0 (length quads - 4)))))
Vale.Lib.Seqs.slice_seq_map_commute reverse_bytes_nat32_quad32 quads 0 (length quads - 4);
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (reverse_bytes_nat32_quad32_seq (slice (reverse_bytes_nat32_quad32_seq quads) 0 (length quads - 4)))
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes r_prefix)
// }
// assert (seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes r_prefix) == input1); // Conclusion of the calc
assert (Seq.equal h_prefix h_bytes1); // Conclusion of Step 1
// To invoke lemma_endian_relation below,
// we need to show (1):
// calc {
// qs
Vale.Lib.Seqs.slice_seq_map_commute reverse_bytes_nat32_quad32 quads (length quads - 4) (length quads);
// slice (reverse_bytes_nat32_quad32_seq quads) (length quads - 4) (length quads))
// reverse_bytes_nat32_quad32_seq (slice quads (length quads - 4) (length quads))
// }
// And (2):
// calc {
// input2
// slice blocks bytes_pivot (length blocks)
// slice (seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes quads)) bytes_pivot (length blocks)
// assert (equal (slice (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) bytes_pivot (length blocks))
// (seq_nat8_to_seq_uint8 (slice (le_seq_quad32_to_bytes quads) bytes_pivot (length blocks))));
// seq_nat8_to_seq_U8 (slice (le_seq_quad32_to_bytes quads) bytes_pivot (length blocks))
slice_commutes_le_seq_quad32_to_bytes quads (bytes_pivot/16) ((length blocks)/16);
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads bytes_pivot/16 (length blocks)/16)
//
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads (length quads - 4) (length quads))))
// }
//assert (input2 == seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads (length quads - 4) (length quads)))); // Conclusion of the calc
(* Step 2: Show that update_block SHA2_256 h_prefix (quads_to_block qs) == update_multi SHA2_256 h_bytes1 input2 *)
// calc {
// update_block SHA2_256 h_prefix (quads_to_block qs)
// { from Step 1 }
// update_block SHA2_256 h_bytes1 (quads_to_block qs)
//
assert (equal input2 (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (slice quads (length quads - 4) (length quads)))));
lemma_endian_relation (slice quads (length quads - 4) (length quads)) qs
input2; // ==> quads_to_block qs == words_of_bytes SHA2_256 block_word_length input2
// update_block SHA2_256 h_bytes1 (words_of_bytes SHA2_256 16 input2)
lemma_update_block_equiv h_bytes1 input2;
// update SHA2_256 h_bytes1 input2
update_multi_one h_bytes1 input2;
// update_multi SHA2_256 h_bytes1 input2
// }
//
// assert (update_block SHA2_256 h_prefix (quads_to_block qs) == update_multi SHA2_256 h_bytes1 input2); // Conclusion of calc
// assert (h_final == h_bytes2); // Conclusion of Goal
()
end | val lemma_update_multi_equiv_vale (hash hash':hash256) (quads:seq quad32) (r_quads:seq quad32)
(nat8s:seq nat8) (blocks:seq byte) :
Lemma (requires length quads % 4 == 0 /\
r_quads == reverse_bytes_nat32_quad32_seq quads /\
nat8s == le_seq_quad32_to_bytes quads /\
blocks == seq_nat8_to_seq_uint8 nat8s /\
hash' == update_multi_quads r_quads hash)
(ensures
length blocks % size_k_w_256 == 0 /\
hash' == update_multi_opaque_vale hash blocks)
let rec lemma_update_multi_equiv_vale
(hash hash': hash256)
(quads r_quads: seq quad32)
(nat8s: seq nat8)
(blocks: seq UInt8.t)
: Lemma
(requires
length quads % 4 == 0 /\ r_quads == reverse_bytes_nat32_quad32_seq quads /\
nat8s == le_seq_quad32_to_bytes quads /\ blocks == seq_nat8_to_seq_uint8 nat8s /\
hash' == update_multi_quads r_quads hash)
(ensures length blocks % 64 == 0 /\ hash' == update_multi_opaque_vale hash blocks)
(decreases (length quads)) = | false | null | true | lemma_mod_transform quads;
assert (length blocks % 64 == 0);
update_multi_reveal ();
if length quads = 0
then
(lemma_le_seq_quad32_to_bytes_length quads;
lemma_update_multi_quads_short r_quads hash;
assert (equal blocks empty);
update_multi_zero SHA2_256 hash;
())
else
let num_blocks = (length quads) / 4 in
let bytes_pivot = (num_blocks - 1) * 64 in
let input1, input2 = Lib.UpdateMulti.split_block block_length blocks (bytes_pivot / 64) in
let h_bytes1 = update_multi SHA2_256 hash () input1 in
let h_bytes2 = update_multi SHA2_256 h_bytes1 () input2 in
update_multi_associative SHA2_256 hash input1 input2;
assert (input1 `Seq.append` input2 == blocks);
Seq.lemma_eq_intro h_bytes2 (update_multi SHA2_256 hash () blocks);
assert (h_bytes2 == update_multi SHA2_256 hash () blocks);
let prefix, qs = split r_quads (length r_quads - 4) in
let h_prefix = update_multi_quads prefix hash in
let h_final = update_block h_prefix (quads_to_block qs) in
lemma_update_multi_quads_unfold r_quads hash;
let r_prefix = reverse_bytes_nat32_quad32_seq prefix in
lemma_update_multi_equiv_vale hash
h_prefix
r_prefix
prefix
(le_seq_quad32_to_bytes r_prefix)
(seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes r_prefix));
assert (h_prefix ==
update_multi SHA2_256 hash () (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes r_prefix)));
assert (equal (slice (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) 0 bytes_pivot)
(seq_nat8_to_seq_uint8 (slice (le_seq_quad32_to_bytes quads) 0 bytes_pivot)));
slice_commutes_le_seq_quad32_to_bytes0 quads (bytes_pivot / 16);
assert (bytes_pivot / 16 == length quads - 4);
assert (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq (slice quads
0
(length quads - 4))) ==
slice quads 0 (length quads - 4));
Vale.Lib.Seqs.slice_seq_map_commute reverse_bytes_nat32_quad32 quads 0 (length quads - 4);
assert (Seq.equal h_prefix h_bytes1);
Vale.Lib.Seqs.slice_seq_map_commute reverse_bytes_nat32_quad32
quads
(length quads - 4)
(length quads);
slice_commutes_le_seq_quad32_to_bytes quads (bytes_pivot / 16) ((length blocks) / 16);
assert (equal input2
(seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (slice quads
(length quads - 4)
(length quads)))));
lemma_endian_relation (slice quads (length quads - 4) (length quads)) qs input2;
lemma_update_block_equiv h_bytes1 input2;
update_multi_one h_bytes1 input2;
() | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"",
"lemma"
] | [
"Vale.SHA.SHA_helpers.hash256",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.quad32",
"Vale.Def.Words_s.nat8",
"FStar.UInt8.t",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"Prims.unit",
"Spec.Hash.Lemmas.update_multi_zero",
"Spec.Hash.Definitions.SHA2_256",
"Prims._assert",
"FStar.Seq.Base.equal",
"FStar.Seq.Base.empty",
"Vale.SHA.SHA_helpers.lemma_update_multi_quads_short",
"Vale.Arch.Types.lemma_le_seq_quad32_to_bytes_length",
"Prims.bool",
"Lib.UpdateMulti.uint8",
"Vale.SHA.SHA_helpers.update_multi_one",
"Vale.SHA.SHA_helpers.lemma_update_block_equiv",
"Vale.SHA.SHA_helpers.lemma_endian_relation",
"FStar.Seq.Base.slice",
"Prims.op_Subtraction",
"Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8",
"Vale.Def.Types_s.le_seq_quad32_to_bytes",
"Vale.Arch.Types.slice_commutes_le_seq_quad32_to_bytes",
"Prims.op_Division",
"Vale.Lib.Seqs.slice_seq_map_commute",
"Vale.Arch.Types.reverse_bytes_nat32_quad32",
"Vale.SHA.SHA_helpers.word",
"Prims.eq2",
"Vale.Arch.Types.reverse_bytes_nat32_quad32_seq",
"Vale.Arch.Types.slice_commutes_le_seq_quad32_to_bytes0",
"Vale.Def.Types_s.nat8",
"Spec.Hash.Definitions.word",
"Prims.l_or",
"Prims.nat",
"Spec.Hash.Definitions.state_word_length",
"Prims.b2t",
"Spec.Agile.Hash.update_multi",
"Vale.SHA.SHA_helpers.lemma_update_multi_equiv_vale",
"Vale.SHA.SHA_helpers.lemma_update_multi_quads_unfold",
"Vale.SHA.SHA_helpers.update_block",
"Vale.SHA.SHA_helpers.quads_to_block",
"Vale.SHA.SHA_helpers.update_multi_quads",
"FStar.Pervasives.Native.tuple2",
"FStar.Seq.Properties.split",
"Spec.Hash.Definitions.words_state",
"FStar.Seq.Base.lemma_eq_intro",
"FStar.Seq.Base.append",
"Spec.Hash.Lemmas.update_multi_associative",
"Lib.UpdateMulti.split_block",
"Vale.SHA.SHA_helpers.block_length",
"FStar.Mul.op_Star",
"Vale.SHA.SHA_helpers.update_multi_reveal",
"Prims.op_Modulus",
"Vale.SHA.SHA_helpers.lemma_mod_transform",
"Prims.l_and",
"Prims.squash",
"Vale.SHA.SHA_helpers.update_multi_opaque_vale",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
// Top-level proof for the SHA256_msg1 instruction
let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
=
sha256_msg1_spec_reveal ();
let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
let ws_computed (b:block_w) (t:counter{t < size_k_w_256}): Tot (UInt32.t) =
if t < block_word_length SHA2_256 then to_uint32 (ws_opaque b t)
else
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
let open Lib.IntTypes in
(t16 +. s0 +. t7 +. s1)
#push-options "--max_fuel 1"
let lemma_ws_computed_is_ws (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (ws_computed b t == ws SHA2_256 b t)
=
Pervasives.reveal_opaque (`%ws) ws;
if t < block_word_length SHA2_256 then (
assert (vv (ws_computed b t) == ws_opaque b t);
assert (to_uint32 (ws_opaque b t) == ws SHA2_256 b t);
()
) else (
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
lemma_add_mod_ws_rearrangement s1 t7 s0 t16;
()
)
#pop-options
let lemma_ws_computed_is_ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (vv (ws_computed b t) == ws_opaque b t)
=
lemma_ws_computed_is_ws b t;
Pervasives.reveal_opaque (`%ws) ws;
()
let ws_computed_quad32 (t:counter{t < size_k_w_256 - 3}) (block:block_w) : quad32 =
Mkfour (vv (ws_computed block t))
(vv (ws_computed block (t+1)))
(vv (ws_computed block (t+2)))
(vv (ws_computed block (t+3)))
let lemma_ws_computed_is_ws_quad32 (b:block_w) (t:counter{t < size_k_w_256 - 3}) :
Lemma (ws_computed_quad32 t b == ws_quad32 t b)
=
let w = ws_computed_quad32 t b in
let w' = ws_quad32 t b in
lemma_ws_computed_is_ws_opaque b t;
lemma_ws_computed_is_ws_opaque b (t+1);
lemma_ws_computed_is_ws_opaque b (t+2);
lemma_ws_computed_is_ws_opaque b (t+3);
()
#push-options "--z3rlimit 30"
let lemma_ws_computed_quad32 (t:counter{16 <= t /\ t < size_k_w_256 - 4}) (block:block_w) :
Lemma (let t_minus_16 = ws_quad32 (t-16) block in
let t_minus_15 = ws_quad32 (t-15) block in
let t_minus_7 = ws_quad32 (t - 7) block in
let t_minus_2 = ws_quad32 (t - 2) block in
let m1 = add_mod_quad32 t_minus_16 (_sigma0_quad32 t_minus_15) in
let m2 = add_mod_quad32 m1 t_minus_7 in
let m3 = add_mod_quad32 m2 (_sigma1_quad32 t_minus_2) in
m3 == ws_computed_quad32 t block )
=
()
#pop-options
let sha256_msg1_spec_t (t:counter{t < size_k_w_256 - 1}) (block:block_w) : quad32 =
let init = ws_quad32 t block in
let next = ws_quad32 (t + 1) block in
let msg1 = add_mod_quad32 init (_sigma0_quad32 next) in
msg1
#push-options "--ifuel 1"
let lemma_sha256_msg1_spec_t_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 - 3)
(ensures ws_partial t block == sha256_msg1_spec_t (t-16) block)
=
ws_partial_reveal ();
let init = ws_quad32 (t-16) block in
let next = ws_quad32 (t-15) block in
lemma_add_wrap_quad32_is_add_mod_quad32 init (_sigma0_quad32 next);
()
#pop-options
let lemma_sha256_msg1_spec_t (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w_256 - 4 /\
src1 == ws_quad32 t block /\
src2.lo0 == ws_opaque block (t+4))
(ensures sha256_msg1_spec_t t block == sha256_msg1_spec src1 src2)
=
sha256_msg1_spec_reveal ();
()
#push-options "--z3rlimit 70"
let lemma_sha256_step2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1) /\
(let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
src1 == add_mod_quad32 w mid))
(ensures sha256_msg2_spec src1 src2 == ws_computed_quad32 t block)
=
sha256_msg2_spec_reveal ();
let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
let final = sha256_msg2_spec src1 src2 in
lemma_ws_computed_is_ws_opaque block (t);
lemma_ws_computed_is_ws_opaque block (t+1);
()
#pop-options
// Top-level proof for the SHA256_msg2 instruction
let lemma_sha256_msg2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
(let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
src1 == add_wrap_quad32 step1 t_minus_7 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1)))
(ensures sha256_msg2_spec src1 src2 == ws_quad32 t block)
=
let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
lemma_sha256_msg1_spec_t_partial t block;
// ==> step1 == sha256_msg1_spec_t (t-16) block
lemma_add_wrap_quad32_is_add_mod_quad32 step1 t_minus_7;
lemma_sha256_step2 src1 src2 t block;
lemma_ws_computed_is_ws_quad32 block t;
()
(* Abbreviations and lemmas for the code itself *)
#reset-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block qs
=
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32);
reveal_opaque (`%ws) ws
#reset-options "--max_fuel 0 --max_ifuel 0"
let translate_hash_update (h0 h1 h0' h1' a0 a1:quad32) : Lemma
(requires h0' == add_wrap_quad32 a0 h0 /\
h1' == add_wrap_quad32 a1 h1)
(ensures (
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
mapped == h'))
=
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
assert (equal mapped h');
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_lemma (src1 src2 src1' src2' h0 h1:quad32) (block:block_w) : Lemma
(requires (let hash_orig = make_hash h0 h1 in
make_hash src1 src2 ==
Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash_orig /\
src1' == add_wrap_quad32 src1 h0 /\
src2' == add_wrap_quad32 src2 h1))
(ensures (let hash_orig = make_hash h0 h1 in
make_hash src1' src2' == update_block hash_orig block))
=
let hash_orig = make_hash h0 h1 in
let hash_1 = shuffle_opaque SHA2_256 hash_orig block in
Pervasives.reveal_opaque (`%shuffle) shuffle;
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let rec f (i:nat{i <= 64}) : Lemma (
Spec.Loops.repeat_range 0 i (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 i (shuffle_core SHA2_256 block) hash_orig)
=
if i = 0 then (
Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_base 0 (shuffle_core SHA2_256 block) hash_orig
) else (
f (i - 1);
Spec.Loops.repeat_range_induction 0 i (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_induction 0 i (shuffle_core SHA2_256 block) hash_orig
)
in
f 64;
(*
let h = make_hash src1 src2 in
assert (forall (block:block_w) (hash:hash256) . FStar.FunctionalExtensionality.feq (shuffle_core_opaque block hash) (shuffle_core_opaque_aux SHA2_256 block hash));
//assert (forall (block:block_w) . (shuffle_core_opaque block) == (shuffle_core_opaque_aux SHA2_256 block));
assert (shuffle_core_opaque == shuffle_core_opaque_aux SHA2_256);
assert (shuffle_core_opaque == shuffle_core SHA2_256);
assert (shuffle_core_opaque block == shuffle_core SHA2_256 block);
assert (Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 64 (shuffle_core SHA2_256 block) hash_orig);
assert (make_hash src1 src2 == shuffle SHA2_256 hash_orig block);
assert (make_hash src1 src2 == shuffle_opaque SHA2_256 hash_orig block);
*)
translate_hash_update src1 src2 src1' src2' h0 h1;
shuffle_is_shuffle_pre SHA2_256 hash_orig block;
assert (equal (make_hash src1' src2') (update_block hash_orig block));
()
let lemma_le_bytes_to_seq_quad32_empty (b:seq nat8) : Lemma
(requires b == empty)
(ensures le_bytes_to_seq_quad32 b == empty)
=
reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32;
assert (equal (le_bytes_to_seq_quad32 b) empty)
let lemma_le_bytes_to_seq_quad32_length (b:seq nat8) : Lemma
(requires length b % 16 == 0)
(ensures length (le_bytes_to_seq_quad32 b) == length b / 16)
=
reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32;
()
#push-options "--max_fuel 1" // Without this, F* refuses to do even one unfolding of recursive functions :(
let lemma_slice_commutes_reverse_bytes_nat32_quad32_seq (s:seq quad32) (pivot:nat) : Lemma
(requires pivot <= length s)
(ensures slice (reverse_bytes_nat32_quad32_seq s) 0 pivot == reverse_bytes_nat32_quad32_seq (slice s 0 pivot))
=
let rs = reverse_bytes_nat32_quad32_seq s in
let srs = slice (reverse_bytes_nat32_quad32_seq s) 0 pivot in
let ss = slice s 0 pivot in
let rss = reverse_bytes_nat32_quad32_seq ss in
if pivot = 0 then (
assert (equal ss empty);
assert (equal srs empty);
assert (equal empty (reverse_bytes_nat32_quad32_seq empty));
()
) else (
assert (equal srs rss)
)
// One level of expansion that we can use in places that can't use fuel
let lemma_update_multi_quads_unfold (s:seq quad32) (hash_orig:hash256) : Lemma
(requires length s >= 4)
(ensures (let prefix, qs = split s (length s - 4) in
let h_prefix = update_multi_quads prefix hash_orig in
let hash = update_block h_prefix (quads_to_block qs) in
update_multi_quads s hash_orig == hash))
=
()
let lemma_update_multi_quads_short (s:seq quad32) (hash_orig:hash256) : Lemma
(requires length s < 4)
(ensures update_multi_quads s hash_orig == hash_orig)
=
()
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
#pop-options
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 40"
let lemma_endian_relation (quads qs:seq quad32) (input2:seq UInt8.t) : Lemma
(requires length qs == 4 /\ length input2 == 64 /\
qs == reverse_bytes_nat32_quad32_seq quads /\
input2 == seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads))
(ensures quads_to_block qs == words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2)
=
let fi (i:nat{i < length (quads_to_block qs)}) : Lemma
((quads_to_block qs).[i] == (words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2).[i])
=
let open Vale.Def.Words.Four_s in
let open Vale.Lib.Seqs_s in
let ni = (seq_four_to_seq_LE quads).[i] in
let b = slice input2 (4 * i) (4 * i + 4) in
// FStar.Krml.Endianness.lemma_be_to_n_is_bounded b;
calc (==) {
b;
== {}
slice input2 (4 * i) (4 * i + 4);
== {}
slice (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) (4 * i) (4 * i + 4);
== {le_seq_quad32_to_bytes_reveal ()}
slice (seq_nat8_to_seq_uint8 (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE quads))) (4 * i) (4 * i + 4);
equal {}
seq_nat8_to_seq_uint8 (slice (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE quads)) (4 * i) (4 * i + 4));
== {}
seq_nat8_to_seq_uint8 (slice (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE quads))) (4 * i) (4 * i + 4));
== {slice_commutes_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE quads)) i (i + 1)}
seq_nat8_to_seq_uint8 (seq_four_to_seq_LE (slice (seq_map (nat_to_four 8) (seq_four_to_seq_LE quads)) i (i + 1)));
equal {reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat8)}
seq_nat8_to_seq_uint8 (four_to_seq_LE (nat_to_four 8 (seq_four_to_seq_LE quads).[i]));
};
let open Lib.IntTypes in
calc (==) {
(words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2).[i];
== { }
(Lib.ByteSequence.uints_from_bytes_be #U32 #SEC #(block_word_length SHA2_256) input2).[i];
== { Lib.ByteSequence.index_uints_from_bytes_be #U32 #SEC #(block_word_length SHA2_256) input2 i }
Lib.ByteSequence.uint_from_bytes_be (Lib.Sequence.sub #uint8 #64 input2 (i * 4) 4);
== { let open Lib.Sequence in
calc (==) {
sub #uint8 #64 input2 (i * 4) 4;
== { }
Seq.slice input2 (4 * i) (4 * i + 4);
}
}
Lib.ByteSequence.uint_from_bytes_be #U32 #SEC b;
== { calc (==) {
Lib.ByteSequence.nat_from_bytes_be #SEC b;
(==) { }
Lib.ByteSequence.nat_from_bytes_be #SEC (seq_nat8_to_seq_uint8 (four_to_seq_LE (nat_to_four 8 ni)));
(==) { lemma_be_to_n_4 (four_to_seq_LE (nat_to_four 8 ni)) }
be_bytes_to_nat32 (four_to_seq_LE (nat_to_four 8 ni));
};
v_inj (Lib.ByteSequence.uint_from_bytes_be #U32 #SEC b)
(u32 (be_bytes_to_nat32 (four_to_seq_LE (nat_to_four 8 ni))))
}
nat32_to_word (be_bytes_to_nat32 (four_to_seq_LE (nat_to_four 8 ni)));
== {}
nat32_to_word (be_bytes_to_nat32 (reverse_seq (nat32_to_be_bytes ni)));
== {reverse_bytes_nat32_reveal ()}
nat32_to_word (reverse_bytes_nat32 ni);
== {}
nat32_to_word (reverse_bytes_nat32 (seq_four_to_seq_LE quads).[i]);
== {reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32)}
nat32_to_word (seq_four_to_seq_LE qs).[i];
== {}
(quads_to_block qs).[i];
}
in
FStar.Classical.forall_intro fi;
assert (equal (quads_to_block qs) (words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2))
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
#reset-options "--max_fuel 0 --ifuel 1 --z3rlimit 20"
let rec lemma_update_multi_equiv_vale (hash hash':hash256) (quads:seq quad32) (r_quads:seq quad32)
(nat8s:seq nat8) (blocks:seq UInt8.t) :
Lemma (requires length quads % 4 == 0 /\
r_quads == reverse_bytes_nat32_quad32_seq quads /\
nat8s == le_seq_quad32_to_bytes quads /\
blocks == seq_nat8_to_seq_uint8 nat8s /\
hash' == update_multi_quads r_quads hash)
(ensures
length blocks % 64 == 0 /\
hash' == update_multi_opaque_vale hash blocks)
(decreases (length quads)) | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": 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"
} | null | val lemma_update_multi_equiv_vale (hash hash':hash256) (quads:seq quad32) (r_quads:seq quad32)
(nat8s:seq nat8) (blocks:seq byte) :
Lemma (requires length quads % 4 == 0 /\
r_quads == reverse_bytes_nat32_quad32_seq quads /\
nat8s == le_seq_quad32_to_bytes quads /\
blocks == seq_nat8_to_seq_uint8 nat8s /\
hash' == update_multi_quads r_quads hash)
(ensures
length blocks % size_k_w_256 == 0 /\
hash' == update_multi_opaque_vale hash blocks) | [
"recursion"
] | Vale.SHA.SHA_helpers.lemma_update_multi_equiv_vale | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
hash: Vale.SHA.SHA_helpers.hash256 ->
hash': Vale.SHA.SHA_helpers.hash256 ->
quads: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
r_quads: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
nat8s: FStar.Seq.Base.seq Vale.Def.Words_s.nat8 ->
blocks: FStar.Seq.Base.seq Vale.SHA.SHA_helpers.byte
-> FStar.Pervasives.Lemma
(requires
FStar.Seq.Base.length quads % 4 == 0 /\
r_quads == Vale.Arch.Types.reverse_bytes_nat32_quad32_seq quads /\
nat8s == Vale.Def.Types_s.le_seq_quad32_to_bytes quads /\
blocks == Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 nat8s /\
hash' == Vale.SHA.SHA_helpers.update_multi_quads r_quads hash)
(ensures
FStar.Seq.Base.length blocks % Vale.SHA.SHA_helpers.size_k_w_256 == 0 /\
hash' == Vale.SHA.SHA_helpers.update_multi_opaque_vale hash blocks)
(decreases FStar.Seq.Base.length quads) | {
"end_col": 5,
"end_line": 1000,
"start_col": 2,
"start_line": 889
} |
FStar.Pervasives.Lemma | val lemma_hash_to_bytes (s:seq quad32) : Lemma
(requires length s == 2)
(ensures make_ordered_hash s.[0] s.[1] == le_bytes_to_hash (le_seq_quad32_to_bytes s)) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_hash_to_bytes (s:seq quad32) : Lemma
(requires length s == 2)
(ensures make_ordered_hash s.[0] s.[1] == le_bytes_to_hash (le_seq_quad32_to_bytes s))
=
lemma_le_bytes_to_hash_quads s;
assert (equal (make_ordered_hash s.[0] s.[1]) (le_bytes_to_hash (le_seq_quad32_to_bytes s)));
() | val lemma_hash_to_bytes (s:seq quad32) : Lemma
(requires length s == 2)
(ensures make_ordered_hash s.[0] s.[1] == le_bytes_to_hash (le_seq_quad32_to_bytes s))
let lemma_hash_to_bytes (s: seq quad32)
: Lemma (requires length s == 2)
(ensures make_ordered_hash s.[ 0 ] s.[ 1 ] == le_bytes_to_hash (le_seq_quad32_to_bytes s)) = | false | null | true | lemma_le_bytes_to_hash_quads s;
assert (equal (make_ordered_hash s.[ 0 ] s.[ 1 ]) (le_bytes_to_hash (le_seq_quad32_to_bytes s)));
() | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.quad32",
"Prims.unit",
"Prims._assert",
"FStar.Seq.Base.equal",
"Vale.SHA.SHA_helpers.word",
"Vale.SHA.SHA_helpers.make_ordered_hash",
"Spec.SHA2.op_String_Access",
"Vale.SHA.SHA_helpers.le_bytes_to_hash",
"Vale.Def.Types_s.le_seq_quad32_to_bytes",
"Vale.SHA.SHA_helpers.lemma_le_bytes_to_hash_quads",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"Prims.squash",
"Vale.SHA.SHA_helpers.hash256",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
// Top-level proof for the SHA256_msg1 instruction
let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
=
sha256_msg1_spec_reveal ();
let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
let ws_computed (b:block_w) (t:counter{t < size_k_w_256}): Tot (UInt32.t) =
if t < block_word_length SHA2_256 then to_uint32 (ws_opaque b t)
else
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
let open Lib.IntTypes in
(t16 +. s0 +. t7 +. s1)
#push-options "--max_fuel 1"
let lemma_ws_computed_is_ws (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (ws_computed b t == ws SHA2_256 b t)
=
Pervasives.reveal_opaque (`%ws) ws;
if t < block_word_length SHA2_256 then (
assert (vv (ws_computed b t) == ws_opaque b t);
assert (to_uint32 (ws_opaque b t) == ws SHA2_256 b t);
()
) else (
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
lemma_add_mod_ws_rearrangement s1 t7 s0 t16;
()
)
#pop-options
let lemma_ws_computed_is_ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (vv (ws_computed b t) == ws_opaque b t)
=
lemma_ws_computed_is_ws b t;
Pervasives.reveal_opaque (`%ws) ws;
()
let ws_computed_quad32 (t:counter{t < size_k_w_256 - 3}) (block:block_w) : quad32 =
Mkfour (vv (ws_computed block t))
(vv (ws_computed block (t+1)))
(vv (ws_computed block (t+2)))
(vv (ws_computed block (t+3)))
let lemma_ws_computed_is_ws_quad32 (b:block_w) (t:counter{t < size_k_w_256 - 3}) :
Lemma (ws_computed_quad32 t b == ws_quad32 t b)
=
let w = ws_computed_quad32 t b in
let w' = ws_quad32 t b in
lemma_ws_computed_is_ws_opaque b t;
lemma_ws_computed_is_ws_opaque b (t+1);
lemma_ws_computed_is_ws_opaque b (t+2);
lemma_ws_computed_is_ws_opaque b (t+3);
()
#push-options "--z3rlimit 30"
let lemma_ws_computed_quad32 (t:counter{16 <= t /\ t < size_k_w_256 - 4}) (block:block_w) :
Lemma (let t_minus_16 = ws_quad32 (t-16) block in
let t_minus_15 = ws_quad32 (t-15) block in
let t_minus_7 = ws_quad32 (t - 7) block in
let t_minus_2 = ws_quad32 (t - 2) block in
let m1 = add_mod_quad32 t_minus_16 (_sigma0_quad32 t_minus_15) in
let m2 = add_mod_quad32 m1 t_minus_7 in
let m3 = add_mod_quad32 m2 (_sigma1_quad32 t_minus_2) in
m3 == ws_computed_quad32 t block )
=
()
#pop-options
let sha256_msg1_spec_t (t:counter{t < size_k_w_256 - 1}) (block:block_w) : quad32 =
let init = ws_quad32 t block in
let next = ws_quad32 (t + 1) block in
let msg1 = add_mod_quad32 init (_sigma0_quad32 next) in
msg1
#push-options "--ifuel 1"
let lemma_sha256_msg1_spec_t_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 - 3)
(ensures ws_partial t block == sha256_msg1_spec_t (t-16) block)
=
ws_partial_reveal ();
let init = ws_quad32 (t-16) block in
let next = ws_quad32 (t-15) block in
lemma_add_wrap_quad32_is_add_mod_quad32 init (_sigma0_quad32 next);
()
#pop-options
let lemma_sha256_msg1_spec_t (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w_256 - 4 /\
src1 == ws_quad32 t block /\
src2.lo0 == ws_opaque block (t+4))
(ensures sha256_msg1_spec_t t block == sha256_msg1_spec src1 src2)
=
sha256_msg1_spec_reveal ();
()
#push-options "--z3rlimit 70"
let lemma_sha256_step2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1) /\
(let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
src1 == add_mod_quad32 w mid))
(ensures sha256_msg2_spec src1 src2 == ws_computed_quad32 t block)
=
sha256_msg2_spec_reveal ();
let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
let final = sha256_msg2_spec src1 src2 in
lemma_ws_computed_is_ws_opaque block (t);
lemma_ws_computed_is_ws_opaque block (t+1);
()
#pop-options
// Top-level proof for the SHA256_msg2 instruction
let lemma_sha256_msg2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
(let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
src1 == add_wrap_quad32 step1 t_minus_7 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1)))
(ensures sha256_msg2_spec src1 src2 == ws_quad32 t block)
=
let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
lemma_sha256_msg1_spec_t_partial t block;
// ==> step1 == sha256_msg1_spec_t (t-16) block
lemma_add_wrap_quad32_is_add_mod_quad32 step1 t_minus_7;
lemma_sha256_step2 src1 src2 t block;
lemma_ws_computed_is_ws_quad32 block t;
()
(* Abbreviations and lemmas for the code itself *)
#reset-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block qs
=
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32);
reveal_opaque (`%ws) ws
#reset-options "--max_fuel 0 --max_ifuel 0"
let translate_hash_update (h0 h1 h0' h1' a0 a1:quad32) : Lemma
(requires h0' == add_wrap_quad32 a0 h0 /\
h1' == add_wrap_quad32 a1 h1)
(ensures (
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
mapped == h'))
=
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
assert (equal mapped h');
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_lemma (src1 src2 src1' src2' h0 h1:quad32) (block:block_w) : Lemma
(requires (let hash_orig = make_hash h0 h1 in
make_hash src1 src2 ==
Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash_orig /\
src1' == add_wrap_quad32 src1 h0 /\
src2' == add_wrap_quad32 src2 h1))
(ensures (let hash_orig = make_hash h0 h1 in
make_hash src1' src2' == update_block hash_orig block))
=
let hash_orig = make_hash h0 h1 in
let hash_1 = shuffle_opaque SHA2_256 hash_orig block in
Pervasives.reveal_opaque (`%shuffle) shuffle;
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let rec f (i:nat{i <= 64}) : Lemma (
Spec.Loops.repeat_range 0 i (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 i (shuffle_core SHA2_256 block) hash_orig)
=
if i = 0 then (
Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_base 0 (shuffle_core SHA2_256 block) hash_orig
) else (
f (i - 1);
Spec.Loops.repeat_range_induction 0 i (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_induction 0 i (shuffle_core SHA2_256 block) hash_orig
)
in
f 64;
(*
let h = make_hash src1 src2 in
assert (forall (block:block_w) (hash:hash256) . FStar.FunctionalExtensionality.feq (shuffle_core_opaque block hash) (shuffle_core_opaque_aux SHA2_256 block hash));
//assert (forall (block:block_w) . (shuffle_core_opaque block) == (shuffle_core_opaque_aux SHA2_256 block));
assert (shuffle_core_opaque == shuffle_core_opaque_aux SHA2_256);
assert (shuffle_core_opaque == shuffle_core SHA2_256);
assert (shuffle_core_opaque block == shuffle_core SHA2_256 block);
assert (Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 64 (shuffle_core SHA2_256 block) hash_orig);
assert (make_hash src1 src2 == shuffle SHA2_256 hash_orig block);
assert (make_hash src1 src2 == shuffle_opaque SHA2_256 hash_orig block);
*)
translate_hash_update src1 src2 src1' src2' h0 h1;
shuffle_is_shuffle_pre SHA2_256 hash_orig block;
assert (equal (make_hash src1' src2') (update_block hash_orig block));
()
let lemma_le_bytes_to_seq_quad32_empty (b:seq nat8) : Lemma
(requires b == empty)
(ensures le_bytes_to_seq_quad32 b == empty)
=
reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32;
assert (equal (le_bytes_to_seq_quad32 b) empty)
let lemma_le_bytes_to_seq_quad32_length (b:seq nat8) : Lemma
(requires length b % 16 == 0)
(ensures length (le_bytes_to_seq_quad32 b) == length b / 16)
=
reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32;
()
#push-options "--max_fuel 1" // Without this, F* refuses to do even one unfolding of recursive functions :(
let lemma_slice_commutes_reverse_bytes_nat32_quad32_seq (s:seq quad32) (pivot:nat) : Lemma
(requires pivot <= length s)
(ensures slice (reverse_bytes_nat32_quad32_seq s) 0 pivot == reverse_bytes_nat32_quad32_seq (slice s 0 pivot))
=
let rs = reverse_bytes_nat32_quad32_seq s in
let srs = slice (reverse_bytes_nat32_quad32_seq s) 0 pivot in
let ss = slice s 0 pivot in
let rss = reverse_bytes_nat32_quad32_seq ss in
if pivot = 0 then (
assert (equal ss empty);
assert (equal srs empty);
assert (equal empty (reverse_bytes_nat32_quad32_seq empty));
()
) else (
assert (equal srs rss)
)
// One level of expansion that we can use in places that can't use fuel
let lemma_update_multi_quads_unfold (s:seq quad32) (hash_orig:hash256) : Lemma
(requires length s >= 4)
(ensures (let prefix, qs = split s (length s - 4) in
let h_prefix = update_multi_quads prefix hash_orig in
let hash = update_block h_prefix (quads_to_block qs) in
update_multi_quads s hash_orig == hash))
=
()
let lemma_update_multi_quads_short (s:seq quad32) (hash_orig:hash256) : Lemma
(requires length s < 4)
(ensures update_multi_quads s hash_orig == hash_orig)
=
()
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
#pop-options
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 40"
let lemma_endian_relation (quads qs:seq quad32) (input2:seq UInt8.t) : Lemma
(requires length qs == 4 /\ length input2 == 64 /\
qs == reverse_bytes_nat32_quad32_seq quads /\
input2 == seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads))
(ensures quads_to_block qs == words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2)
=
let fi (i:nat{i < length (quads_to_block qs)}) : Lemma
((quads_to_block qs).[i] == (words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2).[i])
=
let open Vale.Def.Words.Four_s in
let open Vale.Lib.Seqs_s in
let ni = (seq_four_to_seq_LE quads).[i] in
let b = slice input2 (4 * i) (4 * i + 4) in
// FStar.Krml.Endianness.lemma_be_to_n_is_bounded b;
calc (==) {
b;
== {}
slice input2 (4 * i) (4 * i + 4);
== {}
slice (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) (4 * i) (4 * i + 4);
== {le_seq_quad32_to_bytes_reveal ()}
slice (seq_nat8_to_seq_uint8 (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE quads))) (4 * i) (4 * i + 4);
equal {}
seq_nat8_to_seq_uint8 (slice (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE quads)) (4 * i) (4 * i + 4));
== {}
seq_nat8_to_seq_uint8 (slice (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE quads))) (4 * i) (4 * i + 4));
== {slice_commutes_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE quads)) i (i + 1)}
seq_nat8_to_seq_uint8 (seq_four_to_seq_LE (slice (seq_map (nat_to_four 8) (seq_four_to_seq_LE quads)) i (i + 1)));
equal {reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat8)}
seq_nat8_to_seq_uint8 (four_to_seq_LE (nat_to_four 8 (seq_four_to_seq_LE quads).[i]));
};
let open Lib.IntTypes in
calc (==) {
(words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2).[i];
== { }
(Lib.ByteSequence.uints_from_bytes_be #U32 #SEC #(block_word_length SHA2_256) input2).[i];
== { Lib.ByteSequence.index_uints_from_bytes_be #U32 #SEC #(block_word_length SHA2_256) input2 i }
Lib.ByteSequence.uint_from_bytes_be (Lib.Sequence.sub #uint8 #64 input2 (i * 4) 4);
== { let open Lib.Sequence in
calc (==) {
sub #uint8 #64 input2 (i * 4) 4;
== { }
Seq.slice input2 (4 * i) (4 * i + 4);
}
}
Lib.ByteSequence.uint_from_bytes_be #U32 #SEC b;
== { calc (==) {
Lib.ByteSequence.nat_from_bytes_be #SEC b;
(==) { }
Lib.ByteSequence.nat_from_bytes_be #SEC (seq_nat8_to_seq_uint8 (four_to_seq_LE (nat_to_four 8 ni)));
(==) { lemma_be_to_n_4 (four_to_seq_LE (nat_to_four 8 ni)) }
be_bytes_to_nat32 (four_to_seq_LE (nat_to_four 8 ni));
};
v_inj (Lib.ByteSequence.uint_from_bytes_be #U32 #SEC b)
(u32 (be_bytes_to_nat32 (four_to_seq_LE (nat_to_four 8 ni))))
}
nat32_to_word (be_bytes_to_nat32 (four_to_seq_LE (nat_to_four 8 ni)));
== {}
nat32_to_word (be_bytes_to_nat32 (reverse_seq (nat32_to_be_bytes ni)));
== {reverse_bytes_nat32_reveal ()}
nat32_to_word (reverse_bytes_nat32 ni);
== {}
nat32_to_word (reverse_bytes_nat32 (seq_four_to_seq_LE quads).[i]);
== {reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32)}
nat32_to_word (seq_four_to_seq_LE qs).[i];
== {}
(quads_to_block qs).[i];
}
in
FStar.Classical.forall_intro fi;
assert (equal (quads_to_block qs) (words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2))
let lemma_mod_transform (quads:seq quad32) : Lemma
(requires length quads % 4 == 0)
(ensures length (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) % 64 == 0)
=
()
#reset-options "--max_fuel 0 --ifuel 1 --z3rlimit 20"
let rec lemma_update_multi_equiv_vale (hash hash':hash256) (quads:seq quad32) (r_quads:seq quad32)
(nat8s:seq nat8) (blocks:seq UInt8.t) :
Lemma (requires length quads % 4 == 0 /\
r_quads == reverse_bytes_nat32_quad32_seq quads /\
nat8s == le_seq_quad32_to_bytes quads /\
blocks == seq_nat8_to_seq_uint8 nat8s /\
hash' == update_multi_quads r_quads hash)
(ensures
length blocks % 64 == 0 /\
hash' == update_multi_opaque_vale hash blocks)
(decreases (length quads))
=
lemma_mod_transform quads;
assert (length blocks % 64 == 0);
update_multi_reveal ();
if length quads = 0 then begin
lemma_le_seq_quad32_to_bytes_length quads;
//assert (length nat8s == 0);
//assert (length r_quads == 0);
lemma_update_multi_quads_short r_quads hash;
//assert (hash' == hash);
//assert (length blocks == 0);
assert (equal blocks empty);
update_multi_zero SHA2_256 hash;
//assert (update_multi SHA2_256 hash blocks == hash);
()
end else begin
let num_blocks = (length quads) / 4 in
let bytes_pivot = (num_blocks - 1) * 64 in
// Use associativity of update_multi to rearrange recursion to better match update_multi_quads' recursion
let input1,input2 = Lib.UpdateMulti.split_block block_length blocks (bytes_pivot / 64) in
let h_bytes1 = update_multi SHA2_256 hash () input1 in
let h_bytes2 = update_multi SHA2_256 h_bytes1 () input2 in
update_multi_associative SHA2_256 hash input1 input2;
assert (input1 `Seq.append` input2 == blocks);
Seq.lemma_eq_intro h_bytes2 (update_multi SHA2_256 hash () blocks);
assert (h_bytes2 == update_multi SHA2_256 hash () blocks);
// Unfold update_multi_quads one level, so we can start matching parts up
let prefix, qs = split r_quads (length r_quads - 4) in
let h_prefix = update_multi_quads prefix hash in
let h_final = update_block h_prefix (quads_to_block qs) in
lemma_update_multi_quads_unfold r_quads hash;
// hash' == update_multi_quads r_quads hash == h_final
(*+ Goal: h_bytes_2 == h_final +*)
(* Step 1: Show that h_prefix == h_bytes1 *)
// Inductive hypothesis says that we roughly line up on input1
let r_prefix = reverse_bytes_nat32_quad32_seq prefix in
lemma_update_multi_equiv_vale hash h_prefix r_prefix prefix
(le_seq_quad32_to_bytes r_prefix)
(seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes r_prefix));
assert (h_prefix == update_multi SHA2_256 hash () (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes r_prefix)));
// To show that h_prefix == h_bytes1, we need to show that:
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes r_prefix) == input1
// calc {
// input1
// slice blocks 0 bytes_pivot
// slice ( (le_seq_quad32_to_bytes quads)) 0 bytes_pivot
assert (equal (slice (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) 0 bytes_pivot)
(seq_nat8_to_seq_uint8 (slice (le_seq_quad32_to_bytes quads) 0 bytes_pivot)));
// seq_nat8_to_seq_U8 (slice (le_seq_quad32_to_bytes quads) 0 bytes_pivot)
slice_commutes_le_seq_quad32_to_bytes0 quads (bytes_pivot / 16);
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads 0 (bytes_pivot / 16)))
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads 0 ((num_blocks - 1) * 4)))
assert (bytes_pivot / 16 == length quads - 4);
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads 0 (length quads - 4)))
//
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads 0 (length quads - 4)))))
assert (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq (slice quads 0 (length quads - 4))) == slice quads 0 (length quads - 4));
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (reverse_bytes_nat32_quad32_seq (reverse_bytes_nat32_quad32_seq (slice quads 0 (length quads - 4)))))
Vale.Lib.Seqs.slice_seq_map_commute reverse_bytes_nat32_quad32 quads 0 (length quads - 4);
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (reverse_bytes_nat32_quad32_seq (slice (reverse_bytes_nat32_quad32_seq quads) 0 (length quads - 4)))
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes r_prefix)
// }
// assert (seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes r_prefix) == input1); // Conclusion of the calc
assert (Seq.equal h_prefix h_bytes1); // Conclusion of Step 1
// To invoke lemma_endian_relation below,
// we need to show (1):
// calc {
// qs
Vale.Lib.Seqs.slice_seq_map_commute reverse_bytes_nat32_quad32 quads (length quads - 4) (length quads);
// slice (reverse_bytes_nat32_quad32_seq quads) (length quads - 4) (length quads))
// reverse_bytes_nat32_quad32_seq (slice quads (length quads - 4) (length quads))
// }
// And (2):
// calc {
// input2
// slice blocks bytes_pivot (length blocks)
// slice (seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes quads)) bytes_pivot (length blocks)
// assert (equal (slice (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) bytes_pivot (length blocks))
// (seq_nat8_to_seq_uint8 (slice (le_seq_quad32_to_bytes quads) bytes_pivot (length blocks))));
// seq_nat8_to_seq_U8 (slice (le_seq_quad32_to_bytes quads) bytes_pivot (length blocks))
slice_commutes_le_seq_quad32_to_bytes quads (bytes_pivot/16) ((length blocks)/16);
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads bytes_pivot/16 (length blocks)/16)
//
// seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads (length quads - 4) (length quads))))
// }
//assert (input2 == seq_nat8_to_seq_U8 (le_seq_quad32_to_bytes (slice quads (length quads - 4) (length quads)))); // Conclusion of the calc
(* Step 2: Show that update_block SHA2_256 h_prefix (quads_to_block qs) == update_multi SHA2_256 h_bytes1 input2 *)
// calc {
// update_block SHA2_256 h_prefix (quads_to_block qs)
// { from Step 1 }
// update_block SHA2_256 h_bytes1 (quads_to_block qs)
//
assert (equal input2 (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes (slice quads (length quads - 4) (length quads)))));
lemma_endian_relation (slice quads (length quads - 4) (length quads)) qs
input2; // ==> quads_to_block qs == words_of_bytes SHA2_256 block_word_length input2
// update_block SHA2_256 h_bytes1 (words_of_bytes SHA2_256 16 input2)
lemma_update_block_equiv h_bytes1 input2;
// update SHA2_256 h_bytes1 input2
update_multi_one h_bytes1 input2;
// update_multi SHA2_256 h_bytes1 input2
// }
//
// assert (update_block SHA2_256 h_prefix (quads_to_block qs) == update_multi SHA2_256 h_bytes1 input2); // Conclusion of calc
// assert (h_final == h_bytes2); // Conclusion of Goal
()
end
//
#push-options "--max_fuel 1" // Without this, F* refuses to do even one unfolding of update_multi_quads :(
let lemma_update_multi_quads (s:seq quad32) (hash_orig:hash256) (bound:nat) : Lemma
(requires bound + 4 <= length s)
(ensures (let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_nat32_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_nat32_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound+4) in
let input_BE = reverse_bytes_nat32_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block block_quads_BE) in
h == update_multi_quads input_BE hash_orig))
=
let prefix_LE = slice s 0 bound in
let prefix_BE = reverse_bytes_nat32_quad32_seq prefix_LE in
let h_prefix = update_multi_quads prefix_BE hash_orig in
let block_quads_LE = slice s bound (bound + 4) in
let block_quads_BE = reverse_bytes_nat32_quad32_seq block_quads_LE in
let input_LE = slice s 0 (bound+4) in
let input_BE = reverse_bytes_nat32_quad32_seq input_LE in
let h = update_block h_prefix (quads_to_block block_quads_BE) in
lemma_slice_commutes_reverse_bytes_nat32_quad32_seq s bound;
lemma_slice_commutes_reverse_bytes_nat32_quad32_seq s (bound + 4);
assert (prefix_BE == slice (reverse_bytes_nat32_quad32_seq s) 0 bound);
assert (input_BE == slice (reverse_bytes_nat32_quad32_seq s) 0 (bound + 4));
if bound = 0 then ()
else (
let prefix, qs = split input_BE (length input_BE - 4) in
assert (equal prefix prefix_BE);
assert (equal qs block_quads_BE);
()
)
#pop-options
let lemma_le_bytes_to_hash_quads_part1 (s:seq quad32) : Lemma
(requires length s == 2)
(ensures le_bytes_to_hash (le_seq_quad32_to_bytes s) ==
Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s))
=
let lhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
assert (lhs == Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE (le_seq_quad32_to_bytes s)));
le_seq_quad32_to_bytes_reveal ();
Vale.Def.Words.Seq.seq_nat8_to_seq_nat32_to_seq_nat8_LE (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s);
()
//
#push-options "--z3rlimit 30"
let lemma_le_bytes_to_hash_quads (s:seq quad32) : Lemma
(requires length s == 2)
(ensures (let rhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
rhs.[0] == to_uint32 (s.[0]).lo0 /\
rhs.[1] == to_uint32 (s.[0]).lo1 /\
rhs.[2] == to_uint32 (s.[0]).hi2 /\
rhs.[3] == to_uint32 (s.[0]).hi3 /\
rhs.[4] == to_uint32 (s.[1]).lo0 /\
rhs.[5] == to_uint32 (s.[1]).lo1 /\
rhs.[6] == to_uint32 (s.[1]).hi2 /\
rhs.[7] == to_uint32 (s.[1]).hi3 /\
length rhs == 8))
=
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32);
let rhs = le_bytes_to_hash (le_seq_quad32_to_bytes s) in
lemma_le_bytes_to_hash_quads_part1 s;
assert (rhs == Vale.Lib.Seqs_s.seq_map nat32_to_word (Vale.Def.Words.Seq_s.seq_four_to_seq_LE s));
()
#pop-options
let lemma_hash_to_bytes (s:seq quad32) : Lemma
(requires length s == 2)
(ensures make_ordered_hash s.[0] s.[1] == le_bytes_to_hash (le_seq_quad32_to_bytes s)) | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": 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"
} | null | val lemma_hash_to_bytes (s:seq quad32) : Lemma
(requires length s == 2)
(ensures make_ordered_hash s.[0] s.[1] == le_bytes_to_hash (le_seq_quad32_to_bytes s)) | [] | Vale.SHA.SHA_helpers.lemma_hash_to_bytes | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: FStar.Seq.Base.seq Vale.Def.Types_s.quad32
-> FStar.Pervasives.Lemma (requires FStar.Seq.Base.length s == 2)
(ensures
Vale.SHA.SHA_helpers.make_ordered_hash s.[ 0 ] s.[ 1 ] ==
Vale.SHA.SHA_helpers.le_bytes_to_hash (Vale.Def.Types_s.le_seq_quad32_to_bytes s)) | {
"end_col": 4,
"end_line": 1077,
"start_col": 2,
"start_line": 1075
} |
FStar.Pervasives.Lemma | val lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
=
sha256_msg1_spec_reveal ();
let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
() | val lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
let lemma_sha256_msg1 (dst src: quad32) (t: counter) (block: block_w)
: Lemma
(requires
16 <= t /\ t < size_k_w (SHA2_256) /\ dst == ws_quad32 (t - 16) block /\
src.lo0 == ws_opaque block (t - 12))
(ensures sha256_msg1_spec dst src == ws_partial t block) = | false | null | true | sha256_msg1_spec_reveal ();
let init = ws_quad32 (t - 16) block in
let sigma0_in = ws_quad32 (t - 15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
() | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"Vale.Def.Types_s.quad32",
"Vale.SHA.SHA_helpers.counter",
"Vale.SHA.SHA_helpers.block_w",
"Prims.unit",
"Vale.SHA.SHA_helpers.ws_partial_reveal",
"Vale.SHA.SHA_helpers.lemma_add_wrap_quad32_is_add_mod_quad32",
"Vale.SHA.SHA_helpers._sigma0_quad32",
"Vale.SHA.SHA_helpers.ws_quad32",
"Prims.op_Subtraction",
"Vale.X64.CryptoInstructions_s.sha256_msg1_spec_reveal",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Spec.SHA2.size_k_w",
"Spec.Hash.Definitions.SHA2_256",
"Prims.eq2",
"Vale.Def.Words_s.nat32",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0",
"Vale.Def.Types_s.nat32",
"Vale.SHA.SHA_helpers.ws_opaque",
"Prims.squash",
"Vale.X64.CryptoInstructions_s.sha256_msg1_spec",
"Vale.SHA.SHA_helpers.ws_partial",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
// Top-level proof for the SHA256_msg1 instruction
let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block) | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block) | [] | Vale.SHA.SHA_helpers.lemma_sha256_msg1 | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
dst: Vale.Def.Types_s.quad32 ->
src: Vale.Def.Types_s.quad32 ->
t: Vale.SHA.SHA_helpers.counter ->
block: Vale.SHA.SHA_helpers.block_w
-> FStar.Pervasives.Lemma
(requires
16 <= t /\ t < Vale.SHA.SHA_helpers.size_k_w_256 /\
dst == Vale.SHA.SHA_helpers.ws_quad32 (t - 16) block /\
Mkfour?.lo0 src == Vale.SHA.SHA_helpers.ws_opaque block (t - 12))
(ensures
Vale.X64.CryptoInstructions_s.sha256_msg1_spec dst src ==
Vale.SHA.SHA_helpers.ws_partial t block) | {
"end_col": 4,
"end_line": 455,
"start_col": 2,
"start_line": 449
} |
FStar.Pervasives.Lemma | val lemma_rnds2_spec_quad32_is_shuffle_core_x2
(abef cdgh: quad32)
(wk0 wk1: UInt32.t)
(block: block_w)
(t: counter{t < size_k_w_256 - 1})
: Lemma
(requires
vv wk0 == add_mod32 (k0 SHA2_256).[ t ] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[ t + 1 ] (ws_opaque block (t + 1)))
(ensures
(let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh'')) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
() | val lemma_rnds2_spec_quad32_is_shuffle_core_x2
(abef cdgh: quad32)
(wk0 wk1: UInt32.t)
(block: block_w)
(t: counter{t < size_k_w_256 - 1})
: Lemma
(requires
vv wk0 == add_mod32 (k0 SHA2_256).[ t ] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[ t + 1 ] (ws_opaque block (t + 1)))
(ensures
(let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
let lemma_rnds2_spec_quad32_is_shuffle_core_x2
(abef cdgh: quad32)
(wk0 wk1: UInt32.t)
(block: block_w)
(t: counter{t < size_k_w_256 - 1})
: Lemma
(requires
vv wk0 == add_mod32 (k0 SHA2_256).[ t ] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[ t + 1 ] (ws_opaque block (t + 1)))
(ensures
(let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh'')) = | false | null | true | let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t + 1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
() | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"Vale.Def.Types_s.quad32",
"FStar.UInt32.t",
"Vale.SHA.SHA_helpers.block_w",
"Vale.SHA.SHA_helpers.counter",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_Subtraction",
"Vale.SHA.SHA_helpers.size_k_w_256",
"Prims.unit",
"Prims._assert",
"FStar.Seq.Base.equal",
"Vale.SHA.SHA_helpers.word",
"Vale.SHA.SHA_helpers.make_hash",
"Vale.SHA.SHA_helpers.lemma_rnds_quad32",
"Prims.op_Addition",
"FStar.Pervasives.Native.tuple2",
"Vale.SHA.SHA_helpers.sha256_rnds2_spec_update_quad32",
"Vale.SHA.SHA_helpers.hash256",
"Vale.SHA.SHA_helpers.shuffle_core_opaque",
"Prims.l_and",
"Prims.eq2",
"Vale.Def.Words_s.nat32",
"Vale.SHA.SHA_helpers.vv",
"Vale.SHA.SHA_helpers.add_mod32",
"Spec.SHA2.op_String_Access",
"Spec.Hash.Definitions.word",
"Spec.Hash.Definitions.SHA2_256",
"Spec.SHA2.k0",
"Vale.SHA.SHA_helpers.ws_opaque",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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": 30,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_rnds2_spec_quad32_is_shuffle_core_x2
(abef cdgh: quad32)
(wk0 wk1: UInt32.t)
(block: block_w)
(t: counter{t < size_k_w_256 - 1})
: Lemma
(requires
vv wk0 == add_mod32 (k0 SHA2_256).[ t ] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[ t + 1 ] (ws_opaque block (t + 1)))
(ensures
(let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh'')) | [] | Vale.SHA.SHA_helpers.lemma_rnds2_spec_quad32_is_shuffle_core_x2 | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
abef: Vale.Def.Types_s.quad32 ->
cdgh: Vale.Def.Types_s.quad32 ->
wk0: FStar.UInt32.t ->
wk1: FStar.UInt32.t ->
block: Vale.SHA.SHA_helpers.block_w ->
t: Vale.SHA.SHA_helpers.counter{t < Vale.SHA.SHA_helpers.size_k_w_256 - 1}
-> FStar.Pervasives.Lemma
(requires
Vale.SHA.SHA_helpers.vv wk0 ==
Vale.SHA.SHA_helpers.add_mod32 (Spec.SHA2.k0 Spec.Hash.Definitions.SHA2_256).[ t ]
(Vale.SHA.SHA_helpers.ws_opaque block t) /\
Vale.SHA.SHA_helpers.vv wk1 ==
Vale.SHA.SHA_helpers.add_mod32 (Spec.SHA2.k0 Spec.Hash.Definitions.SHA2_256).[ t + 1 ]
(Vale.SHA.SHA_helpers.ws_opaque block (t + 1)))
(ensures
(let hash0 = Vale.SHA.SHA_helpers.make_hash abef cdgh in
let hash1 = Vale.SHA.SHA_helpers.shuffle_core_opaque block hash0 t in
let hash2 = Vale.SHA.SHA_helpers.shuffle_core_opaque block hash1 (t + 1) in
let _ = Vale.SHA.SHA_helpers.sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ abef' cdgh' = _ in
let _ = Vale.SHA.SHA_helpers.sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ abef'' cdgh'' = _ in
hash2 == Vale.SHA.SHA_helpers.make_hash abef'' cdgh'')
<:
Type0)
<:
Type0)) | {
"end_col": 4,
"end_line": 349,
"start_col": 3,
"start_line": 339
} |
FStar.Pervasives.Lemma | val lemma_ws_computed_is_ws (b: block_w) (t: counter{t < size_k_w_256})
: Lemma (ws_computed b t == ws SHA2_256 b t) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_ws_computed_is_ws (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (ws_computed b t == ws SHA2_256 b t)
=
Pervasives.reveal_opaque (`%ws) ws;
if t < block_word_length SHA2_256 then (
assert (vv (ws_computed b t) == ws_opaque b t);
assert (to_uint32 (ws_opaque b t) == ws SHA2_256 b t);
()
) else (
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
lemma_add_mod_ws_rearrangement s1 t7 s0 t16;
()
) | val lemma_ws_computed_is_ws (b: block_w) (t: counter{t < size_k_w_256})
: Lemma (ws_computed b t == ws SHA2_256 b t)
let lemma_ws_computed_is_ws (b: block_w) (t: counter{t < size_k_w_256})
: Lemma (ws_computed b t == ws SHA2_256 b t) = | false | null | true | Pervasives.reveal_opaque (`%ws) ws;
if t < block_word_length SHA2_256
then
(assert (vv (ws_computed b t) == ws_opaque b t);
assert (to_uint32 (ws_opaque b t) == ws SHA2_256 b t);
())
else
(let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
lemma_add_mod_ws_rearrangement s1 t7 s0 t16;
()) | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"Vale.SHA.SHA_helpers.block_w",
"Vale.SHA.SHA_helpers.counter",
"Prims.b2t",
"Prims.op_LessThan",
"Vale.SHA.SHA_helpers.size_k_w_256",
"Spec.Hash.Definitions.block_word_length",
"Spec.Hash.Definitions.SHA2_256",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"FStar.UInt32.t",
"Vale.SHA.SHA_helpers.to_uint32",
"Vale.SHA.SHA_helpers.ws_opaque",
"Spec.SHA2.Lemmas.ws",
"Vale.Def.Words_s.nat32",
"Vale.SHA.SHA_helpers.vv",
"Vale.SHA.SHA_helpers.ws_computed",
"Prims.bool",
"Vale.SHA.SHA_helpers.lemma_add_mod_ws_rearrangement",
"Spec.Hash.Definitions.word",
"Spec.SHA2._sigma0",
"Spec.SHA2._sigma1",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U32",
"Lib.IntTypes.SEC",
"Prims.op_Subtraction",
"FStar.Pervasives.reveal_opaque",
"Spec.Hash.Definitions.sha2_alg",
"Spec.SHA2.block_w",
"Spec.SHA2.counter",
"Spec.SHA2.size_k_w",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
// Top-level proof for the SHA256_msg1 instruction
let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
=
sha256_msg1_spec_reveal ();
let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
let ws_computed (b:block_w) (t:counter{t < size_k_w_256}): Tot (UInt32.t) =
if t < block_word_length SHA2_256 then to_uint32 (ws_opaque b t)
else
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
let open Lib.IntTypes in
(t16 +. s0 +. t7 +. s1)
#push-options "--max_fuel 1"
let lemma_ws_computed_is_ws (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (ws_computed b t == ws SHA2_256 b t) | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"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": 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"
} | null | val lemma_ws_computed_is_ws (b: block_w) (t: counter{t < size_k_w_256})
: Lemma (ws_computed b t == ws SHA2_256 b t) | [] | Vale.SHA.SHA_helpers.lemma_ws_computed_is_ws | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Vale.SHA.SHA_helpers.block_w ->
t: Vale.SHA.SHA_helpers.counter{t < Vale.SHA.SHA_helpers.size_k_w_256}
-> FStar.Pervasives.Lemma
(ensures
Vale.SHA.SHA_helpers.ws_computed b t == Spec.SHA2.Lemmas.ws Spec.Hash.Definitions.SHA2_256 b t
) | {
"end_col": 3,
"end_line": 508,
"start_col": 2,
"start_line": 494
} |
FStar.Pervasives.Lemma | val lemma_endian_relation (quads qs: seq quad32) (input2: seq UInt8.t)
: Lemma
(requires
length qs == 4 /\ length input2 == 64 /\ qs == reverse_bytes_nat32_quad32_seq quads /\
input2 == seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads))
(ensures quads_to_block qs == words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_endian_relation (quads qs:seq quad32) (input2:seq UInt8.t) : Lemma
(requires length qs == 4 /\ length input2 == 64 /\
qs == reverse_bytes_nat32_quad32_seq quads /\
input2 == seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads))
(ensures quads_to_block qs == words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2)
=
let fi (i:nat{i < length (quads_to_block qs)}) : Lemma
((quads_to_block qs).[i] == (words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2).[i])
=
let open Vale.Def.Words.Four_s in
let open Vale.Lib.Seqs_s in
let ni = (seq_four_to_seq_LE quads).[i] in
let b = slice input2 (4 * i) (4 * i + 4) in
// FStar.Krml.Endianness.lemma_be_to_n_is_bounded b;
calc (==) {
b;
== {}
slice input2 (4 * i) (4 * i + 4);
== {}
slice (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) (4 * i) (4 * i + 4);
== {le_seq_quad32_to_bytes_reveal ()}
slice (seq_nat8_to_seq_uint8 (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE quads))) (4 * i) (4 * i + 4);
equal {}
seq_nat8_to_seq_uint8 (slice (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE quads)) (4 * i) (4 * i + 4));
== {}
seq_nat8_to_seq_uint8 (slice (seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE quads))) (4 * i) (4 * i + 4));
== {slice_commutes_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE quads)) i (i + 1)}
seq_nat8_to_seq_uint8 (seq_four_to_seq_LE (slice (seq_map (nat_to_four 8) (seq_four_to_seq_LE quads)) i (i + 1)));
equal {reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat8)}
seq_nat8_to_seq_uint8 (four_to_seq_LE (nat_to_four 8 (seq_four_to_seq_LE quads).[i]));
};
let open Lib.IntTypes in
calc (==) {
(words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2).[i];
== { }
(Lib.ByteSequence.uints_from_bytes_be #U32 #SEC #(block_word_length SHA2_256) input2).[i];
== { Lib.ByteSequence.index_uints_from_bytes_be #U32 #SEC #(block_word_length SHA2_256) input2 i }
Lib.ByteSequence.uint_from_bytes_be (Lib.Sequence.sub #uint8 #64 input2 (i * 4) 4);
== { let open Lib.Sequence in
calc (==) {
sub #uint8 #64 input2 (i * 4) 4;
== { }
Seq.slice input2 (4 * i) (4 * i + 4);
}
}
Lib.ByteSequence.uint_from_bytes_be #U32 #SEC b;
== { calc (==) {
Lib.ByteSequence.nat_from_bytes_be #SEC b;
(==) { }
Lib.ByteSequence.nat_from_bytes_be #SEC (seq_nat8_to_seq_uint8 (four_to_seq_LE (nat_to_four 8 ni)));
(==) { lemma_be_to_n_4 (four_to_seq_LE (nat_to_four 8 ni)) }
be_bytes_to_nat32 (four_to_seq_LE (nat_to_four 8 ni));
};
v_inj (Lib.ByteSequence.uint_from_bytes_be #U32 #SEC b)
(u32 (be_bytes_to_nat32 (four_to_seq_LE (nat_to_four 8 ni))))
}
nat32_to_word (be_bytes_to_nat32 (four_to_seq_LE (nat_to_four 8 ni)));
== {}
nat32_to_word (be_bytes_to_nat32 (reverse_seq (nat32_to_be_bytes ni)));
== {reverse_bytes_nat32_reveal ()}
nat32_to_word (reverse_bytes_nat32 ni);
== {}
nat32_to_word (reverse_bytes_nat32 (seq_four_to_seq_LE quads).[i]);
== {reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32)}
nat32_to_word (seq_four_to_seq_LE qs).[i];
== {}
(quads_to_block qs).[i];
}
in
FStar.Classical.forall_intro fi;
assert (equal (quads_to_block qs) (words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2)) | val lemma_endian_relation (quads qs: seq quad32) (input2: seq UInt8.t)
: Lemma
(requires
length qs == 4 /\ length input2 == 64 /\ qs == reverse_bytes_nat32_quad32_seq quads /\
input2 == seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads))
(ensures quads_to_block qs == words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2)
let lemma_endian_relation (quads qs: seq quad32) (input2: seq UInt8.t)
: Lemma
(requires
length qs == 4 /\ length input2 == 64 /\ qs == reverse_bytes_nat32_quad32_seq quads /\
input2 == seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads))
(ensures quads_to_block qs == words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2) = | false | null | true | let fi (i: nat{i < length (quads_to_block qs)})
: Lemma
((quads_to_block qs).[ i ] ==
(words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2).[ i ]) =
let open Vale.Def.Words.Four_s in
let open Vale.Lib.Seqs_s in
let ni = (seq_four_to_seq_LE quads).[ i ] in
let b = slice input2 (4 * i) (4 * i + 4) in
calc ( == ) {
b;
( == ) { () }
slice input2 (4 * i) (4 * i + 4);
( == ) { () }
slice (seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) (4 * i) (4 * i + 4);
( == ) { le_seq_quad32_to_bytes_reveal () }
slice (seq_nat8_to_seq_uint8 (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE quads)))
(4 * i)
(4 * i + 4);
equal { () }
seq_nat8_to_seq_uint8 (slice (seq_nat32_to_seq_nat8_LE (seq_four_to_seq_LE quads))
(4 * i)
(4 * i + 4));
( == ) { () }
seq_nat8_to_seq_uint8 (slice (seq_four_to_seq_LE (seq_map (nat_to_four 8)
(seq_four_to_seq_LE quads)))
(4 * i)
(4 * i + 4));
( == ) { slice_commutes_seq_four_to_seq_LE (seq_map (nat_to_four 8) (seq_four_to_seq_LE quads))
i
(i + 1) }
seq_nat8_to_seq_uint8 (seq_four_to_seq_LE (slice (seq_map (nat_to_four 8)
(seq_four_to_seq_LE quads))
i
(i + 1)));
equal { reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat8) }
seq_nat8_to_seq_uint8 (four_to_seq_LE (nat_to_four 8 (seq_four_to_seq_LE quads).[ i ]));
};
let open Lib.IntTypes in
calc ( == ) {
(words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2).[ i ];
( == ) { () }
(Lib.ByteSequence.uints_from_bytes_be #U32 #SEC #(block_word_length SHA2_256) input2).[ i ];
( == ) { Lib.ByteSequence.index_uints_from_bytes_be #U32
#SEC
#(block_word_length SHA2_256)
input2
i }
Lib.ByteSequence.uint_from_bytes_be (Lib.Sequence.sub #uint8 #64 input2 (i * 4) 4);
( == ) { let open Lib.Sequence in
calc ( == ) {
sub #uint8 #64 input2 (i * 4) 4;
( == ) { () }
Seq.slice input2 (4 * i) (4 * i + 4);
} }
Lib.ByteSequence.uint_from_bytes_be #U32 #SEC b;
( == ) { (calc ( == ) {
Lib.ByteSequence.nat_from_bytes_be #SEC b;
( == ) { () }
Lib.ByteSequence.nat_from_bytes_be #SEC
(seq_nat8_to_seq_uint8 (four_to_seq_LE (nat_to_four 8 ni)));
( == ) { lemma_be_to_n_4 (four_to_seq_LE (nat_to_four 8 ni)) }
be_bytes_to_nat32 (four_to_seq_LE (nat_to_four 8 ni));
};
v_inj (Lib.ByteSequence.uint_from_bytes_be #U32 #SEC b)
(u32 (be_bytes_to_nat32 (four_to_seq_LE (nat_to_four 8 ni))))) }
nat32_to_word (be_bytes_to_nat32 (four_to_seq_LE (nat_to_four 8 ni)));
( == ) { () }
nat32_to_word (be_bytes_to_nat32 (reverse_seq (nat32_to_be_bytes ni)));
( == ) { reverse_bytes_nat32_reveal () }
nat32_to_word (reverse_bytes_nat32 ni);
( == ) { () }
nat32_to_word (reverse_bytes_nat32 (seq_four_to_seq_LE quads).[ i ]);
( == ) { reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32) }
nat32_to_word (seq_four_to_seq_LE qs).[ i ];
( == ) { () }
(quads_to_block qs).[ i ];
}
in
FStar.Classical.forall_intro fi;
assert (equal (quads_to_block qs) (words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2)) | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.quad32",
"FStar.UInt8.t",
"Prims._assert",
"FStar.Seq.Base.equal",
"Vale.SHA.SHA_helpers.word",
"Vale.SHA.SHA_helpers.quads_to_block",
"Spec.Hash.Definitions.words_of_bytes",
"Spec.Hash.Definitions.SHA2_256",
"Spec.Hash.Definitions.block_word_length",
"Prims.unit",
"FStar.Classical.forall_intro",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"Prims.eq2",
"FStar.UInt32.t",
"Spec.SHA2.op_String_Access",
"Spec.Hash.Definitions.word",
"Prims.l_True",
"Prims.squash",
"FStar.Seq.Base.index",
"Prims.Nil",
"FStar.Pervasives.pattern",
"FStar.Calc.calc_finish",
"Prims.Cons",
"FStar.Preorder.relation",
"FStar.Calc.calc_step",
"Vale.SHA.SHA_helpers.nat32_to_word",
"Vale.Def.Types_s.nat32",
"Vale.Def.Words.Seq_s.seq_four_to_seq_LE",
"Vale.Def.Types_s.reverse_bytes_nat32",
"Vale.Def.Types_s.be_bytes_to_nat32",
"Vale.Lib.Seqs_s.reverse_seq",
"Vale.Def.Types_s.nat8",
"Vale.Def.Types_s.nat32_to_be_bytes",
"Vale.Def.Words.Seq_s.four_to_seq_LE",
"Vale.Def.Words_s.natN",
"Prims.pow2",
"Vale.Def.Words.Four_s.nat_to_four",
"Lib.ByteSequence.uint_from_bytes_be",
"Lib.IntTypes.U32",
"Lib.IntTypes.SEC",
"Lib.Sequence.sub",
"Lib.IntTypes.uint8",
"FStar.Mul.op_Star",
"Lib.IntTypes.uint_t",
"Lib.ByteSequence.uints_from_bytes_be",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Lib.ByteSequence.index_uints_from_bytes_be",
"Lib.Sequence.lseq",
"Prims.l_and",
"Lib.Sequence.to_seq",
"FStar.Seq.Base.slice",
"Prims.op_Addition",
"Prims.l_Forall",
"Prims.l_or",
"Lib.Sequence.index",
"FStar.UInt32.v_inj",
"Lib.IntTypes.u32",
"Lib.Sequence.length",
"Lib.IntTypes.U8",
"Lib.ByteSequence.nat_from_bytes_be",
"Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8",
"Vale.SHA.SHA_helpers.lemma_be_to_n_4",
"Vale.Def.Types_s.reverse_bytes_nat32_reveal",
"FStar.Pervasives.reveal_opaque",
"Vale.Def.Words_s.four",
"Vale.Def.Words_s.nat32",
"Prims.int",
"Vale.Def.Words_s.nat8",
"Vale.Lib.Seqs_s.seq_map",
"Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE",
"Vale.Def.Types_s.le_seq_quad32_to_bytes",
"Vale.Def.Types_s.le_seq_quad32_to_bytes_reveal",
"Vale.Arch.Types.slice_commutes_seq_four_to_seq_LE",
"Vale.Arch.Types.reverse_bytes_nat32_quad32_seq",
"Prims.op_Equality",
"Vale.SHA.SHA_helpers.size_block_w_256"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
// Top-level proof for the SHA256_msg1 instruction
let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
=
sha256_msg1_spec_reveal ();
let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
let ws_computed (b:block_w) (t:counter{t < size_k_w_256}): Tot (UInt32.t) =
if t < block_word_length SHA2_256 then to_uint32 (ws_opaque b t)
else
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
let open Lib.IntTypes in
(t16 +. s0 +. t7 +. s1)
#push-options "--max_fuel 1"
let lemma_ws_computed_is_ws (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (ws_computed b t == ws SHA2_256 b t)
=
Pervasives.reveal_opaque (`%ws) ws;
if t < block_word_length SHA2_256 then (
assert (vv (ws_computed b t) == ws_opaque b t);
assert (to_uint32 (ws_opaque b t) == ws SHA2_256 b t);
()
) else (
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
lemma_add_mod_ws_rearrangement s1 t7 s0 t16;
()
)
#pop-options
let lemma_ws_computed_is_ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (vv (ws_computed b t) == ws_opaque b t)
=
lemma_ws_computed_is_ws b t;
Pervasives.reveal_opaque (`%ws) ws;
()
let ws_computed_quad32 (t:counter{t < size_k_w_256 - 3}) (block:block_w) : quad32 =
Mkfour (vv (ws_computed block t))
(vv (ws_computed block (t+1)))
(vv (ws_computed block (t+2)))
(vv (ws_computed block (t+3)))
let lemma_ws_computed_is_ws_quad32 (b:block_w) (t:counter{t < size_k_w_256 - 3}) :
Lemma (ws_computed_quad32 t b == ws_quad32 t b)
=
let w = ws_computed_quad32 t b in
let w' = ws_quad32 t b in
lemma_ws_computed_is_ws_opaque b t;
lemma_ws_computed_is_ws_opaque b (t+1);
lemma_ws_computed_is_ws_opaque b (t+2);
lemma_ws_computed_is_ws_opaque b (t+3);
()
#push-options "--z3rlimit 30"
let lemma_ws_computed_quad32 (t:counter{16 <= t /\ t < size_k_w_256 - 4}) (block:block_w) :
Lemma (let t_minus_16 = ws_quad32 (t-16) block in
let t_minus_15 = ws_quad32 (t-15) block in
let t_minus_7 = ws_quad32 (t - 7) block in
let t_minus_2 = ws_quad32 (t - 2) block in
let m1 = add_mod_quad32 t_minus_16 (_sigma0_quad32 t_minus_15) in
let m2 = add_mod_quad32 m1 t_minus_7 in
let m3 = add_mod_quad32 m2 (_sigma1_quad32 t_minus_2) in
m3 == ws_computed_quad32 t block )
=
()
#pop-options
let sha256_msg1_spec_t (t:counter{t < size_k_w_256 - 1}) (block:block_w) : quad32 =
let init = ws_quad32 t block in
let next = ws_quad32 (t + 1) block in
let msg1 = add_mod_quad32 init (_sigma0_quad32 next) in
msg1
#push-options "--ifuel 1"
let lemma_sha256_msg1_spec_t_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 - 3)
(ensures ws_partial t block == sha256_msg1_spec_t (t-16) block)
=
ws_partial_reveal ();
let init = ws_quad32 (t-16) block in
let next = ws_quad32 (t-15) block in
lemma_add_wrap_quad32_is_add_mod_quad32 init (_sigma0_quad32 next);
()
#pop-options
let lemma_sha256_msg1_spec_t (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w_256 - 4 /\
src1 == ws_quad32 t block /\
src2.lo0 == ws_opaque block (t+4))
(ensures sha256_msg1_spec_t t block == sha256_msg1_spec src1 src2)
=
sha256_msg1_spec_reveal ();
()
#push-options "--z3rlimit 70"
let lemma_sha256_step2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1) /\
(let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
src1 == add_mod_quad32 w mid))
(ensures sha256_msg2_spec src1 src2 == ws_computed_quad32 t block)
=
sha256_msg2_spec_reveal ();
let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
let final = sha256_msg2_spec src1 src2 in
lemma_ws_computed_is_ws_opaque block (t);
lemma_ws_computed_is_ws_opaque block (t+1);
()
#pop-options
// Top-level proof for the SHA256_msg2 instruction
let lemma_sha256_msg2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
(let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
src1 == add_wrap_quad32 step1 t_minus_7 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1)))
(ensures sha256_msg2_spec src1 src2 == ws_quad32 t block)
=
let step1 = ws_partial t block in
let t_minus_7 = ws_quad32 (t-7) block in
lemma_sha256_msg1_spec_t_partial t block;
// ==> step1 == sha256_msg1_spec_t (t-16) block
lemma_add_wrap_quad32_is_add_mod_quad32 step1 t_minus_7;
lemma_sha256_step2 src1 src2 t block;
lemma_ws_computed_is_ws_quad32 block t;
()
(* Abbreviations and lemmas for the code itself *)
#reset-options "--z3rlimit 20 --max_fuel 1"
let lemma_quads_to_block qs
=
reveal_opaque (`%seq_four_to_seq_LE) (seq_four_to_seq_LE #nat32);
reveal_opaque (`%ws) ws
#reset-options "--max_fuel 0 --max_ifuel 0"
let translate_hash_update (h0 h1 h0' h1' a0 a1:quad32) : Lemma
(requires h0' == add_wrap_quad32 a0 h0 /\
h1' == add_wrap_quad32 a1 h1)
(ensures (
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
mapped == h'))
=
let h = make_hash h0 h1 in
let a = make_hash a0 a1 in
let h' = make_hash h0' h1' in
let open Lib.IntTypes in
let mapped = Spec.Loops.seq_map2 ( +. ) h a in
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
assert (equal mapped h');
()
unfold let shuffle_opaque = shuffle
let update_block (hash:hash256) (block:block_w): Tot (hash256) =
let hash_1 = shuffle_opaque SHA2_256 hash block in
let open Lib.IntTypes in
Spec.Loops.seq_map2 ( +. ) hash hash_1
#push-options "--z3cliopt smt.arith.nl=true" (* FIXME: Seemingly needed after fix to #2894 in F*, but should not be *)
let lemma_update_block_equiv (hash:hash256) (block:bytes{length block = block_length}) :
Lemma (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block) == update SHA2_256 hash block)
=
Pervasives.reveal_opaque (`%Spec.SHA2.update) Spec.SHA2.update;
Pervasives.reveal_opaque (`%Spec.SHA2.shuffle) Spec.SHA2.shuffle;
assert (equal (update_block hash (words_of_bytes SHA2_256 #(block_word_length SHA2_256) block)) (update SHA2_256 hash block));
()
#pop-options
let update_lemma (src1 src2 src1' src2' h0 h1:quad32) (block:block_w) : Lemma
(requires (let hash_orig = make_hash h0 h1 in
make_hash src1 src2 ==
Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash_orig /\
src1' == add_wrap_quad32 src1 h0 /\
src2' == add_wrap_quad32 src2 h1))
(ensures (let hash_orig = make_hash h0 h1 in
make_hash src1' src2' == update_block hash_orig block))
=
let hash_orig = make_hash h0 h1 in
let hash_1 = shuffle_opaque SHA2_256 hash_orig block in
Pervasives.reveal_opaque (`%shuffle) shuffle;
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let rec f (i:nat{i <= 64}) : Lemma (
Spec.Loops.repeat_range 0 i (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 i (shuffle_core SHA2_256 block) hash_orig)
=
if i = 0 then (
Spec.Loops.repeat_range_base 0 (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_base 0 (shuffle_core SHA2_256 block) hash_orig
) else (
f (i - 1);
Spec.Loops.repeat_range_induction 0 i (shuffle_core_opaque block) hash_orig;
Spec.Loops.repeat_range_induction 0 i (shuffle_core SHA2_256 block) hash_orig
)
in
f 64;
(*
let h = make_hash src1 src2 in
assert (forall (block:block_w) (hash:hash256) . FStar.FunctionalExtensionality.feq (shuffle_core_opaque block hash) (shuffle_core_opaque_aux SHA2_256 block hash));
//assert (forall (block:block_w) . (shuffle_core_opaque block) == (shuffle_core_opaque_aux SHA2_256 block));
assert (shuffle_core_opaque == shuffle_core_opaque_aux SHA2_256);
assert (shuffle_core_opaque == shuffle_core SHA2_256);
assert (shuffle_core_opaque block == shuffle_core SHA2_256 block);
assert (Spec.Loops.repeat_range 0 64 (shuffle_core_opaque block) hash_orig ==
Spec.Loops.repeat_range 0 64 (shuffle_core SHA2_256 block) hash_orig);
assert (make_hash src1 src2 == shuffle SHA2_256 hash_orig block);
assert (make_hash src1 src2 == shuffle_opaque SHA2_256 hash_orig block);
*)
translate_hash_update src1 src2 src1' src2' h0 h1;
shuffle_is_shuffle_pre SHA2_256 hash_orig block;
assert (equal (make_hash src1' src2') (update_block hash_orig block));
()
let lemma_le_bytes_to_seq_quad32_empty (b:seq nat8) : Lemma
(requires b == empty)
(ensures le_bytes_to_seq_quad32 b == empty)
=
reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32;
assert (equal (le_bytes_to_seq_quad32 b) empty)
let lemma_le_bytes_to_seq_quad32_length (b:seq nat8) : Lemma
(requires length b % 16 == 0)
(ensures length (le_bytes_to_seq_quad32 b) == length b / 16)
=
reveal_opaque (`%le_bytes_to_seq_quad32) le_bytes_to_seq_quad32;
()
#push-options "--max_fuel 1" // Without this, F* refuses to do even one unfolding of recursive functions :(
let lemma_slice_commutes_reverse_bytes_nat32_quad32_seq (s:seq quad32) (pivot:nat) : Lemma
(requires pivot <= length s)
(ensures slice (reverse_bytes_nat32_quad32_seq s) 0 pivot == reverse_bytes_nat32_quad32_seq (slice s 0 pivot))
=
let rs = reverse_bytes_nat32_quad32_seq s in
let srs = slice (reverse_bytes_nat32_quad32_seq s) 0 pivot in
let ss = slice s 0 pivot in
let rss = reverse_bytes_nat32_quad32_seq ss in
if pivot = 0 then (
assert (equal ss empty);
assert (equal srs empty);
assert (equal empty (reverse_bytes_nat32_quad32_seq empty));
()
) else (
assert (equal srs rss)
)
// One level of expansion that we can use in places that can't use fuel
let lemma_update_multi_quads_unfold (s:seq quad32) (hash_orig:hash256) : Lemma
(requires length s >= 4)
(ensures (let prefix, qs = split s (length s - 4) in
let h_prefix = update_multi_quads prefix hash_orig in
let hash = update_block h_prefix (quads_to_block qs) in
update_multi_quads s hash_orig == hash))
=
()
let lemma_update_multi_quads_short (s:seq quad32) (hash_orig:hash256) : Lemma
(requires length s < 4)
(ensures update_multi_quads s hash_orig == hash_orig)
=
()
let update_multi_one (h:hash256) (b:bytes_blocks {length b = block_length}) : Lemma
(ensures (update_multi SHA2_256 h () b == update SHA2_256 h b)) =
update_multi_update SHA2_256 h b
#pop-options
friend Lib.ByteSequence
#reset-options "--z3rlimit 50 --max_fuel 1 --max_ifuel 0 --z3cliopt smt.arith.nl=true"
let lemma_be_to_n_4 (s:seq4 nat8) : Lemma
(Lib.ByteSequence.nat_from_bytes_be #Lib.IntTypes.SEC (seq_nat8_to_seq_uint8 s) == be_bytes_to_nat32 s)
=
let open Lib.IntTypes in
let open Vale.Def.Words.Four_s in
assert (pow2 8 = 0x100);
assert (pow2 16 = 0x10000);
assert_norm (pow2 24 = 0x1000000);
let x = seq_nat8_to_seq_uint8 s in
let f = Lib.ByteSequence.nat_from_intseq_be_ #U8 #SEC in
calc (==) {
f x <: nat ;
== { }
FStar.UInt8.v (last x) + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * f (slice x 0 3);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * f (slice x 0 2);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * f (slice x 0 1);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0 + pow2 32 * f (slice x 0 0);
== {}
index s 3 + pow2 8 * index s 2 + pow2 16 * index s 1 + pow2 24 * index s 0;
== {}
four_to_nat_unfold 8 (seq_to_four_BE s);
== {reveal_opaque (`%four_to_nat) four_to_nat}
be_bytes_to_nat32 s;
}
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 40"
let lemma_endian_relation (quads qs:seq quad32) (input2:seq UInt8.t) : Lemma
(requires length qs == 4 /\ length input2 == 64 /\
qs == reverse_bytes_nat32_quad32_seq quads /\
input2 == seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads)) | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_endian_relation (quads qs: seq quad32) (input2: seq UInt8.t)
: Lemma
(requires
length qs == 4 /\ length input2 == 64 /\ qs == reverse_bytes_nat32_quad32_seq quads /\
input2 == seq_nat8_to_seq_uint8 (le_seq_quad32_to_bytes quads))
(ensures quads_to_block qs == words_of_bytes SHA2_256 #(block_word_length SHA2_256) input2) | [] | Vale.SHA.SHA_helpers.lemma_endian_relation | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
quads: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
qs: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
input2: FStar.Seq.Base.seq FStar.UInt8.t
-> FStar.Pervasives.Lemma
(requires
FStar.Seq.Base.length qs == 4 /\ FStar.Seq.Base.length input2 == 64 /\
qs == Vale.Arch.Types.reverse_bytes_nat32_quad32_seq quads /\
input2 ==
Vale.Def.Words.Seq_s.seq_nat8_to_seq_uint8 (Vale.Def.Types_s.le_seq_quad32_to_bytes quads))
(ensures
Vale.SHA.SHA_helpers.quads_to_block qs ==
Spec.Hash.Definitions.words_of_bytes Spec.Hash.Definitions.SHA2_256 input2) | {
"end_col": 99,
"end_line": 868,
"start_col": 3,
"start_line": 803
} |
FStar.Pervasives.Lemma | val lemma_sha256_step2 (src1 src2: quad32) (t: counter) (block: block_w)
: Lemma
(requires
16 <= t /\ t < size_k_w (SHA2_256) - 3 /\ src2.hi2 == ws_opaque block (t - 2) /\
src2.hi3 == ws_opaque block (t - 1) /\
(let w = sha256_msg1_spec_t (t - 16) block in
let mid = ws_quad32 (t - 7) block in
src1 == add_mod_quad32 w mid))
(ensures sha256_msg2_spec src1 src2 == ws_computed_quad32 t block) | [
{
"abbrev": false,
"full_module": "FStar.UInt32 // Interop with UInt-based SHA spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile.Hash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.SHA2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_sha256_step2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1) /\
(let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
src1 == add_mod_quad32 w mid))
(ensures sha256_msg2_spec src1 src2 == ws_computed_quad32 t block)
=
sha256_msg2_spec_reveal ();
let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
let final = sha256_msg2_spec src1 src2 in
lemma_ws_computed_is_ws_opaque block (t);
lemma_ws_computed_is_ws_opaque block (t+1);
() | val lemma_sha256_step2 (src1 src2: quad32) (t: counter) (block: block_w)
: Lemma
(requires
16 <= t /\ t < size_k_w (SHA2_256) - 3 /\ src2.hi2 == ws_opaque block (t - 2) /\
src2.hi3 == ws_opaque block (t - 1) /\
(let w = sha256_msg1_spec_t (t - 16) block in
let mid = ws_quad32 (t - 7) block in
src1 == add_mod_quad32 w mid))
(ensures sha256_msg2_spec src1 src2 == ws_computed_quad32 t block)
let lemma_sha256_step2 (src1 src2: quad32) (t: counter) (block: block_w)
: Lemma
(requires
16 <= t /\ t < size_k_w (SHA2_256) - 3 /\ src2.hi2 == ws_opaque block (t - 2) /\
src2.hi3 == ws_opaque block (t - 1) /\
(let w = sha256_msg1_spec_t (t - 16) block in
let mid = ws_quad32 (t - 7) block in
src1 == add_mod_quad32 w mid))
(ensures sha256_msg2_spec src1 src2 == ws_computed_quad32 t block) = | false | null | true | sha256_msg2_spec_reveal ();
let w = sha256_msg1_spec_t (t - 16) block in
let mid = ws_quad32 (t - 7) block in
let final = sha256_msg2_spec src1 src2 in
lemma_ws_computed_is_ws_opaque block (t);
lemma_ws_computed_is_ws_opaque block (t + 1);
() | {
"checked_file": "Vale.SHA.SHA_helpers.fst.checked",
"dependencies": [
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.X64.CryptoInstructions_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Seq.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.Lemmas.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.SHA2.fst.checked",
"Spec.Loops.fst.checked",
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.fst.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.SHA.SHA_helpers.fst"
} | [
"lemma"
] | [
"Vale.Def.Types_s.quad32",
"Vale.SHA.SHA_helpers.counter",
"Vale.SHA.SHA_helpers.block_w",
"Prims.unit",
"Vale.SHA.SHA_helpers.lemma_ws_computed_is_ws_opaque",
"Prims.op_Addition",
"Vale.X64.CryptoInstructions_s.sha256_msg2_spec",
"Vale.SHA.SHA_helpers.ws_quad32",
"Prims.op_Subtraction",
"Vale.SHA.SHA_helpers.sha256_msg1_spec_t",
"Vale.X64.CryptoInstructions_s.sha256_msg2_spec_reveal",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Spec.SHA2.size_k_w",
"Spec.Hash.Definitions.SHA2_256",
"Prims.eq2",
"Vale.Def.Words_s.nat32",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Vale.Def.Types_s.nat32",
"Vale.SHA.SHA_helpers.ws_opaque",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Vale.SHA.SHA_helpers.add_mod_quad32",
"Prims.squash",
"Vale.SHA.SHA_helpers.ws_computed_quad32",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.SHA.SHA_helpers
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Spec.SHA2
open Spec.SHA2.Lemmas
open Spec.Agile.Hash
open Spec.Hash.Definitions
open Spec.Hash.Lemmas
open Vale.X64.CryptoInstructions_s
open Vale.Def.Types_s
open Vale.Def.Words_s
open FStar.Seq
open FStar.UInt32 // Interop with UInt-based SHA spec
open Vale.Arch.Types
friend Spec.SHA2
friend Spec.SHA2.Lemmas
friend Vale.X64.CryptoInstructions_s
#reset-options "--max_fuel 0 --max_ifuel 0"
// Define these specific converters here, so that F* only reasons about
// the correctness of the conversion once, rather that at every call site
let vv (u:Lib.IntTypes.uint32) : nat32 = Lib.IntTypes.v u
let to_uint32 (n:nat32) : Lib.IntTypes.uint32 = Lib.IntTypes.u32 n
let word = Lib.IntTypes.uint32
let k = (Spec.SHA2.k0 SHA2_256)
let reveal_word () = ()
val add_mod_lemma:x:Lib.IntTypes.uint32 -> y:Lib.IntTypes.uint32 ->
Lemma (add_mod x y == Lib.IntTypes.(x +. y))
[SMTPat (Lib.IntTypes.(x +. y))]
let add_mod_lemma x y = ()
unfold let ws_opaque_aux = ws
let ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) : nat32 =
vv (ws_opaque_aux SHA2_256 b t)
unfold let shuffle_core_opaque_aux = shuffle_core
let shuffle_core_opaque (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}):hash256 =
shuffle_core_opaque_aux SHA2_256 block hash t
[@"opaque_to_smt"] let update_multi_opaque_aux = opaque_make update_multi
irreducible let update_multi_reveal = opaque_revealer (`%update_multi_opaque_aux) update_multi_opaque_aux update_multi
let update_multi_opaque (hash:hash256) (blocks:bytes_blocks):hash256 =
(update_multi_opaque_aux SHA2_256 hash () blocks)
let update_multi_transparent (hash:hash256) (blocks:bytes_blocks) =
update_multi SHA2_256 hash () blocks
let add_mod32 (x:word) (y:nat32) : nat32 = vv (add_mod x (to_uint32 y))
let word_to_nat32 = vv
let nat32_to_word = to_uint32
let byte_to_nat8 = UInt8.v
let nat8_to_byte = UInt8.uint_to_t
let make_hash_def (abef cdgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abef.hi3 /\
hash.[1] == to_uint32 abef.hi2 /\
hash.[2] == to_uint32 cdgh.hi3 /\
hash.[3] == to_uint32 cdgh.hi2 /\
hash.[4] == to_uint32 abef.lo1 /\
hash.[5] == to_uint32 abef.lo0 /\
hash.[6] == to_uint32 cdgh.lo1 /\
hash.[7] == to_uint32 cdgh.lo0
} ) =
let a = to_uint32 abef.hi3 in
let b = to_uint32 abef.hi2 in
let c = to_uint32 cdgh.hi3 in
let d = to_uint32 cdgh.hi2 in
let e = to_uint32 abef.lo1 in
let f = to_uint32 abef.lo0 in
let g = to_uint32 cdgh.lo1 in
let h = to_uint32 cdgh.lo0 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
//assert_norm (index hash 2 == c);
hash
[@"opaque_to_smt"] let make_hash = opaque_make make_hash_def
irreducible let make_hash_reveal = opaque_revealer (`%make_hash) make_hash make_hash_def
let make_ordered_hash_def (abcd efgh:quad32) :
(hash:words_state SHA2_256 {
length hash == 8 /\
hash.[0] == to_uint32 abcd.lo0 /\
hash.[1] == to_uint32 abcd.lo1 /\
hash.[2] == to_uint32 abcd.hi2 /\
hash.[3] == to_uint32 abcd.hi3 /\
hash.[4] == to_uint32 efgh.lo0 /\
hash.[5] == to_uint32 efgh.lo1 /\
hash.[6] == to_uint32 efgh.hi2 /\
hash.[7] == to_uint32 efgh.hi3
})
=
let a = to_uint32 abcd.lo0 in
let b = to_uint32 abcd.lo1 in
let c = to_uint32 abcd.hi2 in
let d = to_uint32 abcd.hi3 in
let e = to_uint32 efgh.lo0 in
let f = to_uint32 efgh.lo1 in
let g = to_uint32 efgh.hi2 in
let h = to_uint32 efgh.hi3 in
let l = [a; b; c; d; e; f; g; h] in
let hash = seq_of_list l in
assert_norm (length hash == 8);
elim_of_list l;
hash
[@"opaque_to_smt"] let make_ordered_hash = opaque_make make_ordered_hash_def
irreducible let make_ordered_hash_reveal = opaque_revealer (`%make_ordered_hash) make_ordered_hash make_ordered_hash_def
let shuffle_core_properties (block:block_w) (hash:hash256) (t:counter{t < size_k_w_256}) :
Lemma(let h = shuffle_core_opaque block hash t in
let open Lib.IntTypes in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
h.[0] == t1 +. t2 /\
h.[1] == a0 /\
h.[2] == b0 /\
h.[3] == c0 /\
h.[4] == d0 +. t1 /\
h.[5] == e0 /\
h.[6] == f0 /\
h.[7] == g0)
=
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
let h = shuffle_core SHA2_256 block hash t in
let a0 = hash.[0] in
let b0 = hash.[1] in
let c0 = hash.[2] in
let d0 = hash.[3] in
let e0 = hash.[4] in
let f0 = hash.[5] in
let g0 = hash.[6] in
let h0 = hash.[7] in
let t1 = h0 +. (_Sigma1 SHA2_256 e0) +. (_Ch SHA2_256 e0 f0 g0) +. (k0 SHA2_256).[t] +. (ws SHA2_256 block t) in
let t2 = (_Sigma0 SHA2_256 a0) +. (_Maj SHA2_256 a0 b0 c0) in
let l = [ t1 +. t2; a0; b0; c0; d0 +. t1; e0; f0; g0 ] in
assert (h == seq_of_list l);
elim_of_list l;
()
let sha256_rnds2_spec_update_quad32 (abef cdgh:quad32) (wk:UInt32.t) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let a', b', c', d', e', f', g', h' = sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3] hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let abef' = Mkfour (vv f') (vv e') (vv b') (vv a') in
let cdgh' = Mkfour (vv h') (vv g') (vv d') (vv c') in
(abef', cdgh')
let sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) : quad32 =
let abef', cdgh' = sha256_rnds2_spec_update_quad32 src2 src1 (to_uint32 wk.lo0) in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' (to_uint32 wk.lo1) in
abef''
let lemma_sha256_rnds2_spec_quad32 (src1 src2 wk:quad32) :
Lemma (sha256_rnds2_spec src1 src2 wk == sha256_rnds2_spec_quad32 src1 src2 wk)
=
sha256_rnds2_spec_reveal ();
()
let lemma_add_mod_commutes (x y:UInt32.t) :
Lemma (add_mod x y == add_mod y x)
=
()
(*
let lemma_add_mod32_associates (x y z:int) :
Lemma ( ((x + y % pow2_32) + z) % pow2_32 == (x + ((y + z) % pow2_32)) % pow2_32 )
=
()
*)
let lemma_add_mod_associates_U32 (x y z:UInt32.t) :
Lemma (add_mod x (add_mod y z) == add_mod (add_mod x y) z)
=
let open Lib.IntTypes in
calc (==) {
v (x +. (y +. z));
(==) { }
(v x + (v y + v z) % pow2 32) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v x) (v y + v z) (pow2 32) }
((v x + v y) + v z) % pow2 32;
(==) { FStar.Math.Lemmas.lemma_mod_add_distr (v z) (v x + v y) (pow2 32) }
((v x + v y) % pow2 32 + v z) % pow2 32;
(==) { }
v ((x +. y) +. z);
};
v_inj (x +. (y +. z)) ((x +. y) +. z)
(*
assert_norm (pow2 32 == pow2_32);
//assert (add_mod y z == to_uint32 ((vv y + vv z) % pow2_32));
//assert (add_mod x (add_mod y z) == to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32));
lemma_add_mod32_associates (vv x) (vv y) (vv z);
//assert (to_uint32 ((vv x + vv (to_uint32 ((vv y + vv z) % pow2_32))) % pow2_32) ==
// to_uint32 (((vv x + vv y % pow2_32) + vv z) % pow2_32));
*)
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_wrap_is_add_mod (n0 n1:nat32) :
Lemma (add_wrap n0 n1 == vv (add_mod (to_uint32 n0) (to_uint32 n1)))
=
assert_norm (pow2 32 == pow2_32);
()
let add_wrap_commutes (x y:nat32) :
Lemma(add_wrap x y == add_wrap y x)
=
()
// Walk F* through the math steps required to rearrange all of the add_mods
let lemma_add_mod_a (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
(add_mod (_Maj SHA2_256 a b c)
(_Sigma0 SHA2_256 a))))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let t2 = add_mod (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c) in
let core = add_mod t1 t2 in
lemma_add_mod_commutes (_Sigma0 SHA2_256 a) (_Maj SHA2_256 a b c);
assert (t2 == add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
assert (t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a));
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
// ==> add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk)
lemma_add_mod_commutes (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g);
// ==> add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk)
lemma_add_mod_associates_U32 (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)));
assert (core == add_mod (add_mod (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e)) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a)))));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h (add_mod (_Maj SHA2_256 a b c) (_Sigma0 SHA2_256 a))));
()
let lemma_add_mod_e (a b c d e f g h wk:UInt32.t) :
Lemma ( let u = add_mod (_Ch SHA2_256 e f g)
(add_mod (_Sigma1 SHA2_256 e)
(add_mod wk
(add_mod h
d))) in
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
u == core)
=
let t1 = add_mod h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) in
let core = add_mod d t1 in
lemma_add_mod_commutes h (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk));
// t1 == add_mod (add_mod (_Sigma1 SHA2_256 e) (add_mod (_Ch SHA2_256 e f g) wk)) h);
lemma_add_mod_commutes d t1;
// core == add_mod t1 d
lemma_add_mod_associates_U32 (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g) wk;
assert (t1 == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h);
lemma_add_mod_associates_U32 (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) h d;
assert (core == add_mod (add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk) (add_mod h d));
lemma_add_mod_associates_U32 (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) wk (add_mod h d);
assert (core == add_mod (add_mod (_Sigma1 SHA2_256 e) (_Ch SHA2_256 e f g)) (add_mod wk (add_mod h d)));
lemma_add_mod_associates_U32 (_Ch SHA2_256 e f g) (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d));
assert (core == add_mod (_Ch SHA2_256 e f g) (add_mod (_Sigma1 SHA2_256 e) (add_mod wk (add_mod h d))));
()
let lemma_sha256_rnds2_spec_update_is_shuffle_core (hash:hash256) (wk:UInt32.t) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w SHA2_256 /\ wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures (let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let u = seq_of_list [a'; b'; c'; d'; e'; f'; g'; h'] in
let c = shuffle_core_opaque block hash t in
u == c))
=
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash.[0] hash.[1] hash.[2] hash.[3]
hash.[4] hash.[5] hash.[6] hash.[7] wk in
let l:list Lib.IntTypes.uint32 = [a'; b'; c'; d'; e'; f'; g'; h'] in
let u:Seq.seq UInt32.t = seq_of_list l in
assert_norm (List.length l == 8);
let c = shuffle_core_opaque block hash t in
Pervasives.reveal_opaque (`%shuffle_core) shuffle_core;
Pervasives.reveal_opaque (`%ws) ws;
shuffle_core_properties block hash t;
elim_of_list l;
Classical.forall_intro_3 lemma_add_mod_associates_U32;
lemma_add_mod_a hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk;
lemma_add_mod_e hash.[0] hash.[1] hash.[2] hash.[3] hash.[4] hash.[5] hash.[6] hash.[7] wk
let sha256_rnds2_spec_update_core_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : (quad32 & quad32) =
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let abef' = Mkfour (vv hash1.[5]) (vv hash1.[4]) (vv hash1.[1]) (vv hash1.[0]) in
let cdgh' = Mkfour (vv hash1.[7]) (vv hash1.[6]) (vv hash1.[3]) (vv hash1.[2]) in
(abef', cdgh')
let lemma_rnds_quad32 (abef cdgh:quad32) (wk:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256}) : Lemma
(requires wk == to_uint32 (add_mod32 (k0 SHA2_256).[t] (ws_opaque block t)))
(ensures sha256_rnds2_spec_update_core_quad32 abef cdgh wk block t == sha256_rnds2_spec_update_quad32 abef cdgh wk)
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let a', b', c', d', e', f', g', h' =
sha256_rnds2_spec_update hash0.[0] hash0.[1] hash0.[2] hash0.[3]
hash0.[4] hash0.[5] hash0.[6] hash0.[7] wk in
let l = [a'; b'; c'; d'; e'; f'; g'; h'] in
elim_of_list l;
lemma_sha256_rnds2_spec_update_is_shuffle_core hash0 wk t block;
()
#push-options "--z3rlimit 30"
let lemma_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh:quad32) (wk0 wk1:UInt32.t) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires vv wk0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
vv wk1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
hash2 == make_hash abef'' cdgh''))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
lemma_rnds_quad32 abef cdgh wk0 block t;
lemma_rnds_quad32 abef' cdgh' wk1 block (t+1);
assert (equal (make_hash abef' cdgh') hash1);
assert (equal (make_hash abef'' cdgh'') hash2);
()
#pop-options
let sha256_rnds2_spec_update_quad32_x2_shifts (abef cdgh:quad32) (wk0 wk1:UInt32.t) :
Lemma ((let abef', cdgh' = sha256_rnds2_spec_update_quad32 abef cdgh wk0 in
let abef'', cdgh'' = sha256_rnds2_spec_update_quad32 abef' cdgh' wk1 in
cdgh'' == abef))
=
()
let sha256_rnds2_spec_quad32_is_shuffle_core_x2 (abef cdgh wk:quad32) (block:block_w) (t:counter{t < size_k_w_256 - 1}) : Lemma
(requires wk.lo0 == add_mod32 (k0 SHA2_256).[t] (ws_opaque block t) /\
wk.lo1 == add_mod32 (k0 SHA2_256).[t+1] (ws_opaque block (t+1)))
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
let abef' = sha256_rnds2_spec_quad32 cdgh abef wk in
hash2 == make_hash abef' abef))
=
lemma_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1) block t;
sha256_rnds2_spec_update_quad32_x2_shifts abef cdgh (to_uint32 wk.lo0) (to_uint32 wk.lo1);
()
let lemma_sha256_rnds2_two_steps (abef cdgh xmm0:quad32) (t:counter) (block:block_w) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (vv (k0 SHA2_256).[t] ) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1)) )
(ensures (let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
hash2 == make_hash (sha256_rnds2_spec cdgh abef xmm0) abef))
=
let hash0 = make_hash abef cdgh in
let hash1 = shuffle_core_opaque block hash0 t in
let hash2 = shuffle_core_opaque block hash1 (t + 1) in
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
sha256_rnds2_spec_quad32_is_shuffle_core_x2 abef cdgh xmm0 block t;
lemma_sha256_rnds2_spec_quad32 cdgh abef xmm0;
()
// Top-level proof for the SHA256_rnds2 instruction
let lemma_sha256_rnds2 (abef cdgh xmm0:quad32) (t:counter) (block:block_w) (hash_in:hash256) : Lemma
(requires t + 1 < size_k_w_256 /\
xmm0.lo0 == add_wrap (word_to_nat32 k.[t]) (ws_opaque block t) /\
xmm0.lo1 == add_wrap (word_to_nat32 k.[t+1]) (ws_opaque block (t+1)) /\
make_hash abef cdgh == Spec.Loops.repeat_range 0 t (shuffle_core_opaque block) hash_in
)
(ensures make_hash (sha256_rnds2_spec cdgh abef xmm0) abef ==
Spec.Loops.repeat_range 0 (t+2) (shuffle_core_opaque block) hash_in)
=
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t] ) (ws_opaque block t);
lemma_add_wrap_is_add_mod (vv (k0 SHA2_256).[t+1]) (ws_opaque block (t+1));
lemma_sha256_rnds2_two_steps abef cdgh xmm0 t block;
Spec.Loops.repeat_range_induction 0 (t + 1) (shuffle_core_opaque block) hash_in;
Spec.Loops.repeat_range_induction 0 (t + 2) (shuffle_core_opaque block) hash_in;
()
(* Proof work for the SHA256_msg* instructions *)
let _sigma0_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma0 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma0 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma0 SHA2_256 (to_uint32 q.hi3)))
let _sigma1_quad32 (q:quad32) : quad32 =
Mkfour (vv (_sigma1 SHA2_256 (to_uint32 q.lo0)))
(vv (_sigma1 SHA2_256 (to_uint32 q.lo1)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi2)))
(vv (_sigma1 SHA2_256 (to_uint32 q.hi3)))
let ws_partial_def (t:counter) (block:block_w) : quad32 =
if 16 <= t && t < size_k_w_256 then
(let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
add_wrap_quad32 init sigma0_out)
else
Mkfour 0 0 0 0
let add_mod_quad32 (q0 q1:quad32) : quad32 =
Mkfour (vv (add_mod (to_uint32 q0.lo0) (to_uint32 q1.lo0)))
(vv (add_mod (to_uint32 q0.lo1) (to_uint32 q1.lo1)))
(vv (add_mod (to_uint32 q0.hi2) (to_uint32 q1.hi2)))
(vv (add_mod (to_uint32 q0.hi3) (to_uint32 q1.hi3)))
let lemma_add_wrap_quad32_is_add_mod_quad32 (q0 q1:quad32) :
Lemma (add_mod_quad32 q0 q1 == add_wrap_quad32 q0 q1)
=
FStar.Classical.forall_intro_2 lemma_add_wrap_is_add_mod;
()
#reset-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 30"
// Top-level proof for the SHA256_msg1 instruction
let lemma_sha256_msg1 (dst src:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) /\
dst == ws_quad32 (t-16) block /\
src.lo0 == ws_opaque block (t-12))
(ensures sha256_msg1_spec dst src == ws_partial t block)
=
sha256_msg1_spec_reveal ();
let init = ws_quad32 (t-16) block in
let sigma0_in = ws_quad32 (t-15) block in
let sigma0_out = _sigma0_quad32 sigma0_in in
lemma_add_wrap_quad32_is_add_mod_quad32 init sigma0_out;
ws_partial_reveal ();
()
#reset-options "--max_fuel 0 --max_ifuel 0"
let lemma_add_mod_ws_rearrangement (a b c d:UInt32.t) :
Lemma (let open Lib.IntTypes in
a +. b +. c +. d == d +. c +. b +. a)
=
let open Lib.IntTypes in
calc (==) {
a +. b +. c +. d;
(==) {}
(((a +. b) +. c) +. d);
(==) { lemma_add_mod_commutes ((a +. b) +. c) d;
lemma_add_mod_commutes (a +. b) c;
lemma_add_mod_commutes a b
}
d +. (c +. (b +. a));
(==) { lemma_add_mod_associates_U32 d c (b +. a);
lemma_add_mod_associates_U32 (d +. c) b a}
(((d +. c) +. b) +. a);
}
let ws_computed (b:block_w) (t:counter{t < size_k_w_256}): Tot (UInt32.t) =
if t < block_word_length SHA2_256 then to_uint32 (ws_opaque b t)
else
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
let open Lib.IntTypes in
(t16 +. s0 +. t7 +. s1)
#push-options "--max_fuel 1"
let lemma_ws_computed_is_ws (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (ws_computed b t == ws SHA2_256 b t)
=
Pervasives.reveal_opaque (`%ws) ws;
if t < block_word_length SHA2_256 then (
assert (vv (ws_computed b t) == ws_opaque b t);
assert (to_uint32 (ws_opaque b t) == ws SHA2_256 b t);
()
) else (
let t16 = to_uint32 (ws_opaque b (t - 16)) in
let t15 = to_uint32 (ws_opaque b (t - 15)) in
let t7 = to_uint32 (ws_opaque b (t - 7)) in
let t2 = to_uint32 (ws_opaque b (t - 2)) in
let s1 = _sigma1 SHA2_256 t2 in
let s0 = _sigma0 SHA2_256 t15 in
lemma_add_mod_ws_rearrangement s1 t7 s0 t16;
()
)
#pop-options
let lemma_ws_computed_is_ws_opaque (b:block_w) (t:counter{t < size_k_w_256}) :
Lemma (vv (ws_computed b t) == ws_opaque b t)
=
lemma_ws_computed_is_ws b t;
Pervasives.reveal_opaque (`%ws) ws;
()
let ws_computed_quad32 (t:counter{t < size_k_w_256 - 3}) (block:block_w) : quad32 =
Mkfour (vv (ws_computed block t))
(vv (ws_computed block (t+1)))
(vv (ws_computed block (t+2)))
(vv (ws_computed block (t+3)))
let lemma_ws_computed_is_ws_quad32 (b:block_w) (t:counter{t < size_k_w_256 - 3}) :
Lemma (ws_computed_quad32 t b == ws_quad32 t b)
=
let w = ws_computed_quad32 t b in
let w' = ws_quad32 t b in
lemma_ws_computed_is_ws_opaque b t;
lemma_ws_computed_is_ws_opaque b (t+1);
lemma_ws_computed_is_ws_opaque b (t+2);
lemma_ws_computed_is_ws_opaque b (t+3);
()
#push-options "--z3rlimit 30"
let lemma_ws_computed_quad32 (t:counter{16 <= t /\ t < size_k_w_256 - 4}) (block:block_w) :
Lemma (let t_minus_16 = ws_quad32 (t-16) block in
let t_minus_15 = ws_quad32 (t-15) block in
let t_minus_7 = ws_quad32 (t - 7) block in
let t_minus_2 = ws_quad32 (t - 2) block in
let m1 = add_mod_quad32 t_minus_16 (_sigma0_quad32 t_minus_15) in
let m2 = add_mod_quad32 m1 t_minus_7 in
let m3 = add_mod_quad32 m2 (_sigma1_quad32 t_minus_2) in
m3 == ws_computed_quad32 t block )
=
()
#pop-options
let sha256_msg1_spec_t (t:counter{t < size_k_w_256 - 1}) (block:block_w) : quad32 =
let init = ws_quad32 t block in
let next = ws_quad32 (t + 1) block in
let msg1 = add_mod_quad32 init (_sigma0_quad32 next) in
msg1
#push-options "--ifuel 1"
let lemma_sha256_msg1_spec_t_partial (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w_256 - 3)
(ensures ws_partial t block == sha256_msg1_spec_t (t-16) block)
=
ws_partial_reveal ();
let init = ws_quad32 (t-16) block in
let next = ws_quad32 (t-15) block in
lemma_add_wrap_quad32_is_add_mod_quad32 init (_sigma0_quad32 next);
()
#pop-options
let lemma_sha256_msg1_spec_t (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires t < size_k_w_256 - 4 /\
src1 == ws_quad32 t block /\
src2.lo0 == ws_opaque block (t+4))
(ensures sha256_msg1_spec_t t block == sha256_msg1_spec src1 src2)
=
sha256_msg1_spec_reveal ();
()
#push-options "--z3rlimit 70"
let lemma_sha256_step2 (src1 src2:quad32) (t:counter) (block:block_w) : Lemma
(requires 16 <= t /\ t < size_k_w(SHA2_256) - 3 /\
src2.hi2 == ws_opaque block (t-2) /\
src2.hi3 == ws_opaque block (t-1) /\
(let w = sha256_msg1_spec_t (t-16) block in
let mid = ws_quad32 (t-7) block in
src1 == add_mod_quad32 w mid))
(ensures sha256_msg2_spec src1 src2 == ws_computed_quad32 t block) | false | false | Vale.SHA.SHA_helpers.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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": 70,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_sha256_step2 (src1 src2: quad32) (t: counter) (block: block_w)
: Lemma
(requires
16 <= t /\ t < size_k_w (SHA2_256) - 3 /\ src2.hi2 == ws_opaque block (t - 2) /\
src2.hi3 == ws_opaque block (t - 1) /\
(let w = sha256_msg1_spec_t (t - 16) block in
let mid = ws_quad32 (t - 7) block in
src1 == add_mod_quad32 w mid))
(ensures sha256_msg2_spec src1 src2 == ws_computed_quad32 t block) | [] | Vale.SHA.SHA_helpers.lemma_sha256_step2 | {
"file_name": "vale/code/crypto/sha/Vale.SHA.SHA_helpers.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
src1: Vale.Def.Types_s.quad32 ->
src2: Vale.Def.Types_s.quad32 ->
t: Vale.SHA.SHA_helpers.counter ->
block: Vale.SHA.SHA_helpers.block_w
-> FStar.Pervasives.Lemma
(requires
16 <= t /\ t < Spec.SHA2.size_k_w Spec.Hash.Definitions.SHA2_256 - 3 /\
Mkfour?.hi2 src2 == Vale.SHA.SHA_helpers.ws_opaque block (t - 2) /\
Mkfour?.hi3 src2 == Vale.SHA.SHA_helpers.ws_opaque block (t - 1) /\
(let w = Vale.SHA.SHA_helpers.sha256_msg1_spec_t (t - 16) block in
let mid = Vale.SHA.SHA_helpers.ws_quad32 (t - 7) block in
src1 == Vale.SHA.SHA_helpers.add_mod_quad32 w mid))
(ensures
Vale.X64.CryptoInstructions_s.sha256_msg2_spec src1 src2 ==
Vale.SHA.SHA_helpers.ws_computed_quad32 t block) | {
"end_col": 4,
"end_line": 594,
"start_col": 2,
"start_line": 588
} |
Prims.Tot | val va_codegen_success_MulAdd_unroll_1way : va_dummy:unit -> Tot va_pbool | [
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math // For lemma_poly_bits64()",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_codegen_success_MulAdd_unroll_1way () =
(va_pbool_and (va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_pbool_and
(va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
7)) (va_pbool_and (va_codegen_success_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (va_ttrue ())))))) | val va_codegen_success_MulAdd_unroll_1way : va_dummy:unit -> Tot va_pbool
let va_codegen_success_MulAdd_unroll_1way () = | false | null | false | (va_pbool_and (va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7)
Secret)
(va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 0))
(va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 7))
(va_pbool_and (va_codegen_success_VPolyMul (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 6))
(va_ttrue ())))))) | {
"checked_file": "Vale.AES.PPC64LE.GHash.fst.checked",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.GCTR_BE.fsti.checked",
"Vale.AES.GCM_helpers_BE.fsti.checked",
"Vale.AES.AES_helpers.fsti.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GHash.fst"
} | [
"total"
] | [
"Prims.unit",
"Vale.PPC64LE.Decls.va_pbool_and",
"Vale.PPC64LE.InsVector.va_codegen_success_Load128_byte16_buffer",
"Vale.PPC64LE.Decls.va_op_heaplet_mem_heaplet",
"Vale.PPC64LE.Decls.va_op_vec_opr_vec",
"Vale.PPC64LE.Decls.va_op_reg_opr_reg",
"Vale.Arch.HeapTypes_s.Secret",
"Vale.AES.PPC64LE.PolyOps.va_codegen_success_VPolyAdd",
"Vale.AES.PPC64LE.PolyOps.va_codegen_success_VPolyMulLow",
"Vale.AES.PPC64LE.PolyOps.va_codegen_success_VPolyMul",
"Vale.AES.PPC64LE.PolyOps.va_codegen_success_VPolyMulHigh",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | module Vale.AES.PPC64LE.GHash
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.AES_helpers
open Vale.Poly1305.Math // For lemma_poly_bits64()
open Vale.AES.GCM_helpers_BE
open Vale.AES.GCTR_BE_s
open Vale.AES.GCTR_BE
open Vale.Arch.TypesNative
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
#reset-options "--z3rlimit 50"
//-- MulAdd_unroll_1way
val va_code_MulAdd_unroll_1way : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_MulAdd_unroll_1way () =
(va_Block (va_CCons (va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_CCons (va_code_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_CCons
(va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5))
(va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
6)) (va_CNil ())))))))
val va_codegen_success_MulAdd_unroll_1way : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr] | false | true | Vale.AES.PPC64LE.GHash.fst | {
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_codegen_success_MulAdd_unroll_1way : va_dummy:unit -> Tot va_pbool | [] | Vale.AES.PPC64LE.GHash.va_codegen_success_MulAdd_unroll_1way | {
"file_name": "obj/Vale.AES.PPC64LE.GHash.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_dummy: Prims.unit -> Vale.PPC64LE.Decls.va_pbool | {
"end_col": 67,
"end_line": 58,
"start_col": 2,
"start_line": 52
} |
Prims.Tot | val va_codegen_success_GhashUnroll_n : exactly2:bool -> Tot va_pbool | [
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math // For lemma_poly_bits64()",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_codegen_success_GhashUnroll_n exactly2 =
(va_pbool_and (if exactly2 then va_pbool_and (va_codegen_success_MulAdd_unroll_2way ()) (va_ttrue
()) else va_pbool_and (va_codegen_success_MulAdd_unroll_1way ()) (va_ttrue ())) (va_pbool_and
(va_codegen_success_Vspltisw (va_op_vec_opr_vec 8) 0) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 8) 4) (va_pbool_and (va_codegen_success_ReduceLast ()) (va_ttrue ())))))))) | val va_codegen_success_GhashUnroll_n : exactly2:bool -> Tot va_pbool
let va_codegen_success_GhashUnroll_n exactly2 = | false | null | false | (va_pbool_and (if exactly2
then va_pbool_and (va_codegen_success_MulAdd_unroll_2way ()) (va_ttrue ())
else va_pbool_and (va_codegen_success_MulAdd_unroll_1way ()) (va_ttrue ()))
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 8) 0)
(va_pbool_and (va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (- 15872))
(va_pbool_and (va_codegen_success_Mtvsrws (va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10))
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 0)
4)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 8)
4)
(va_pbool_and (va_codegen_success_ReduceLast ()) (va_ttrue ())))))))) | {
"checked_file": "Vale.AES.PPC64LE.GHash.fst.checked",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.GCTR_BE.fsti.checked",
"Vale.AES.GCM_helpers_BE.fsti.checked",
"Vale.AES.AES_helpers.fsti.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GHash.fst"
} | [
"total"
] | [
"Prims.bool",
"Vale.PPC64LE.Decls.va_pbool_and",
"Vale.AES.PPC64LE.GHash.va_codegen_success_MulAdd_unroll_2way",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.AES.PPC64LE.GHash.va_codegen_success_MulAdd_unroll_1way",
"Vale.PPC64LE.Decls.va_pbool",
"Vale.PPC64LE.InsVector.va_codegen_success_Vspltisw",
"Vale.PPC64LE.Decls.va_op_vec_opr_vec",
"Vale.PPC64LE.InsBasic.va_codegen_success_LoadImmShl64",
"Vale.PPC64LE.Decls.va_op_reg_opr_reg",
"Prims.op_Minus",
"Vale.PPC64LE.InsVector.va_codegen_success_Mtvsrws",
"Vale.PPC64LE.InsVector.va_codegen_success_Vsldoi",
"Vale.AES.PPC64LE.GHash.va_codegen_success_ReduceLast"
] | [] | module Vale.AES.PPC64LE.GHash
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.AES_helpers
open Vale.Poly1305.Math // For lemma_poly_bits64()
open Vale.AES.GCM_helpers_BE
open Vale.AES.GCTR_BE_s
open Vale.AES.GCTR_BE
open Vale.Arch.TypesNative
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
#reset-options "--z3rlimit 50"
//-- MulAdd_unroll_1way
val va_code_MulAdd_unroll_1way : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_MulAdd_unroll_1way () =
(va_Block (va_CCons (va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_CCons (va_code_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_CCons
(va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5))
(va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
6)) (va_CNil ())))))))
val va_codegen_success_MulAdd_unroll_1way : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_MulAdd_unroll_1way () =
(va_pbool_and (va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_pbool_and
(va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
7)) (va_pbool_and (va_codegen_success_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (va_ttrue ()))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_MulAdd_unroll_1way (va_mods:va_mods_t) (in_b:buffer128) (index:nat) (h:poly)
(prev:poly) (data:(seq quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_1way ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (pdata:(Prims.int
-> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in let
(data_i:poly) = pdata 0 in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 136 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret in_b index) (fun (va_s:va_state) _ -> let
(va_arg44:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 138 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg44 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 139 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg43:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 140 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg43) (let
(va_arg42:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 141 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg42 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 142 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 143 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg41:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg40:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 144 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg40 va_arg41) (let
(va_arg39:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 145 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg39 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 146 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg38:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg37:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 147 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg37 va_arg38) (let
(va_arg36:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 148 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg36 64) (let
(va_arg35:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 149 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg35 64) (let
(va_arg34:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 150 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg34) (let
(va_arg33:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 151 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg33 64) (let
(va_arg32:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 152 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg32 64) (let
(va_arg31:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg30:Vale.Math.Poly2_s.poly) = add prev data_i in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 153 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg30 va_arg31) (va_QEmpty
(()))))))))))))))))))))
val va_lemma_MulAdd_unroll_1way : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 -> index:nat ->
h:poly -> prev:poly -> data:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_MulAdd_unroll_1way ()) va_s0 /\ va_get_ok va_s0 /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 1 /\
in_b_blocks in_b index 1 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0) /\ va_state_eq va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_ok va_sM va_s0)))))))
[@"opaque_to_smt"]
let va_lemma_MulAdd_unroll_1way va_b0 va_s0 in_b index h prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_MulAdd_unroll_1way va_mods in_b index h prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_MulAdd_unroll_1way ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 106 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in label va_range1
"***** POSTCONDITION NOT MET AT line 133 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_ok]) va_sM
va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_MulAdd_unroll_1way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq quad32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 1 /\
in_b_blocks in_b index 1 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64)) /\ (forall
(va_x_v0:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) . let va_sM = va_upd_vec 4
va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 va_s0))) in va_get_ok
va_sM /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0) ==> va_k va_sM (())))
val va_wpProof_MulAdd_unroll_1way : in_b:buffer128 -> index:nat -> h:poly -> prev:poly -> data:(seq
quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_MulAdd_unroll_1way in_b index h prev data va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_MulAdd_unroll_1way ()) ([va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_MulAdd_unroll_1way in_b index h prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_MulAdd_unroll_1way (va_code_MulAdd_unroll_1way ()) va_s0 in_b index
h prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 0 va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_MulAdd_unroll_1way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq
quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_1way ())) =
(va_QProc (va_code_MulAdd_unroll_1way ()) ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec
0]) (va_wp_MulAdd_unroll_1way in_b index h prev data) (va_wpProof_MulAdd_unroll_1way in_b index
h prev data))
//--
//-- MulAdd_unroll_2way
val va_code_MulAdd_unroll_2way : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_MulAdd_unroll_2way () =
(va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_CCons
(va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret) (va_CCons (va_code_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg
10) Secret) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 7)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 5)) (va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
8) (va_op_vec_opr_vec 6)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 0)) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec
10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (va_CCons (va_code_VPolyMulHigh
(va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 13)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 11)) (va_CNil
())))))))))))))))
val va_codegen_success_MulAdd_unroll_2way : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_MulAdd_unroll_2way () =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret) (va_pbool_and (va_codegen_success_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg
10) Secret) (va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 8) (va_op_vec_opr_vec 7)) (va_pbool_and (va_codegen_success_VPolyMul
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec
6)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 0)) (va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14)) (va_pbool_and (va_codegen_success_VPolyMul
(va_op_vec_opr_vec 10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (va_pbool_and
(va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 13)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_pbool_and
(va_codegen_success_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
11)) (va_ttrue ()))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_MulAdd_unroll_2way (va_mods:va_mods_t) (in_b:buffer128) (index:nat) (h:poly)
(prev:poly) (data:(seq quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_2way ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (pdata:(Prims.int
-> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in let
(data_0:poly) = pdata 0 in let (data_1:poly) = pdata 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 196 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 197 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret in_b index) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 198 column 32 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 10) Secret in_b (index + 1)) (fun (va_s:va_state) _ ->
let (va_arg95:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 200 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg95 1) (let
(va_arg94:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 201 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg94) (let
(va_arg93:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 202 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg93 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 203 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 204 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg92:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg91:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 205 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg91 va_arg92) (let
(va_arg90:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 206 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg90 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 207 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg89:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg88:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 208 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg88 va_arg89) (let
(va_arg87:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 209 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg87 64) (let
(va_arg86:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 210 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg86 64) (let
(va_arg85:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 211 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg85) (let
(va_arg84:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 212 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg84 64) (let
(va_arg83:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 213 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg83 64) (let
(va_arg82:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg81:Vale.Math.Poly2_s.poly) = data_1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 214 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg81 va_arg82) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 215 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 0) (let (va_arg80:Vale.Math.Poly2_s.poly)
= h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 218 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg80 2) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 219 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg79:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 220 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg79) (let
(va_arg78:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 221 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg78 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 222 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 223 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (fun
(va_s:va_state) _ -> let (va_arg77:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg76:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
2) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 224 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg76 va_arg77) (let
(va_arg75:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 225 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg75 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 226 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 13))
(fun (va_s:va_state) _ -> let (va_arg74:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64
in let (va_arg73:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 227 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg73 va_arg74) (let
(va_arg72:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 228 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg72 64) (let
(va_arg71:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 229 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg71 64) (let
(va_arg70:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 230 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg70) (let
(va_arg69:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 231 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg69 64) (let
(va_arg68:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 232 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg68 64) (let
(va_arg67:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift (add prev
data_0) (-64)) (Vale.Math.Poly2.mask (Vale.AES.GHash_BE.gf128_power h 2) 64) in let
(va_arg66:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask (add prev
data_0) 64) (Vale.Math.Poly2_s.shift (Vale.AES.GHash_BE.gf128_power h 2) (-64)) in let
(va_arg65:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec 3 va_s) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 233 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_add_associate va_arg65 va_arg66 va_arg67) (let
(va_arg64:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in let
(va_arg63:Vale.Math.Poly2_s.poly) = add prev data_0 in let (va_arg62:Vale.Math.Poly2_s.poly) =
of_quad32 (va_get_vec 4 va_s) in let (va_arg61:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec
3 va_s) in let (va_arg60:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec 2 va_s) in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 236 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128_accum va_arg60 va_arg61 va_arg62 va_arg63
va_arg64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 237 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 238 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 239 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 11))
(va_QEmpty (()))))))))))))))))))))))))))))))))))))))))))
val va_lemma_MulAdd_unroll_2way : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 -> index:nat ->
h:poly -> prev:poly -> data:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_MulAdd_unroll_2way ()) va_s0 /\ va_get_ok va_s0 /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 2 /\
in_b_blocks in_b index 2 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1) /\ va_state_eq va_sM
(va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))))))))))
[@"opaque_to_smt"]
let va_lemma_MulAdd_unroll_2way va_b0 va_s0 in_b index h prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec
4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_MulAdd_unroll_2way va_mods in_b index h prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_MulAdd_unroll_2way ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 156 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in label va_range1
"***** POSTCONDITION NOT MET AT line 192 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_MulAdd_unroll_2way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq quad32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 2 /\
in_b_blocks in_b index 2 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64)) /\ (forall
(va_x_r10:nat64) (va_x_v0:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32)
(va_x_v8:quad32) (va_x_v9:quad32) (va_x_v10:quad32) (va_x_v11:quad32) . let va_sM = va_upd_vec
11 va_x_v11 (va_upd_vec 10 va_x_v10 (va_upd_vec 9 va_x_v9 (va_upd_vec 8 va_x_v8 (va_upd_vec 4
va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 (va_upd_reg 10
va_x_r10 va_s0)))))))) in va_get_ok va_sM /\ (let (pdata:(Prims.int ->
Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1) ==> va_k va_sM (())))
val va_wpProof_MulAdd_unroll_2way : in_b:buffer128 -> index:nat -> h:poly -> prev:poly -> data:(seq
quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_MulAdd_unroll_2way in_b index h prev data va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_MulAdd_unroll_2way ()) ([va_Mod_vec
11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 0; va_Mod_reg 10]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_MulAdd_unroll_2way in_b index h prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_MulAdd_unroll_2way (va_code_MulAdd_unroll_2way ()) va_s0 in_b index
h prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM
(va_update_vec 8 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM va_s0)))))))))));
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_MulAdd_unroll_2way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq
quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_2way ())) =
(va_QProc (va_code_MulAdd_unroll_2way ()) ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9;
va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10])
(va_wp_MulAdd_unroll_2way in_b index h prev data) (va_wpProof_MulAdd_unroll_2way in_b index h
prev data))
//--
//-- Reduce
val va_code_Reduce : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Reduce () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 0) 0) (va_CCons (va_code_Low64ToHigh
(va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_CCons (va_code_VSwap (va_op_vec_opr_vec 10)
(va_op_vec_opr_vec 2)) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
2) (va_op_vec_opr_vec 8)) (va_CCons (va_code_High64ToLow (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 10)) (va_CCons (va_code_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2))
(va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
8)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
2)) (va_CNil ()))))))))))))))
val va_codegen_success_Reduce : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Reduce () =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 0) 0) (va_pbool_and
(va_codegen_success_Low64ToHigh (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9))
(va_pbool_and (va_codegen_success_VSwap (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 2))
(va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 8)) (va_pbool_and (va_codegen_success_High64ToLow (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 3)) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 10)) (va_pbool_and
(va_codegen_success_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_pbool_and
(va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
8)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_ttrue ())))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Reduce (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_Reduce ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in let
(c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in
let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 265 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 0) 0) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 266 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod a1 64) (let
(va_arg39:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.mask a1 64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 267 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_is_mul va_arg39 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 268 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Low64ToHigh (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3) a1) (fun (va_s:va_state) _ ->
let (va_arg38:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift (Vale.Math.Poly2.mask a1 64) 64
in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 269 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32 va_arg38) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 270 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 271 column 10 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VSwap (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 2)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 272 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 273 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div a1 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 274 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_High64ToLow (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) a1) (fun (va_s:va_state) _ ->
let (va_arg37:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift a1 (-64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 275 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32 va_arg37) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 276 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 3)) (fun
(va_s:va_state) _ -> let (va_arg36:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 10 va_s) in let (va_arg35:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 277 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_add_commute va_arg35 va_arg36) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 278 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 10)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 279 column 10 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 280 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 281 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 4)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 282 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (fun
(va_s:va_state) _ -> let (va_arg34:Vale.Math.Poly2_s.poly) = f in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 283 column 21 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_reduce_rev a0 a1 a2 va_arg34 64) (va_QEmpty
(()))))))))))))))))))))))
val va_lemma_Reduce : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Reduce ()) va_s0 /\ va_get_ok va_s0 /\ (let
(g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in let
(c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in
let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) (-64) == zero /\ Vale.Math.Poly2.mask (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) 64 == c /\ Vale.Math.Poly2_s.degree f < 64 /\ Vale.Math.Poly2_s.degree g
== 128 /\ Vale.Math.Poly2_s.poly_index f 0)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in let
(c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in
let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) ==
Vale.Math.Poly2_s.reverse (mod (Vale.Math.Poly2_s.reverse a 255) g) 127) /\ va_state_eq va_sM
(va_update_vec 1 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 9 va_sM
(va_update_vec 2 va_sM (va_update_vec 8 va_sM (va_update_vec 10 va_sM (va_update_vec 0 va_sM
(va_update_ok va_sM va_s0)))))))))))
[@"opaque_to_smt"]
let va_lemma_Reduce va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2;
va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_Reduce va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Reduce ()) va_qc va_s0 (fun va_s0 va_sM
va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 242 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f
in let (c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1))
63 in let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0)
in let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in label va_range1
"***** POSTCONDITION NOT MET AT line 263 column 60 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.Math.Poly2_s.reverse (mod
(Vale.Math.Poly2_s.reverse a 255) g) 127))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2;
va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Reduce (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in
let (c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63
in let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in
let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) (-64) == zero /\ Vale.Math.Poly2.mask (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) 64 == c /\ Vale.Math.Poly2_s.degree f < 64 /\ Vale.Math.Poly2_s.degree g
== 128 /\ Vale.Math.Poly2_s.poly_index f 0) /\ (forall (va_x_v0:quad32) (va_x_v10:quad32)
(va_x_v8:quad32) (va_x_v2:quad32) (va_x_v9:quad32) (va_x_v3:quad32) (va_x_v4:quad32)
(va_x_v1:quad32) . let va_sM = va_upd_vec 1 va_x_v1 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3
(va_upd_vec 9 va_x_v9 (va_upd_vec 2 va_x_v2 (va_upd_vec 8 va_x_v8 (va_upd_vec 10 va_x_v10
(va_upd_vec 0 va_x_v0 va_s0))))))) in va_get_ok va_sM /\ (let (g:Vale.Math.Poly2_s.poly) = add
(Vale.Math.Poly2_s.monomial 128) f in let (c:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in let
(a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) ==
Vale.Math.Poly2_s.reverse (mod (Vale.Math.Poly2_s.reverse a 255) g) 127) ==> va_k va_sM (())))
val va_wpProof_Reduce : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Reduce f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Reduce ()) ([va_Mod_vec 1; va_Mod_vec
4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2; va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0]) va_s0
va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Reduce f va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Reduce (va_code_Reduce ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 1 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 9 va_sM (va_update_vec 2 va_sM (va_update_vec 8 va_sM (va_update_vec 10 va_sM
(va_update_vec 0 va_sM (va_update_ok va_sM va_s0))))))))));
va_lemma_norm_mods ([va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2;
va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Reduce (f:poly) : (va_quickCode unit (va_code_Reduce ())) =
(va_QProc (va_code_Reduce ()) ([va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9;
va_Mod_vec 2; va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0]) (va_wp_Reduce f) (va_wpProof_Reduce
f))
//--
//-- ReduceLast
[@ "opaque_to_smt" va_qattr]
let va_code_ReduceLast () =
(va_Block (va_CCons (va_code_Reduce ()) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_Block
(va_CNil ())) (va_CNil ())))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ReduceLast () =
(va_pbool_and (va_codegen_success_Reduce ()) (va_ttrue ()))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ReduceLast (va_mods:va_mods_t) (h_BE:quad32) (y_prev:quad32) (data:(seq quad32)) :
(va_quickCode unit (va_code_ReduceLast ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in let
(prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in let (n:Prims.nat) = FStar.Seq.Base.length #quad32 data in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 311 column 35 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_constant_shift_rev ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 312 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_degree ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 313 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Reduce gf128_modulus_low_terms) (fun (va_s:va_state) _ -> va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 314 column 36 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(n - 1 >= 0) (fun _ -> let (va_arg25:Prims.nat) = n - 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 314 column 36 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_ghash_unroll_back_forward h prev pdata 0 va_arg25)
(va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 315 column 31 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(n - 1 >= 0) (fun _ -> let (va_arg24:Prims.nat) = n - 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 315 column 31 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_ghash_poly_of_unroll h prev pdata 0 va_arg24) (let
(va_arg23:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = data in let
(va_arg22:Vale.Def.Types_s.quad32) = y_prev in let (va_arg21:Vale.Def.Types_s.quad32) = h_BE in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 316 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_ghash_incremental_poly va_arg21 va_arg22 va_arg23)
(let (va_arg20:Vale.Def.Types_s.quad32) = Vale.AES.GHash_BE.ghash_incremental h_BE y_prev data
in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 317 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_to_of_quad32 va_arg20) (va_QEmpty (()))))))))))))
[@"opaque_to_smt"]
let va_lemma_ReduceLast va_b0 va_s0 h_BE y_prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_ReduceLast va_mods h_BE y_prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ReduceLast ()) va_qc va_s0 (fun va_s0
va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 286 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in
let (prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in let (n:Prims.nat) = FStar.Seq.Base.length #quad32 data in label va_range1
"***** POSTCONDITION NOT MET AT line 307 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(let xi = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) in label va_range1
"***** POSTCONDITION NOT MET AT line 308 column 63 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.Math.Poly2.Bits_s.to_quad32 xi == Vale.AES.GHash_BE.ghash_incremental h_BE y_prev data)
/\ label va_range1
"***** POSTCONDITION NOT MET AT line 309 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(xi == Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Math.Poly2.Bits_s.to_quad32 xi))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_ReduceLast h_BE y_prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ReduceLast (va_code_ReduceLast ()) va_s0 h_BE y_prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_vec 0 va_sM (va_update_ok va_sM va_s0))))))))));
va_lemma_norm_mods ([va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- GhashUnroll_n
[@ "opaque_to_smt" va_qattr]
let va_code_GhashUnroll_n exactly2 =
(va_Block (va_CCons (if exactly2 then va_Block (va_CCons (va_code_MulAdd_unroll_2way ()) (va_CNil
())) else va_Block (va_CCons (va_code_MulAdd_unroll_1way ()) (va_CNil ()))) (va_CCons
(va_code_Vspltisw (va_op_vec_opr_vec 8) 0) (va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg
10) (-15872)) (va_CCons (va_code_Mtvsrws (va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10))
(va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4)
(va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) 4)
(va_CCons (va_code_ReduceLast ()) (va_CNil ())))))))))
[@ "opaque_to_smt" va_qattr] | false | true | Vale.AES.PPC64LE.GHash.fst | {
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_codegen_success_GhashUnroll_n : exactly2:bool -> Tot va_pbool | [] | Vale.AES.PPC64LE.GHash.va_codegen_success_GhashUnroll_n | {
"file_name": "obj/Vale.AES.PPC64LE.GHash.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | exactly2: Prims.bool -> Vale.PPC64LE.Decls.va_pbool | {
"end_col": 98,
"end_line": 819,
"start_col": 2,
"start_line": 812
} |
Prims.Tot | val va_code_Ghash_buffer_loop_body : va_dummy:unit -> Tot va_code | [
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math // For lemma_poly_bits64()",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_code_Ghash_buffer_loop_body () =
(va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_Block (va_CNil ())) (va_CCons
(va_code_GhashUnroll_n true) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_Block (va_CNil
())) (va_CCons (va_code_AddImm (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 7) 32) (va_CCons
(va_code_SubImm (va_op_reg_opr_reg 6) (va_op_reg_opr_reg 6) 2) (va_CNil ()))))))))) | val va_code_Ghash_buffer_loop_body : va_dummy:unit -> Tot va_code
let va_code_Ghash_buffer_loop_body () = | false | null | false | (va_Block (va_CCons (va_Block (va_CNil ()))
(va_CCons (va_Block (va_CNil ()))
(va_CCons (va_code_GhashUnroll_n true)
(va_CCons (va_Block (va_CNil ()))
(va_CCons (va_Block (va_CNil ()))
(va_CCons (va_code_AddImm (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 7) 32)
(va_CCons (va_code_SubImm (va_op_reg_opr_reg 6) (va_op_reg_opr_reg 6) 2)
(va_CNil ()))))))))) | {
"checked_file": "Vale.AES.PPC64LE.GHash.fst.checked",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.GCTR_BE.fsti.checked",
"Vale.AES.GCM_helpers_BE.fsti.checked",
"Vale.AES.AES_helpers.fsti.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GHash.fst"
} | [
"total"
] | [
"Prims.unit",
"Vale.PPC64LE.Decls.va_Block",
"Vale.PPC64LE.Decls.va_CCons",
"Vale.PPC64LE.Decls.va_CNil",
"Vale.AES.PPC64LE.GHash.va_code_GhashUnroll_n",
"Vale.PPC64LE.InsBasic.va_code_AddImm",
"Vale.PPC64LE.Decls.va_op_reg_opr_reg",
"Vale.PPC64LE.InsBasic.va_code_SubImm",
"Vale.PPC64LE.Decls.va_code"
] | [] | module Vale.AES.PPC64LE.GHash
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.AES_helpers
open Vale.Poly1305.Math // For lemma_poly_bits64()
open Vale.AES.GCM_helpers_BE
open Vale.AES.GCTR_BE_s
open Vale.AES.GCTR_BE
open Vale.Arch.TypesNative
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
#reset-options "--z3rlimit 50"
//-- MulAdd_unroll_1way
val va_code_MulAdd_unroll_1way : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_MulAdd_unroll_1way () =
(va_Block (va_CCons (va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_CCons (va_code_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_CCons
(va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5))
(va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
6)) (va_CNil ())))))))
val va_codegen_success_MulAdd_unroll_1way : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_MulAdd_unroll_1way () =
(va_pbool_and (va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_pbool_and
(va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
7)) (va_pbool_and (va_codegen_success_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (va_ttrue ()))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_MulAdd_unroll_1way (va_mods:va_mods_t) (in_b:buffer128) (index:nat) (h:poly)
(prev:poly) (data:(seq quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_1way ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (pdata:(Prims.int
-> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in let
(data_i:poly) = pdata 0 in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 136 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret in_b index) (fun (va_s:va_state) _ -> let
(va_arg44:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 138 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg44 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 139 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg43:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 140 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg43) (let
(va_arg42:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 141 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg42 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 142 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 143 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg41:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg40:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 144 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg40 va_arg41) (let
(va_arg39:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 145 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg39 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 146 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg38:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg37:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 147 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg37 va_arg38) (let
(va_arg36:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 148 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg36 64) (let
(va_arg35:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 149 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg35 64) (let
(va_arg34:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 150 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg34) (let
(va_arg33:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 151 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg33 64) (let
(va_arg32:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 152 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg32 64) (let
(va_arg31:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg30:Vale.Math.Poly2_s.poly) = add prev data_i in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 153 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg30 va_arg31) (va_QEmpty
(()))))))))))))))))))))
val va_lemma_MulAdd_unroll_1way : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 -> index:nat ->
h:poly -> prev:poly -> data:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_MulAdd_unroll_1way ()) va_s0 /\ va_get_ok va_s0 /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 1 /\
in_b_blocks in_b index 1 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0) /\ va_state_eq va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_ok va_sM va_s0)))))))
[@"opaque_to_smt"]
let va_lemma_MulAdd_unroll_1way va_b0 va_s0 in_b index h prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_MulAdd_unroll_1way va_mods in_b index h prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_MulAdd_unroll_1way ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 106 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in label va_range1
"***** POSTCONDITION NOT MET AT line 133 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_ok]) va_sM
va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_MulAdd_unroll_1way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq quad32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 1 /\
in_b_blocks in_b index 1 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64)) /\ (forall
(va_x_v0:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) . let va_sM = va_upd_vec 4
va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 va_s0))) in va_get_ok
va_sM /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0) ==> va_k va_sM (())))
val va_wpProof_MulAdd_unroll_1way : in_b:buffer128 -> index:nat -> h:poly -> prev:poly -> data:(seq
quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_MulAdd_unroll_1way in_b index h prev data va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_MulAdd_unroll_1way ()) ([va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_MulAdd_unroll_1way in_b index h prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_MulAdd_unroll_1way (va_code_MulAdd_unroll_1way ()) va_s0 in_b index
h prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 0 va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_MulAdd_unroll_1way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq
quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_1way ())) =
(va_QProc (va_code_MulAdd_unroll_1way ()) ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec
0]) (va_wp_MulAdd_unroll_1way in_b index h prev data) (va_wpProof_MulAdd_unroll_1way in_b index
h prev data))
//--
//-- MulAdd_unroll_2way
val va_code_MulAdd_unroll_2way : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_MulAdd_unroll_2way () =
(va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_CCons
(va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret) (va_CCons (va_code_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg
10) Secret) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 7)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 5)) (va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
8) (va_op_vec_opr_vec 6)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 0)) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec
10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (va_CCons (va_code_VPolyMulHigh
(va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 13)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 11)) (va_CNil
())))))))))))))))
val va_codegen_success_MulAdd_unroll_2way : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_MulAdd_unroll_2way () =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret) (va_pbool_and (va_codegen_success_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg
10) Secret) (va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 8) (va_op_vec_opr_vec 7)) (va_pbool_and (va_codegen_success_VPolyMul
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec
6)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 0)) (va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14)) (va_pbool_and (va_codegen_success_VPolyMul
(va_op_vec_opr_vec 10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (va_pbool_and
(va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 13)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_pbool_and
(va_codegen_success_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
11)) (va_ttrue ()))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_MulAdd_unroll_2way (va_mods:va_mods_t) (in_b:buffer128) (index:nat) (h:poly)
(prev:poly) (data:(seq quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_2way ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (pdata:(Prims.int
-> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in let
(data_0:poly) = pdata 0 in let (data_1:poly) = pdata 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 196 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 197 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret in_b index) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 198 column 32 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 10) Secret in_b (index + 1)) (fun (va_s:va_state) _ ->
let (va_arg95:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 200 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg95 1) (let
(va_arg94:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 201 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg94) (let
(va_arg93:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 202 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg93 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 203 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 204 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg92:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg91:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 205 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg91 va_arg92) (let
(va_arg90:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 206 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg90 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 207 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg89:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg88:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 208 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg88 va_arg89) (let
(va_arg87:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 209 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg87 64) (let
(va_arg86:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 210 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg86 64) (let
(va_arg85:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 211 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg85) (let
(va_arg84:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 212 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg84 64) (let
(va_arg83:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 213 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg83 64) (let
(va_arg82:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg81:Vale.Math.Poly2_s.poly) = data_1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 214 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg81 va_arg82) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 215 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 0) (let (va_arg80:Vale.Math.Poly2_s.poly)
= h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 218 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg80 2) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 219 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg79:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 220 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg79) (let
(va_arg78:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 221 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg78 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 222 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 223 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (fun
(va_s:va_state) _ -> let (va_arg77:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg76:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
2) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 224 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg76 va_arg77) (let
(va_arg75:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 225 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg75 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 226 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 13))
(fun (va_s:va_state) _ -> let (va_arg74:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64
in let (va_arg73:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 227 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg73 va_arg74) (let
(va_arg72:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 228 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg72 64) (let
(va_arg71:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 229 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg71 64) (let
(va_arg70:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 230 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg70) (let
(va_arg69:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 231 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg69 64) (let
(va_arg68:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 232 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg68 64) (let
(va_arg67:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift (add prev
data_0) (-64)) (Vale.Math.Poly2.mask (Vale.AES.GHash_BE.gf128_power h 2) 64) in let
(va_arg66:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask (add prev
data_0) 64) (Vale.Math.Poly2_s.shift (Vale.AES.GHash_BE.gf128_power h 2) (-64)) in let
(va_arg65:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec 3 va_s) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 233 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_add_associate va_arg65 va_arg66 va_arg67) (let
(va_arg64:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in let
(va_arg63:Vale.Math.Poly2_s.poly) = add prev data_0 in let (va_arg62:Vale.Math.Poly2_s.poly) =
of_quad32 (va_get_vec 4 va_s) in let (va_arg61:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec
3 va_s) in let (va_arg60:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec 2 va_s) in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 236 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128_accum va_arg60 va_arg61 va_arg62 va_arg63
va_arg64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 237 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 238 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 239 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 11))
(va_QEmpty (()))))))))))))))))))))))))))))))))))))))))))
val va_lemma_MulAdd_unroll_2way : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 -> index:nat ->
h:poly -> prev:poly -> data:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_MulAdd_unroll_2way ()) va_s0 /\ va_get_ok va_s0 /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 2 /\
in_b_blocks in_b index 2 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1) /\ va_state_eq va_sM
(va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))))))))))
[@"opaque_to_smt"]
let va_lemma_MulAdd_unroll_2way va_b0 va_s0 in_b index h prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec
4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_MulAdd_unroll_2way va_mods in_b index h prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_MulAdd_unroll_2way ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 156 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in label va_range1
"***** POSTCONDITION NOT MET AT line 192 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_MulAdd_unroll_2way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq quad32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 2 /\
in_b_blocks in_b index 2 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64)) /\ (forall
(va_x_r10:nat64) (va_x_v0:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32)
(va_x_v8:quad32) (va_x_v9:quad32) (va_x_v10:quad32) (va_x_v11:quad32) . let va_sM = va_upd_vec
11 va_x_v11 (va_upd_vec 10 va_x_v10 (va_upd_vec 9 va_x_v9 (va_upd_vec 8 va_x_v8 (va_upd_vec 4
va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 (va_upd_reg 10
va_x_r10 va_s0)))))))) in va_get_ok va_sM /\ (let (pdata:(Prims.int ->
Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1) ==> va_k va_sM (())))
val va_wpProof_MulAdd_unroll_2way : in_b:buffer128 -> index:nat -> h:poly -> prev:poly -> data:(seq
quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_MulAdd_unroll_2way in_b index h prev data va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_MulAdd_unroll_2way ()) ([va_Mod_vec
11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 0; va_Mod_reg 10]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_MulAdd_unroll_2way in_b index h prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_MulAdd_unroll_2way (va_code_MulAdd_unroll_2way ()) va_s0 in_b index
h prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM
(va_update_vec 8 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM va_s0)))))))))));
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_MulAdd_unroll_2way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq
quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_2way ())) =
(va_QProc (va_code_MulAdd_unroll_2way ()) ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9;
va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10])
(va_wp_MulAdd_unroll_2way in_b index h prev data) (va_wpProof_MulAdd_unroll_2way in_b index h
prev data))
//--
//-- Reduce
val va_code_Reduce : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Reduce () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 0) 0) (va_CCons (va_code_Low64ToHigh
(va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_CCons (va_code_VSwap (va_op_vec_opr_vec 10)
(va_op_vec_opr_vec 2)) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
2) (va_op_vec_opr_vec 8)) (va_CCons (va_code_High64ToLow (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 10)) (va_CCons (va_code_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2))
(va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
8)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
2)) (va_CNil ()))))))))))))))
val va_codegen_success_Reduce : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Reduce () =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 0) 0) (va_pbool_and
(va_codegen_success_Low64ToHigh (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9))
(va_pbool_and (va_codegen_success_VSwap (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 2))
(va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 8)) (va_pbool_and (va_codegen_success_High64ToLow (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 3)) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 10)) (va_pbool_and
(va_codegen_success_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_pbool_and
(va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
8)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_ttrue ())))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Reduce (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_Reduce ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in let
(c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in
let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 265 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 0) 0) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 266 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod a1 64) (let
(va_arg39:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.mask a1 64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 267 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_is_mul va_arg39 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 268 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Low64ToHigh (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3) a1) (fun (va_s:va_state) _ ->
let (va_arg38:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift (Vale.Math.Poly2.mask a1 64) 64
in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 269 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32 va_arg38) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 270 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 271 column 10 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VSwap (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 2)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 272 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 273 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div a1 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 274 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_High64ToLow (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) a1) (fun (va_s:va_state) _ ->
let (va_arg37:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift a1 (-64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 275 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32 va_arg37) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 276 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 3)) (fun
(va_s:va_state) _ -> let (va_arg36:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 10 va_s) in let (va_arg35:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 277 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_add_commute va_arg35 va_arg36) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 278 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 10)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 279 column 10 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 280 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 281 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 4)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 282 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (fun
(va_s:va_state) _ -> let (va_arg34:Vale.Math.Poly2_s.poly) = f in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 283 column 21 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_reduce_rev a0 a1 a2 va_arg34 64) (va_QEmpty
(()))))))))))))))))))))))
val va_lemma_Reduce : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Reduce ()) va_s0 /\ va_get_ok va_s0 /\ (let
(g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in let
(c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in
let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) (-64) == zero /\ Vale.Math.Poly2.mask (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) 64 == c /\ Vale.Math.Poly2_s.degree f < 64 /\ Vale.Math.Poly2_s.degree g
== 128 /\ Vale.Math.Poly2_s.poly_index f 0)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in let
(c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in
let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) ==
Vale.Math.Poly2_s.reverse (mod (Vale.Math.Poly2_s.reverse a 255) g) 127) /\ va_state_eq va_sM
(va_update_vec 1 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 9 va_sM
(va_update_vec 2 va_sM (va_update_vec 8 va_sM (va_update_vec 10 va_sM (va_update_vec 0 va_sM
(va_update_ok va_sM va_s0)))))))))))
[@"opaque_to_smt"]
let va_lemma_Reduce va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2;
va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_Reduce va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Reduce ()) va_qc va_s0 (fun va_s0 va_sM
va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 242 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f
in let (c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1))
63 in let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0)
in let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in label va_range1
"***** POSTCONDITION NOT MET AT line 263 column 60 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.Math.Poly2_s.reverse (mod
(Vale.Math.Poly2_s.reverse a 255) g) 127))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2;
va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Reduce (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in
let (c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63
in let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in
let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) (-64) == zero /\ Vale.Math.Poly2.mask (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) 64 == c /\ Vale.Math.Poly2_s.degree f < 64 /\ Vale.Math.Poly2_s.degree g
== 128 /\ Vale.Math.Poly2_s.poly_index f 0) /\ (forall (va_x_v0:quad32) (va_x_v10:quad32)
(va_x_v8:quad32) (va_x_v2:quad32) (va_x_v9:quad32) (va_x_v3:quad32) (va_x_v4:quad32)
(va_x_v1:quad32) . let va_sM = va_upd_vec 1 va_x_v1 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3
(va_upd_vec 9 va_x_v9 (va_upd_vec 2 va_x_v2 (va_upd_vec 8 va_x_v8 (va_upd_vec 10 va_x_v10
(va_upd_vec 0 va_x_v0 va_s0))))))) in va_get_ok va_sM /\ (let (g:Vale.Math.Poly2_s.poly) = add
(Vale.Math.Poly2_s.monomial 128) f in let (c:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in let
(a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) ==
Vale.Math.Poly2_s.reverse (mod (Vale.Math.Poly2_s.reverse a 255) g) 127) ==> va_k va_sM (())))
val va_wpProof_Reduce : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Reduce f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Reduce ()) ([va_Mod_vec 1; va_Mod_vec
4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2; va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0]) va_s0
va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Reduce f va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Reduce (va_code_Reduce ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 1 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 9 va_sM (va_update_vec 2 va_sM (va_update_vec 8 va_sM (va_update_vec 10 va_sM
(va_update_vec 0 va_sM (va_update_ok va_sM va_s0))))))))));
va_lemma_norm_mods ([va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2;
va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Reduce (f:poly) : (va_quickCode unit (va_code_Reduce ())) =
(va_QProc (va_code_Reduce ()) ([va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9;
va_Mod_vec 2; va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0]) (va_wp_Reduce f) (va_wpProof_Reduce
f))
//--
//-- ReduceLast
[@ "opaque_to_smt" va_qattr]
let va_code_ReduceLast () =
(va_Block (va_CCons (va_code_Reduce ()) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_Block
(va_CNil ())) (va_CNil ())))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ReduceLast () =
(va_pbool_and (va_codegen_success_Reduce ()) (va_ttrue ()))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ReduceLast (va_mods:va_mods_t) (h_BE:quad32) (y_prev:quad32) (data:(seq quad32)) :
(va_quickCode unit (va_code_ReduceLast ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in let
(prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in let (n:Prims.nat) = FStar.Seq.Base.length #quad32 data in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 311 column 35 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_constant_shift_rev ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 312 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_degree ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 313 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Reduce gf128_modulus_low_terms) (fun (va_s:va_state) _ -> va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 314 column 36 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(n - 1 >= 0) (fun _ -> let (va_arg25:Prims.nat) = n - 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 314 column 36 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_ghash_unroll_back_forward h prev pdata 0 va_arg25)
(va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 315 column 31 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(n - 1 >= 0) (fun _ -> let (va_arg24:Prims.nat) = n - 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 315 column 31 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_ghash_poly_of_unroll h prev pdata 0 va_arg24) (let
(va_arg23:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = data in let
(va_arg22:Vale.Def.Types_s.quad32) = y_prev in let (va_arg21:Vale.Def.Types_s.quad32) = h_BE in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 316 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_ghash_incremental_poly va_arg21 va_arg22 va_arg23)
(let (va_arg20:Vale.Def.Types_s.quad32) = Vale.AES.GHash_BE.ghash_incremental h_BE y_prev data
in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 317 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_to_of_quad32 va_arg20) (va_QEmpty (()))))))))))))
[@"opaque_to_smt"]
let va_lemma_ReduceLast va_b0 va_s0 h_BE y_prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_ReduceLast va_mods h_BE y_prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ReduceLast ()) va_qc va_s0 (fun va_s0
va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 286 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in
let (prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in let (n:Prims.nat) = FStar.Seq.Base.length #quad32 data in label va_range1
"***** POSTCONDITION NOT MET AT line 307 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(let xi = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) in label va_range1
"***** POSTCONDITION NOT MET AT line 308 column 63 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.Math.Poly2.Bits_s.to_quad32 xi == Vale.AES.GHash_BE.ghash_incremental h_BE y_prev data)
/\ label va_range1
"***** POSTCONDITION NOT MET AT line 309 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(xi == Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Math.Poly2.Bits_s.to_quad32 xi))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_ReduceLast h_BE y_prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ReduceLast (va_code_ReduceLast ()) va_s0 h_BE y_prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_vec 0 va_sM (va_update_ok va_sM va_s0))))))))));
va_lemma_norm_mods ([va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- GhashUnroll_n
[@ "opaque_to_smt" va_qattr]
let va_code_GhashUnroll_n exactly2 =
(va_Block (va_CCons (if exactly2 then va_Block (va_CCons (va_code_MulAdd_unroll_2way ()) (va_CNil
())) else va_Block (va_CCons (va_code_MulAdd_unroll_1way ()) (va_CNil ()))) (va_CCons
(va_code_Vspltisw (va_op_vec_opr_vec 8) 0) (va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg
10) (-15872)) (va_CCons (va_code_Mtvsrws (va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10))
(va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4)
(va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) 4)
(va_CCons (va_code_ReduceLast ()) (va_CNil ())))))))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_GhashUnroll_n exactly2 =
(va_pbool_and (if exactly2 then va_pbool_and (va_codegen_success_MulAdd_unroll_2way ()) (va_ttrue
()) else va_pbool_and (va_codegen_success_MulAdd_unroll_1way ()) (va_ttrue ())) (va_pbool_and
(va_codegen_success_Vspltisw (va_op_vec_opr_vec 8) 0) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 8) 4) (va_pbool_and (va_codegen_success_ReduceLast ()) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_GhashUnroll_n (va_mods:va_mods_t) (exactly2:bool) (in_b:buffer128) (index:nat)
(h_BE:quad32) (y_prev:quad32) (data:(seq quad32)) : (va_quickCode unit (va_code_GhashUnroll_n
exactly2)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in let
(prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in let (n:Prims.nat) = FStar.Seq.Base.length #quad32 data in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 361 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_qInlineIf va_mods exactly2 (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 363 column 27 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_MulAdd_unroll_2way in_b index h prev data) (va_QEmpty (())))) (qblock va_mods (fun
(va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 367 column 27 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_MulAdd_unroll_1way in_b index h prev data) (va_QEmpty (()))))) (fun (va_s:va_state)
va_g -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 369 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 8) 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 370 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (fun (va_s:va_state) _ -> let
(va_arg27:Vale.Def.Types_s.nat64) = (-15872) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 371 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg27 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 372 column 12 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 373 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 374 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) 4) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 375 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_ReduceLast h_BE y_prev data) (va_QEmpty (())))))))))))
[@"opaque_to_smt"]
let va_lemma_GhashUnroll_n va_b0 va_s0 exactly2 in_b index h_BE y_prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec
4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_GhashUnroll_n va_mods exactly2 in_b index h_BE y_prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_GhashUnroll_n exactly2) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 320 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in
let (prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in let (n:Prims.nat) = FStar.Seq.Base.length #quad32 data in label va_range1
"***** POSTCONDITION NOT MET AT line 359 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.GHash_BE.ghash_incremental h_BE y_prev data))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_GhashUnroll_n exactly2 in_b index h_BE y_prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_GhashUnroll_n (va_code_GhashUnroll_n exactly2) va_s0 exactly2 in_b
index h_BE y_prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM
(va_update_vec 8 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0))))))))))));
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Ghash_register
[@ "opaque_to_smt" va_qattr]
let va_code_Ghash_register () =
(va_Block (va_CCons (va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 5) Secret) (va_CCons (va_code_Vspltisw
(va_op_vec_opr_vec 0) 0) (va_CCons (va_code_VSwap (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5))
(va_CCons (va_code_High64ToLow (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 5)) (va_CCons
(va_code_Low64ToHigh (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 5)) (va_CCons (va_Block (va_CNil
())) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
9)) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 7)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 5)) (va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
9) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 8) 0) (va_CCons
(va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_CCons (va_code_Mtvsrws
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10)) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) 4) (va_CCons (va_code_ReduceLast ()) (va_CNil
()))))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Ghash_register () =
(va_pbool_and (va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 5) Secret) (va_pbool_and (va_codegen_success_Vspltisw
(va_op_vec_opr_vec 0) 0) (va_pbool_and (va_codegen_success_VSwap (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_High64ToLow (va_op_vec_opr_vec 7)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_Low64ToHigh (va_op_vec_opr_vec 6)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 9)) (va_pbool_and (va_codegen_success_VPolyMulLow
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 7)) (va_pbool_and
(va_codegen_success_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 8) 0)
(va_pbool_and (va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 8) 4) (va_pbool_and (va_codegen_success_ReduceLast ()) (va_ttrue
()))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Ghash_register (va_mods:va_mods_t) (hkeys_b:buffer128) (h_BE:quad32) (y_prev:quad32) :
(va_quickCode unit (va_code_Ghash_register ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in let
(data:(FStar.Seq.Base.seq quad32)) = FStar.Seq.Base.create #quad32 1 (va_get_vec 9 va_s) in let
(prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 405 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 0) (va_op_vec_opr_vec 5)
(va_op_reg_opr_reg 5) Secret hkeys_b 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 406 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 0) 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 407 column 10 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VSwap (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5)) (fun (va_s:va_state) _ -> let
(va_arg71:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 408 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_quad32_double va_arg71) (let
(va_arg70:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 409 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_double_swap va_arg70) (let
(va_arg69:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.swap (Vale.AES.GHash_BE.gf128_power h 1) 64
in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 410 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_quad32_double va_arg69) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 411 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_High64ToLow (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 5) (Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 412 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Low64ToHigh (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 5) (Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64)) (fun (va_s:va_state) _ -> let
(va_arg68:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 413 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32 va_arg68) (let
(va_arg67:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 414 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32 va_arg67) (va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 416 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(0 >= 0 /\ (fun a_336 (s_337:(FStar.Seq.Base.seq a_336)) (i_338:Prims.nat) -> let
(i_312:Prims.nat) = i_338 in Prims.b2t (Prims.op_LessThan i_312 (FStar.Seq.Base.length #a_336
s_337))) quad32 data 0) (fun _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 416 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_vec 9 va_s == FStar.Seq.Base.index #quad32 data 0) (let (data_i:poly) = pdata 0 in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 419 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power h 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 420 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 9)) (fun
(va_s:va_state) _ -> let (va_arg66:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 421 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg66) (let
(va_arg65:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 422 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg65 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 423 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 424 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg64:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg63:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 425 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg63 va_arg64) (let
(va_arg62:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 426 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg62 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 427 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg61:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg60:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 428 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg60 va_arg61) (let
(va_arg59:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 429 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg59 64) (let
(va_arg58:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 430 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg58 64) (let
(va_arg57:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 431 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg57) (let
(va_arg56:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 432 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg56 64) (let
(va_arg55:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 433 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg55 64) (let
(va_arg54:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg53:Vale.Math.Poly2_s.poly) = add prev data_i in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 434 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg53 va_arg54) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 436 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 8) 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 437 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (fun (va_s:va_state) _ -> let
(va_arg52:Vale.Def.Types_s.nat64) = (-15872) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 438 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg52 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 439 column 12 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 440 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 441 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) 4) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 442 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_ReduceLast h_BE y_prev data) (va_QEmpty (()))))))))))))))))))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Ghash_register va_b0 va_s0 hkeys_b h_BE y_prev =
let (va_mods:va_mods_t) = [va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 7; va_Mod_vec 6;
va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg
10; va_Mod_ok] in
let va_qc = va_qcode_Ghash_register va_mods hkeys_b h_BE y_prev in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Ghash_register ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 378 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in
let (data:(FStar.Seq.Base.seq quad32)) = FStar.Seq.Base.create #quad32 1 (va_get_vec 9 va_s0)
in let (prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in label va_range1
"***** POSTCONDITION NOT MET AT line 403 column 57 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.GHash_BE.ghash_incremental h_BE y_prev data))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 7; va_Mod_vec 6;
va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg
10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Ghash_register hkeys_b h_BE y_prev va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Ghash_register (va_code_Ghash_register ()) va_s0 hkeys_b h_BE
y_prev in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM
(va_update_vec 7 va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM
(va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))))))))))));
va_lemma_norm_mods ([va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 7; va_Mod_vec 6;
va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg
10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Ghash_buffer_loop_body
val va_code_Ghash_buffer_loop_body : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr] | false | true | Vale.AES.PPC64LE.GHash.fst | {
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_code_Ghash_buffer_loop_body : va_dummy:unit -> Tot va_code | [] | Vale.AES.PPC64LE.GHash.va_code_Ghash_buffer_loop_body | {
"file_name": "obj/Vale.AES.PPC64LE.GHash.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_dummy: Prims.unit -> Vale.PPC64LE.Decls.va_code | {
"end_col": 87,
"end_line": 1099,
"start_col": 2,
"start_line": 1096
} |
Prims.Tot | val va_wp_MulAdd_unroll_2way
(in_b: buffer128)
(index: nat)
(h prev: poly)
(data: (seq quad32))
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | [
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math // For lemma_poly_bits64()",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_wp_MulAdd_unroll_2way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq quad32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 2 /\
in_b_blocks in_b index 2 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64)) /\ (forall
(va_x_r10:nat64) (va_x_v0:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32)
(va_x_v8:quad32) (va_x_v9:quad32) (va_x_v10:quad32) (va_x_v11:quad32) . let va_sM = va_upd_vec
11 va_x_v11 (va_upd_vec 10 va_x_v10 (va_upd_vec 9 va_x_v9 (va_upd_vec 8 va_x_v8 (va_upd_vec 4
va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 (va_upd_reg 10
va_x_r10 va_s0)))))))) in va_get_ok va_sM /\ (let (pdata:(Prims.int ->
Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1) ==> va_k va_sM (()))) | val va_wp_MulAdd_unroll_2way
(in_b: buffer128)
(index: nat)
(h prev: poly)
(data: (seq quad32))
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0
let va_wp_MulAdd_unroll_2way
(in_b: buffer128)
(index: nat)
(h prev: poly)
(data: (seq quad32))
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 = | false | null | false | (va_get_ok va_s0 /\
(let pdata:(Prims.int -> Vale.AES.GHash_BE.poly128) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data
in
FStar.Seq.Base.length #quad32 data == 2 /\
in_b_blocks in_b
index
2
(va_get_mem_heaplet 1 va_s0)
(va_get_mem_layout va_s0)
(va_get_reg 7 va_s0)
data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) ==
Vale.Math.Poly2.swap (Vale.AES.GHash_BE.gf128_power h 1) 64 /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0) ==
Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) ==
Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) ==
Vale.Math.Poly2.swap (Vale.AES.GHash_BE.gf128_power h 2) 64 /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13 va_s0) ==
Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) ==
Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64)) /\
(forall (va_x_r10: nat64)
(va_x_v0: quad32)
(va_x_v2: quad32)
(va_x_v3: quad32)
(va_x_v4: quad32)
(va_x_v8: quad32)
(va_x_v9: quad32)
(va_x_v10: quad32)
(va_x_v11: quad32).
let va_sM =
va_upd_vec 11
va_x_v11
(va_upd_vec 10
va_x_v10
(va_upd_vec 9
va_x_v9
(va_upd_vec 8
va_x_v8
(va_upd_vec 4
va_x_v4
(va_upd_vec 3
va_x_v3
(va_upd_vec 2
va_x_v2
(va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 va_s0))))))))
in
va_get_ok va_sM /\
(let pdata:(Prims.int -> Vale.AES.GHash_BE.poly128) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data
in
add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM))
(Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64))
(Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1) ==>
va_k va_sM (()))) | {
"checked_file": "Vale.AES.PPC64LE.GHash.fst.checked",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.GCTR_BE.fsti.checked",
"Vale.AES.GCM_helpers_BE.fsti.checked",
"Vale.AES.AES_helpers.fsti.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GHash.fst"
} | [
"total"
] | [
"Vale.PPC64LE.Memory.buffer128",
"Prims.nat",
"Vale.Math.Poly2_s.poly",
"FStar.Seq.Base.seq",
"Vale.PPC64LE.Memory.quad32",
"Vale.PPC64LE.Decls.va_state",
"Prims.unit",
"Prims.l_and",
"Prims.b2t",
"Vale.PPC64LE.Decls.va_get_ok",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"Vale.AES.PPC64LE.GHash.in_b_blocks",
"Vale.PPC64LE.Decls.va_get_mem_heaplet",
"Vale.PPC64LE.Decls.va_get_mem_layout",
"Vale.PPC64LE.Decls.va_get_reg",
"Vale.Math.Poly2.Bits_s.of_quad32",
"Vale.PPC64LE.Decls.va_get_vec",
"Vale.Math.Poly2.swap",
"Vale.AES.GHash_BE.gf128_power",
"Vale.Math.Poly2_s.mul",
"Vale.Math.Poly2_s.div",
"Vale.Math.Poly2_s.monomial",
"Vale.Math.Poly2_s.mod",
"Vale.AES.GHash_BE.poly128",
"Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128",
"Prims.l_Forall",
"Vale.PPC64LE.Memory.nat64",
"Prims.l_imp",
"Vale.Math.Poly2_s.add",
"Vale.Math.Poly2_s.shift",
"Vale.AES.GHash_BE.ghash_unroll_back",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.Decls.va_upd_vec",
"Vale.PPC64LE.Decls.va_upd_reg"
] | [] | module Vale.AES.PPC64LE.GHash
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.AES_helpers
open Vale.Poly1305.Math // For lemma_poly_bits64()
open Vale.AES.GCM_helpers_BE
open Vale.AES.GCTR_BE_s
open Vale.AES.GCTR_BE
open Vale.Arch.TypesNative
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
#reset-options "--z3rlimit 50"
//-- MulAdd_unroll_1way
val va_code_MulAdd_unroll_1way : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_MulAdd_unroll_1way () =
(va_Block (va_CCons (va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_CCons (va_code_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_CCons
(va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5))
(va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
6)) (va_CNil ())))))))
val va_codegen_success_MulAdd_unroll_1way : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_MulAdd_unroll_1way () =
(va_pbool_and (va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_pbool_and
(va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
7)) (va_pbool_and (va_codegen_success_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (va_ttrue ()))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_MulAdd_unroll_1way (va_mods:va_mods_t) (in_b:buffer128) (index:nat) (h:poly)
(prev:poly) (data:(seq quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_1way ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (pdata:(Prims.int
-> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in let
(data_i:poly) = pdata 0 in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 136 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret in_b index) (fun (va_s:va_state) _ -> let
(va_arg44:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 138 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg44 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 139 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg43:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 140 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg43) (let
(va_arg42:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 141 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg42 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 142 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 143 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg41:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg40:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 144 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg40 va_arg41) (let
(va_arg39:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 145 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg39 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 146 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg38:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg37:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 147 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg37 va_arg38) (let
(va_arg36:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 148 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg36 64) (let
(va_arg35:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 149 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg35 64) (let
(va_arg34:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 150 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg34) (let
(va_arg33:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 151 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg33 64) (let
(va_arg32:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 152 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg32 64) (let
(va_arg31:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg30:Vale.Math.Poly2_s.poly) = add prev data_i in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 153 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg30 va_arg31) (va_QEmpty
(()))))))))))))))))))))
val va_lemma_MulAdd_unroll_1way : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 -> index:nat ->
h:poly -> prev:poly -> data:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_MulAdd_unroll_1way ()) va_s0 /\ va_get_ok va_s0 /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 1 /\
in_b_blocks in_b index 1 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0) /\ va_state_eq va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_ok va_sM va_s0)))))))
[@"opaque_to_smt"]
let va_lemma_MulAdd_unroll_1way va_b0 va_s0 in_b index h prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_MulAdd_unroll_1way va_mods in_b index h prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_MulAdd_unroll_1way ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 106 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in label va_range1
"***** POSTCONDITION NOT MET AT line 133 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_ok]) va_sM
va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_MulAdd_unroll_1way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq quad32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 1 /\
in_b_blocks in_b index 1 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64)) /\ (forall
(va_x_v0:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) . let va_sM = va_upd_vec 4
va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 va_s0))) in va_get_ok
va_sM /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0) ==> va_k va_sM (())))
val va_wpProof_MulAdd_unroll_1way : in_b:buffer128 -> index:nat -> h:poly -> prev:poly -> data:(seq
quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_MulAdd_unroll_1way in_b index h prev data va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_MulAdd_unroll_1way ()) ([va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_MulAdd_unroll_1way in_b index h prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_MulAdd_unroll_1way (va_code_MulAdd_unroll_1way ()) va_s0 in_b index
h prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 0 va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_MulAdd_unroll_1way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq
quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_1way ())) =
(va_QProc (va_code_MulAdd_unroll_1way ()) ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec
0]) (va_wp_MulAdd_unroll_1way in_b index h prev data) (va_wpProof_MulAdd_unroll_1way in_b index
h prev data))
//--
//-- MulAdd_unroll_2way
val va_code_MulAdd_unroll_2way : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_MulAdd_unroll_2way () =
(va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_CCons
(va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret) (va_CCons (va_code_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg
10) Secret) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 7)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 5)) (va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
8) (va_op_vec_opr_vec 6)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 0)) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec
10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (va_CCons (va_code_VPolyMulHigh
(va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 13)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 11)) (va_CNil
())))))))))))))))
val va_codegen_success_MulAdd_unroll_2way : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_MulAdd_unroll_2way () =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret) (va_pbool_and (va_codegen_success_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg
10) Secret) (va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 8) (va_op_vec_opr_vec 7)) (va_pbool_and (va_codegen_success_VPolyMul
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec
6)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 0)) (va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14)) (va_pbool_and (va_codegen_success_VPolyMul
(va_op_vec_opr_vec 10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (va_pbool_and
(va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 13)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_pbool_and
(va_codegen_success_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
11)) (va_ttrue ()))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_MulAdd_unroll_2way (va_mods:va_mods_t) (in_b:buffer128) (index:nat) (h:poly)
(prev:poly) (data:(seq quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_2way ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (pdata:(Prims.int
-> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in let
(data_0:poly) = pdata 0 in let (data_1:poly) = pdata 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 196 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 197 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret in_b index) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 198 column 32 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 10) Secret in_b (index + 1)) (fun (va_s:va_state) _ ->
let (va_arg95:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 200 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg95 1) (let
(va_arg94:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 201 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg94) (let
(va_arg93:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 202 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg93 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 203 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 204 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg92:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg91:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 205 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg91 va_arg92) (let
(va_arg90:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 206 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg90 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 207 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg89:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg88:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 208 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg88 va_arg89) (let
(va_arg87:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 209 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg87 64) (let
(va_arg86:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 210 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg86 64) (let
(va_arg85:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 211 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg85) (let
(va_arg84:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 212 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg84 64) (let
(va_arg83:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 213 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg83 64) (let
(va_arg82:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg81:Vale.Math.Poly2_s.poly) = data_1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 214 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg81 va_arg82) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 215 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 0) (let (va_arg80:Vale.Math.Poly2_s.poly)
= h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 218 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg80 2) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 219 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg79:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 220 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg79) (let
(va_arg78:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 221 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg78 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 222 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 223 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (fun
(va_s:va_state) _ -> let (va_arg77:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg76:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
2) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 224 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg76 va_arg77) (let
(va_arg75:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 225 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg75 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 226 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 13))
(fun (va_s:va_state) _ -> let (va_arg74:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64
in let (va_arg73:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 227 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg73 va_arg74) (let
(va_arg72:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 228 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg72 64) (let
(va_arg71:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 229 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg71 64) (let
(va_arg70:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 230 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg70) (let
(va_arg69:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 231 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg69 64) (let
(va_arg68:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 232 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg68 64) (let
(va_arg67:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift (add prev
data_0) (-64)) (Vale.Math.Poly2.mask (Vale.AES.GHash_BE.gf128_power h 2) 64) in let
(va_arg66:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask (add prev
data_0) 64) (Vale.Math.Poly2_s.shift (Vale.AES.GHash_BE.gf128_power h 2) (-64)) in let
(va_arg65:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec 3 va_s) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 233 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_add_associate va_arg65 va_arg66 va_arg67) (let
(va_arg64:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in let
(va_arg63:Vale.Math.Poly2_s.poly) = add prev data_0 in let (va_arg62:Vale.Math.Poly2_s.poly) =
of_quad32 (va_get_vec 4 va_s) in let (va_arg61:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec
3 va_s) in let (va_arg60:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec 2 va_s) in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 236 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128_accum va_arg60 va_arg61 va_arg62 va_arg63
va_arg64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 237 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 238 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 239 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 11))
(va_QEmpty (()))))))))))))))))))))))))))))))))))))))))))
val va_lemma_MulAdd_unroll_2way : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 -> index:nat ->
h:poly -> prev:poly -> data:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_MulAdd_unroll_2way ()) va_s0 /\ va_get_ok va_s0 /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 2 /\
in_b_blocks in_b index 2 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1) /\ va_state_eq va_sM
(va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))))))))))
[@"opaque_to_smt"]
let va_lemma_MulAdd_unroll_2way va_b0 va_s0 in_b index h prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec
4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_MulAdd_unroll_2way va_mods in_b index h prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_MulAdd_unroll_2way ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 156 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in label va_range1
"***** POSTCONDITION NOT MET AT line 192 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_MulAdd_unroll_2way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq quad32)) | false | true | Vale.AES.PPC64LE.GHash.fst | {
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_wp_MulAdd_unroll_2way
(in_b: buffer128)
(index: nat)
(h prev: poly)
(data: (seq quad32))
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | [] | Vale.AES.PPC64LE.GHash.va_wp_MulAdd_unroll_2way | {
"file_name": "obj/Vale.AES.PPC64LE.GHash.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
in_b: Vale.PPC64LE.Memory.buffer128 ->
index: Prims.nat ->
h: Vale.Math.Poly2_s.poly ->
prev: Vale.Math.Poly2_s.poly ->
data: FStar.Seq.Base.seq Vale.PPC64LE.Memory.quad32 ->
va_s0: Vale.PPC64LE.Decls.va_state ->
va_k: (_: Vale.PPC64LE.Decls.va_state -> _: Prims.unit -> Type0)
-> Type0 | {
"end_col": 81,
"end_line": 487,
"start_col": 2,
"start_line": 462
} |
Prims.Tot | val va_code_MulAdd_unroll_2way : va_dummy:unit -> Tot va_code | [
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math // For lemma_poly_bits64()",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_code_MulAdd_unroll_2way () =
(va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_CCons
(va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret) (va_CCons (va_code_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg
10) Secret) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 7)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 5)) (va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
8) (va_op_vec_opr_vec 6)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 0)) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec
10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (va_CCons (va_code_VPolyMulHigh
(va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 13)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 11)) (va_CNil
()))))))))))))))) | val va_code_MulAdd_unroll_2way : va_dummy:unit -> Tot va_code
let va_code_MulAdd_unroll_2way () = | false | null | false | (va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 16)
(va_CCons (va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7)
Secret)
(va_CCons (va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 8)
(va_op_reg_opr_reg 7)
(va_op_reg_opr_reg 10)
Secret)
(va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 7))
(va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 5))
(va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 6))
(va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 0))
(va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 14))
(va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 10)
(va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 12))
(va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 11)
(va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 13))
(va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 9))
(va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 10))
(va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 4
)
(va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 11))
(va_CNil ()))))))))))))))) | {
"checked_file": "Vale.AES.PPC64LE.GHash.fst.checked",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.GCTR_BE.fsti.checked",
"Vale.AES.GCM_helpers_BE.fsti.checked",
"Vale.AES.AES_helpers.fsti.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GHash.fst"
} | [
"total"
] | [
"Prims.unit",
"Vale.PPC64LE.Decls.va_Block",
"Vale.PPC64LE.Decls.va_CCons",
"Vale.PPC64LE.InsBasic.va_code_LoadImm64",
"Vale.PPC64LE.Decls.va_op_reg_opr_reg",
"Vale.PPC64LE.InsVector.va_code_Load128_byte16_buffer",
"Vale.PPC64LE.Decls.va_op_heaplet_mem_heaplet",
"Vale.PPC64LE.Decls.va_op_vec_opr_vec",
"Vale.Arch.HeapTypes_s.Secret",
"Vale.PPC64LE.InsVector.va_code_Load128_byte16_buffer_index",
"Vale.AES.PPC64LE.PolyOps.va_code_VPolyMulLow",
"Vale.AES.PPC64LE.PolyOps.va_code_VPolyMul",
"Vale.AES.PPC64LE.PolyOps.va_code_VPolyMulHigh",
"Vale.AES.PPC64LE.PolyOps.va_code_VPolyAdd",
"Vale.PPC64LE.Decls.va_CNil",
"Vale.PPC64LE.Decls.va_code"
] | [] | module Vale.AES.PPC64LE.GHash
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.AES_helpers
open Vale.Poly1305.Math // For lemma_poly_bits64()
open Vale.AES.GCM_helpers_BE
open Vale.AES.GCTR_BE_s
open Vale.AES.GCTR_BE
open Vale.Arch.TypesNative
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
#reset-options "--z3rlimit 50"
//-- MulAdd_unroll_1way
val va_code_MulAdd_unroll_1way : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_MulAdd_unroll_1way () =
(va_Block (va_CCons (va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_CCons (va_code_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_CCons
(va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5))
(va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
6)) (va_CNil ())))))))
val va_codegen_success_MulAdd_unroll_1way : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_MulAdd_unroll_1way () =
(va_pbool_and (va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_pbool_and
(va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
7)) (va_pbool_and (va_codegen_success_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (va_ttrue ()))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_MulAdd_unroll_1way (va_mods:va_mods_t) (in_b:buffer128) (index:nat) (h:poly)
(prev:poly) (data:(seq quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_1way ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (pdata:(Prims.int
-> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in let
(data_i:poly) = pdata 0 in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 136 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret in_b index) (fun (va_s:va_state) _ -> let
(va_arg44:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 138 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg44 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 139 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg43:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 140 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg43) (let
(va_arg42:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 141 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg42 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 142 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 143 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg41:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg40:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 144 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg40 va_arg41) (let
(va_arg39:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 145 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg39 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 146 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg38:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg37:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 147 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg37 va_arg38) (let
(va_arg36:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 148 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg36 64) (let
(va_arg35:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 149 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg35 64) (let
(va_arg34:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 150 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg34) (let
(va_arg33:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 151 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg33 64) (let
(va_arg32:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 152 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg32 64) (let
(va_arg31:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg30:Vale.Math.Poly2_s.poly) = add prev data_i in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 153 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg30 va_arg31) (va_QEmpty
(()))))))))))))))))))))
val va_lemma_MulAdd_unroll_1way : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 -> index:nat ->
h:poly -> prev:poly -> data:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_MulAdd_unroll_1way ()) va_s0 /\ va_get_ok va_s0 /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 1 /\
in_b_blocks in_b index 1 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0) /\ va_state_eq va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_ok va_sM va_s0)))))))
[@"opaque_to_smt"]
let va_lemma_MulAdd_unroll_1way va_b0 va_s0 in_b index h prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_MulAdd_unroll_1way va_mods in_b index h prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_MulAdd_unroll_1way ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 106 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in label va_range1
"***** POSTCONDITION NOT MET AT line 133 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_ok]) va_sM
va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_MulAdd_unroll_1way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq quad32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 1 /\
in_b_blocks in_b index 1 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64)) /\ (forall
(va_x_v0:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) . let va_sM = va_upd_vec 4
va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 va_s0))) in va_get_ok
va_sM /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0) ==> va_k va_sM (())))
val va_wpProof_MulAdd_unroll_1way : in_b:buffer128 -> index:nat -> h:poly -> prev:poly -> data:(seq
quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_MulAdd_unroll_1way in_b index h prev data va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_MulAdd_unroll_1way ()) ([va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_MulAdd_unroll_1way in_b index h prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_MulAdd_unroll_1way (va_code_MulAdd_unroll_1way ()) va_s0 in_b index
h prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 0 va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_MulAdd_unroll_1way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq
quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_1way ())) =
(va_QProc (va_code_MulAdd_unroll_1way ()) ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec
0]) (va_wp_MulAdd_unroll_1way in_b index h prev data) (va_wpProof_MulAdd_unroll_1way in_b index
h prev data))
//--
//-- MulAdd_unroll_2way
val va_code_MulAdd_unroll_2way : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr] | false | true | Vale.AES.PPC64LE.GHash.fst | {
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_code_MulAdd_unroll_2way : va_dummy:unit -> Tot va_code | [] | Vale.AES.PPC64LE.GHash.va_code_MulAdd_unroll_2way | {
"file_name": "obj/Vale.AES.PPC64LE.GHash.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_dummy: Prims.unit -> Vale.PPC64LE.Decls.va_code | {
"end_col": 21,
"end_line": 235,
"start_col": 2,
"start_line": 220
} |
Prims.Tot | val va_code_ReduceLast : va_dummy:unit -> Tot va_code | [
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math // For lemma_poly_bits64()",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_code_ReduceLast () =
(va_Block (va_CCons (va_code_Reduce ()) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_Block
(va_CNil ())) (va_CNil ()))))) | val va_code_ReduceLast : va_dummy:unit -> Tot va_code
let va_code_ReduceLast () = | false | null | false | (va_Block (va_CCons (va_code_Reduce ())
(va_CCons (va_Block (va_CNil ())) (va_CCons (va_Block (va_CNil ())) (va_CNil ()))))) | {
"checked_file": "Vale.AES.PPC64LE.GHash.fst.checked",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.GCTR_BE.fsti.checked",
"Vale.AES.GCM_helpers_BE.fsti.checked",
"Vale.AES.AES_helpers.fsti.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GHash.fst"
} | [
"total"
] | [
"Prims.unit",
"Vale.PPC64LE.Decls.va_Block",
"Vale.PPC64LE.Decls.va_CCons",
"Vale.AES.PPC64LE.GHash.va_code_Reduce",
"Vale.PPC64LE.Decls.va_CNil",
"Vale.PPC64LE.Decls.va_code"
] | [] | module Vale.AES.PPC64LE.GHash
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.AES_helpers
open Vale.Poly1305.Math // For lemma_poly_bits64()
open Vale.AES.GCM_helpers_BE
open Vale.AES.GCTR_BE_s
open Vale.AES.GCTR_BE
open Vale.Arch.TypesNative
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
#reset-options "--z3rlimit 50"
//-- MulAdd_unroll_1way
val va_code_MulAdd_unroll_1way : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_MulAdd_unroll_1way () =
(va_Block (va_CCons (va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_CCons (va_code_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_CCons
(va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5))
(va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
6)) (va_CNil ())))))))
val va_codegen_success_MulAdd_unroll_1way : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_MulAdd_unroll_1way () =
(va_pbool_and (va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_pbool_and
(va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
7)) (va_pbool_and (va_codegen_success_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (va_ttrue ()))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_MulAdd_unroll_1way (va_mods:va_mods_t) (in_b:buffer128) (index:nat) (h:poly)
(prev:poly) (data:(seq quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_1way ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (pdata:(Prims.int
-> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in let
(data_i:poly) = pdata 0 in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 136 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret in_b index) (fun (va_s:va_state) _ -> let
(va_arg44:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 138 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg44 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 139 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg43:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 140 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg43) (let
(va_arg42:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 141 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg42 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 142 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 143 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg41:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg40:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 144 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg40 va_arg41) (let
(va_arg39:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 145 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg39 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 146 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg38:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg37:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 147 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg37 va_arg38) (let
(va_arg36:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 148 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg36 64) (let
(va_arg35:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 149 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg35 64) (let
(va_arg34:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 150 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg34) (let
(va_arg33:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 151 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg33 64) (let
(va_arg32:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 152 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg32 64) (let
(va_arg31:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg30:Vale.Math.Poly2_s.poly) = add prev data_i in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 153 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg30 va_arg31) (va_QEmpty
(()))))))))))))))))))))
val va_lemma_MulAdd_unroll_1way : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 -> index:nat ->
h:poly -> prev:poly -> data:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_MulAdd_unroll_1way ()) va_s0 /\ va_get_ok va_s0 /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 1 /\
in_b_blocks in_b index 1 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0) /\ va_state_eq va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_ok va_sM va_s0)))))))
[@"opaque_to_smt"]
let va_lemma_MulAdd_unroll_1way va_b0 va_s0 in_b index h prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_MulAdd_unroll_1way va_mods in_b index h prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_MulAdd_unroll_1way ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 106 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in label va_range1
"***** POSTCONDITION NOT MET AT line 133 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_ok]) va_sM
va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_MulAdd_unroll_1way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq quad32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 1 /\
in_b_blocks in_b index 1 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64)) /\ (forall
(va_x_v0:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) . let va_sM = va_upd_vec 4
va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 va_s0))) in va_get_ok
va_sM /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0) ==> va_k va_sM (())))
val va_wpProof_MulAdd_unroll_1way : in_b:buffer128 -> index:nat -> h:poly -> prev:poly -> data:(seq
quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_MulAdd_unroll_1way in_b index h prev data va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_MulAdd_unroll_1way ()) ([va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_MulAdd_unroll_1way in_b index h prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_MulAdd_unroll_1way (va_code_MulAdd_unroll_1way ()) va_s0 in_b index
h prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 0 va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_MulAdd_unroll_1way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq
quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_1way ())) =
(va_QProc (va_code_MulAdd_unroll_1way ()) ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec
0]) (va_wp_MulAdd_unroll_1way in_b index h prev data) (va_wpProof_MulAdd_unroll_1way in_b index
h prev data))
//--
//-- MulAdd_unroll_2way
val va_code_MulAdd_unroll_2way : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_MulAdd_unroll_2way () =
(va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_CCons
(va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret) (va_CCons (va_code_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg
10) Secret) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 7)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 5)) (va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
8) (va_op_vec_opr_vec 6)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 0)) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec
10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (va_CCons (va_code_VPolyMulHigh
(va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 13)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 11)) (va_CNil
())))))))))))))))
val va_codegen_success_MulAdd_unroll_2way : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_MulAdd_unroll_2way () =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret) (va_pbool_and (va_codegen_success_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg
10) Secret) (va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 8) (va_op_vec_opr_vec 7)) (va_pbool_and (va_codegen_success_VPolyMul
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec
6)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 0)) (va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14)) (va_pbool_and (va_codegen_success_VPolyMul
(va_op_vec_opr_vec 10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (va_pbool_and
(va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 13)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_pbool_and
(va_codegen_success_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
11)) (va_ttrue ()))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_MulAdd_unroll_2way (va_mods:va_mods_t) (in_b:buffer128) (index:nat) (h:poly)
(prev:poly) (data:(seq quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_2way ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (pdata:(Prims.int
-> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in let
(data_0:poly) = pdata 0 in let (data_1:poly) = pdata 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 196 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 197 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret in_b index) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 198 column 32 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 10) Secret in_b (index + 1)) (fun (va_s:va_state) _ ->
let (va_arg95:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 200 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg95 1) (let
(va_arg94:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 201 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg94) (let
(va_arg93:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 202 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg93 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 203 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 204 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg92:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg91:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 205 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg91 va_arg92) (let
(va_arg90:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 206 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg90 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 207 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg89:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg88:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 208 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg88 va_arg89) (let
(va_arg87:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 209 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg87 64) (let
(va_arg86:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 210 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg86 64) (let
(va_arg85:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 211 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg85) (let
(va_arg84:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 212 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg84 64) (let
(va_arg83:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 213 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg83 64) (let
(va_arg82:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg81:Vale.Math.Poly2_s.poly) = data_1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 214 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg81 va_arg82) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 215 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 0) (let (va_arg80:Vale.Math.Poly2_s.poly)
= h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 218 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg80 2) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 219 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg79:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 220 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg79) (let
(va_arg78:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 221 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg78 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 222 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 223 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (fun
(va_s:va_state) _ -> let (va_arg77:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg76:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
2) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 224 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg76 va_arg77) (let
(va_arg75:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 225 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg75 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 226 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 13))
(fun (va_s:va_state) _ -> let (va_arg74:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64
in let (va_arg73:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 227 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg73 va_arg74) (let
(va_arg72:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 228 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg72 64) (let
(va_arg71:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 229 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg71 64) (let
(va_arg70:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 230 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg70) (let
(va_arg69:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 231 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg69 64) (let
(va_arg68:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 232 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg68 64) (let
(va_arg67:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift (add prev
data_0) (-64)) (Vale.Math.Poly2.mask (Vale.AES.GHash_BE.gf128_power h 2) 64) in let
(va_arg66:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask (add prev
data_0) 64) (Vale.Math.Poly2_s.shift (Vale.AES.GHash_BE.gf128_power h 2) (-64)) in let
(va_arg65:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec 3 va_s) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 233 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_add_associate va_arg65 va_arg66 va_arg67) (let
(va_arg64:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in let
(va_arg63:Vale.Math.Poly2_s.poly) = add prev data_0 in let (va_arg62:Vale.Math.Poly2_s.poly) =
of_quad32 (va_get_vec 4 va_s) in let (va_arg61:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec
3 va_s) in let (va_arg60:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec 2 va_s) in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 236 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128_accum va_arg60 va_arg61 va_arg62 va_arg63
va_arg64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 237 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 238 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 239 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 11))
(va_QEmpty (()))))))))))))))))))))))))))))))))))))))))))
val va_lemma_MulAdd_unroll_2way : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 -> index:nat ->
h:poly -> prev:poly -> data:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_MulAdd_unroll_2way ()) va_s0 /\ va_get_ok va_s0 /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 2 /\
in_b_blocks in_b index 2 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1) /\ va_state_eq va_sM
(va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))))))))))
[@"opaque_to_smt"]
let va_lemma_MulAdd_unroll_2way va_b0 va_s0 in_b index h prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec
4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_MulAdd_unroll_2way va_mods in_b index h prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_MulAdd_unroll_2way ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 156 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in label va_range1
"***** POSTCONDITION NOT MET AT line 192 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_MulAdd_unroll_2way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq quad32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 2 /\
in_b_blocks in_b index 2 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64)) /\ (forall
(va_x_r10:nat64) (va_x_v0:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32)
(va_x_v8:quad32) (va_x_v9:quad32) (va_x_v10:quad32) (va_x_v11:quad32) . let va_sM = va_upd_vec
11 va_x_v11 (va_upd_vec 10 va_x_v10 (va_upd_vec 9 va_x_v9 (va_upd_vec 8 va_x_v8 (va_upd_vec 4
va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 (va_upd_reg 10
va_x_r10 va_s0)))))))) in va_get_ok va_sM /\ (let (pdata:(Prims.int ->
Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1) ==> va_k va_sM (())))
val va_wpProof_MulAdd_unroll_2way : in_b:buffer128 -> index:nat -> h:poly -> prev:poly -> data:(seq
quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_MulAdd_unroll_2way in_b index h prev data va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_MulAdd_unroll_2way ()) ([va_Mod_vec
11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 0; va_Mod_reg 10]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_MulAdd_unroll_2way in_b index h prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_MulAdd_unroll_2way (va_code_MulAdd_unroll_2way ()) va_s0 in_b index
h prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM
(va_update_vec 8 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM va_s0)))))))))));
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_MulAdd_unroll_2way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq
quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_2way ())) =
(va_QProc (va_code_MulAdd_unroll_2way ()) ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9;
va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10])
(va_wp_MulAdd_unroll_2way in_b index h prev data) (va_wpProof_MulAdd_unroll_2way in_b index h
prev data))
//--
//-- Reduce
val va_code_Reduce : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Reduce () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 0) 0) (va_CCons (va_code_Low64ToHigh
(va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_CCons (va_code_VSwap (va_op_vec_opr_vec 10)
(va_op_vec_opr_vec 2)) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
2) (va_op_vec_opr_vec 8)) (va_CCons (va_code_High64ToLow (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 10)) (va_CCons (va_code_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2))
(va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
8)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
2)) (va_CNil ()))))))))))))))
val va_codegen_success_Reduce : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Reduce () =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 0) 0) (va_pbool_and
(va_codegen_success_Low64ToHigh (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9))
(va_pbool_and (va_codegen_success_VSwap (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 2))
(va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 8)) (va_pbool_and (va_codegen_success_High64ToLow (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 3)) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 10)) (va_pbool_and
(va_codegen_success_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_pbool_and
(va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
8)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_ttrue ())))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Reduce (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_Reduce ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in let
(c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in
let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 265 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 0) 0) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 266 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod a1 64) (let
(va_arg39:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.mask a1 64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 267 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_is_mul va_arg39 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 268 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Low64ToHigh (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3) a1) (fun (va_s:va_state) _ ->
let (va_arg38:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift (Vale.Math.Poly2.mask a1 64) 64
in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 269 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32 va_arg38) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 270 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 271 column 10 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VSwap (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 2)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 272 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 273 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div a1 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 274 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_High64ToLow (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) a1) (fun (va_s:va_state) _ ->
let (va_arg37:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift a1 (-64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 275 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32 va_arg37) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 276 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 3)) (fun
(va_s:va_state) _ -> let (va_arg36:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 10 va_s) in let (va_arg35:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 277 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_add_commute va_arg35 va_arg36) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 278 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 10)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 279 column 10 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 280 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 281 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 4)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 282 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (fun
(va_s:va_state) _ -> let (va_arg34:Vale.Math.Poly2_s.poly) = f in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 283 column 21 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_reduce_rev a0 a1 a2 va_arg34 64) (va_QEmpty
(()))))))))))))))))))))))
val va_lemma_Reduce : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Reduce ()) va_s0 /\ va_get_ok va_s0 /\ (let
(g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in let
(c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in
let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) (-64) == zero /\ Vale.Math.Poly2.mask (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) 64 == c /\ Vale.Math.Poly2_s.degree f < 64 /\ Vale.Math.Poly2_s.degree g
== 128 /\ Vale.Math.Poly2_s.poly_index f 0)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in let
(c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in
let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) ==
Vale.Math.Poly2_s.reverse (mod (Vale.Math.Poly2_s.reverse a 255) g) 127) /\ va_state_eq va_sM
(va_update_vec 1 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 9 va_sM
(va_update_vec 2 va_sM (va_update_vec 8 va_sM (va_update_vec 10 va_sM (va_update_vec 0 va_sM
(va_update_ok va_sM va_s0)))))))))))
[@"opaque_to_smt"]
let va_lemma_Reduce va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2;
va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_Reduce va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Reduce ()) va_qc va_s0 (fun va_s0 va_sM
va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 242 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f
in let (c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1))
63 in let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0)
in let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in label va_range1
"***** POSTCONDITION NOT MET AT line 263 column 60 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.Math.Poly2_s.reverse (mod
(Vale.Math.Poly2_s.reverse a 255) g) 127))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2;
va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Reduce (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in
let (c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63
in let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in
let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) (-64) == zero /\ Vale.Math.Poly2.mask (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) 64 == c /\ Vale.Math.Poly2_s.degree f < 64 /\ Vale.Math.Poly2_s.degree g
== 128 /\ Vale.Math.Poly2_s.poly_index f 0) /\ (forall (va_x_v0:quad32) (va_x_v10:quad32)
(va_x_v8:quad32) (va_x_v2:quad32) (va_x_v9:quad32) (va_x_v3:quad32) (va_x_v4:quad32)
(va_x_v1:quad32) . let va_sM = va_upd_vec 1 va_x_v1 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3
(va_upd_vec 9 va_x_v9 (va_upd_vec 2 va_x_v2 (va_upd_vec 8 va_x_v8 (va_upd_vec 10 va_x_v10
(va_upd_vec 0 va_x_v0 va_s0))))))) in va_get_ok va_sM /\ (let (g:Vale.Math.Poly2_s.poly) = add
(Vale.Math.Poly2_s.monomial 128) f in let (c:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in let
(a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) ==
Vale.Math.Poly2_s.reverse (mod (Vale.Math.Poly2_s.reverse a 255) g) 127) ==> va_k va_sM (())))
val va_wpProof_Reduce : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Reduce f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Reduce ()) ([va_Mod_vec 1; va_Mod_vec
4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2; va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0]) va_s0
va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Reduce f va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Reduce (va_code_Reduce ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 1 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 9 va_sM (va_update_vec 2 va_sM (va_update_vec 8 va_sM (va_update_vec 10 va_sM
(va_update_vec 0 va_sM (va_update_ok va_sM va_s0))))))))));
va_lemma_norm_mods ([va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2;
va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Reduce (f:poly) : (va_quickCode unit (va_code_Reduce ())) =
(va_QProc (va_code_Reduce ()) ([va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9;
va_Mod_vec 2; va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0]) (va_wp_Reduce f) (va_wpProof_Reduce
f))
//--
//-- ReduceLast
[@ "opaque_to_smt" va_qattr] | false | true | Vale.AES.PPC64LE.GHash.fst | {
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_code_ReduceLast : va_dummy:unit -> Tot va_code | [] | Vale.AES.PPC64LE.GHash.va_code_ReduceLast | {
"file_name": "obj/Vale.AES.PPC64LE.GHash.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_dummy: Prims.unit -> Vale.PPC64LE.Decls.va_code | {
"end_col": 34,
"end_line": 721,
"start_col": 2,
"start_line": 720
} |
Prims.Tot | val va_code_Reduce : va_dummy:unit -> Tot va_code | [
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math // For lemma_poly_bits64()",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_code_Reduce () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 0) 0) (va_CCons (va_code_Low64ToHigh
(va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_CCons (va_code_VSwap (va_op_vec_opr_vec 10)
(va_op_vec_opr_vec 2)) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
2) (va_op_vec_opr_vec 8)) (va_CCons (va_code_High64ToLow (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 10)) (va_CCons (va_code_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2))
(va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
8)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
2)) (va_CNil ())))))))))))))) | val va_code_Reduce : va_dummy:unit -> Tot va_code
let va_code_Reduce () = | false | null | false | (va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 0) 0)
(va_CCons (va_code_Low64ToHigh (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3))
(va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 9))
(va_CCons (va_code_VSwap (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 2))
(va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 8))
(va_CCons (va_code_High64ToLow (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3))
(va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 3))
(va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 10))
(va_CCons (va_code_VSwap (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 2))
(va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 8))
(va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 4))
(va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 2))
(va_CNil ())))))))))))))) | {
"checked_file": "Vale.AES.PPC64LE.GHash.fst.checked",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.GCTR_BE.fsti.checked",
"Vale.AES.GCM_helpers_BE.fsti.checked",
"Vale.AES.AES_helpers.fsti.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GHash.fst"
} | [
"total"
] | [
"Prims.unit",
"Vale.PPC64LE.Decls.va_Block",
"Vale.PPC64LE.Decls.va_CCons",
"Vale.PPC64LE.InsVector.va_code_Vspltisw",
"Vale.PPC64LE.Decls.va_op_vec_opr_vec",
"Vale.AES.PPC64LE.GF128_Mul.va_code_Low64ToHigh",
"Vale.AES.PPC64LE.PolyOps.va_code_VPolyAdd",
"Vale.AES.PPC64LE.PolyOps.va_code_VSwap",
"Vale.AES.PPC64LE.PolyOps.va_code_VPolyMulLow",
"Vale.AES.PPC64LE.GF128_Mul.va_code_High64ToLow",
"Vale.PPC64LE.Decls.va_CNil",
"Vale.PPC64LE.Decls.va_code"
] | [] | module Vale.AES.PPC64LE.GHash
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.AES_helpers
open Vale.Poly1305.Math // For lemma_poly_bits64()
open Vale.AES.GCM_helpers_BE
open Vale.AES.GCTR_BE_s
open Vale.AES.GCTR_BE
open Vale.Arch.TypesNative
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
#reset-options "--z3rlimit 50"
//-- MulAdd_unroll_1way
val va_code_MulAdd_unroll_1way : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_MulAdd_unroll_1way () =
(va_Block (va_CCons (va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_CCons (va_code_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_CCons
(va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5))
(va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
6)) (va_CNil ())))))))
val va_codegen_success_MulAdd_unroll_1way : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_MulAdd_unroll_1way () =
(va_pbool_and (va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_pbool_and
(va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
7)) (va_pbool_and (va_codegen_success_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (va_ttrue ()))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_MulAdd_unroll_1way (va_mods:va_mods_t) (in_b:buffer128) (index:nat) (h:poly)
(prev:poly) (data:(seq quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_1way ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (pdata:(Prims.int
-> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in let
(data_i:poly) = pdata 0 in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 136 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret in_b index) (fun (va_s:va_state) _ -> let
(va_arg44:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 138 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg44 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 139 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg43:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 140 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg43) (let
(va_arg42:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 141 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg42 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 142 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 143 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg41:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg40:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 144 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg40 va_arg41) (let
(va_arg39:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 145 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg39 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 146 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg38:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg37:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 147 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg37 va_arg38) (let
(va_arg36:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 148 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg36 64) (let
(va_arg35:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 149 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg35 64) (let
(va_arg34:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 150 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg34) (let
(va_arg33:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 151 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg33 64) (let
(va_arg32:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 152 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg32 64) (let
(va_arg31:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg30:Vale.Math.Poly2_s.poly) = add prev data_i in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 153 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg30 va_arg31) (va_QEmpty
(()))))))))))))))))))))
val va_lemma_MulAdd_unroll_1way : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 -> index:nat ->
h:poly -> prev:poly -> data:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_MulAdd_unroll_1way ()) va_s0 /\ va_get_ok va_s0 /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 1 /\
in_b_blocks in_b index 1 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0) /\ va_state_eq va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_ok va_sM va_s0)))))))
[@"opaque_to_smt"]
let va_lemma_MulAdd_unroll_1way va_b0 va_s0 in_b index h prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_MulAdd_unroll_1way va_mods in_b index h prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_MulAdd_unroll_1way ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 106 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in label va_range1
"***** POSTCONDITION NOT MET AT line 133 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_ok]) va_sM
va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_MulAdd_unroll_1way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq quad32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 1 /\
in_b_blocks in_b index 1 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64)) /\ (forall
(va_x_v0:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) . let va_sM = va_upd_vec 4
va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 va_s0))) in va_get_ok
va_sM /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0) ==> va_k va_sM (())))
val va_wpProof_MulAdd_unroll_1way : in_b:buffer128 -> index:nat -> h:poly -> prev:poly -> data:(seq
quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_MulAdd_unroll_1way in_b index h prev data va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_MulAdd_unroll_1way ()) ([va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_MulAdd_unroll_1way in_b index h prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_MulAdd_unroll_1way (va_code_MulAdd_unroll_1way ()) va_s0 in_b index
h prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 0 va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_MulAdd_unroll_1way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq
quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_1way ())) =
(va_QProc (va_code_MulAdd_unroll_1way ()) ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec
0]) (va_wp_MulAdd_unroll_1way in_b index h prev data) (va_wpProof_MulAdd_unroll_1way in_b index
h prev data))
//--
//-- MulAdd_unroll_2way
val va_code_MulAdd_unroll_2way : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_MulAdd_unroll_2way () =
(va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_CCons
(va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret) (va_CCons (va_code_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg
10) Secret) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 7)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 5)) (va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
8) (va_op_vec_opr_vec 6)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 0)) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec
10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (va_CCons (va_code_VPolyMulHigh
(va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 13)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 11)) (va_CNil
())))))))))))))))
val va_codegen_success_MulAdd_unroll_2way : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_MulAdd_unroll_2way () =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret) (va_pbool_and (va_codegen_success_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg
10) Secret) (va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 8) (va_op_vec_opr_vec 7)) (va_pbool_and (va_codegen_success_VPolyMul
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec
6)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 0)) (va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14)) (va_pbool_and (va_codegen_success_VPolyMul
(va_op_vec_opr_vec 10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (va_pbool_and
(va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 13)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_pbool_and
(va_codegen_success_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
11)) (va_ttrue ()))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_MulAdd_unroll_2way (va_mods:va_mods_t) (in_b:buffer128) (index:nat) (h:poly)
(prev:poly) (data:(seq quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_2way ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (pdata:(Prims.int
-> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in let
(data_0:poly) = pdata 0 in let (data_1:poly) = pdata 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 196 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 197 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret in_b index) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 198 column 32 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 10) Secret in_b (index + 1)) (fun (va_s:va_state) _ ->
let (va_arg95:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 200 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg95 1) (let
(va_arg94:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 201 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg94) (let
(va_arg93:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 202 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg93 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 203 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 204 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg92:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg91:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 205 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg91 va_arg92) (let
(va_arg90:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 206 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg90 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 207 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg89:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg88:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 208 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg88 va_arg89) (let
(va_arg87:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 209 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg87 64) (let
(va_arg86:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 210 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg86 64) (let
(va_arg85:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 211 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg85) (let
(va_arg84:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 212 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg84 64) (let
(va_arg83:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 213 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg83 64) (let
(va_arg82:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg81:Vale.Math.Poly2_s.poly) = data_1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 214 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg81 va_arg82) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 215 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 0) (let (va_arg80:Vale.Math.Poly2_s.poly)
= h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 218 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg80 2) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 219 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg79:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 220 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg79) (let
(va_arg78:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 221 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg78 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 222 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 223 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (fun
(va_s:va_state) _ -> let (va_arg77:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg76:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
2) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 224 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg76 va_arg77) (let
(va_arg75:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 225 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg75 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 226 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 13))
(fun (va_s:va_state) _ -> let (va_arg74:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64
in let (va_arg73:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 227 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg73 va_arg74) (let
(va_arg72:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 228 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg72 64) (let
(va_arg71:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 229 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg71 64) (let
(va_arg70:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 230 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg70) (let
(va_arg69:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 231 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg69 64) (let
(va_arg68:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 232 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg68 64) (let
(va_arg67:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift (add prev
data_0) (-64)) (Vale.Math.Poly2.mask (Vale.AES.GHash_BE.gf128_power h 2) 64) in let
(va_arg66:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask (add prev
data_0) 64) (Vale.Math.Poly2_s.shift (Vale.AES.GHash_BE.gf128_power h 2) (-64)) in let
(va_arg65:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec 3 va_s) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 233 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_add_associate va_arg65 va_arg66 va_arg67) (let
(va_arg64:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in let
(va_arg63:Vale.Math.Poly2_s.poly) = add prev data_0 in let (va_arg62:Vale.Math.Poly2_s.poly) =
of_quad32 (va_get_vec 4 va_s) in let (va_arg61:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec
3 va_s) in let (va_arg60:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec 2 va_s) in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 236 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128_accum va_arg60 va_arg61 va_arg62 va_arg63
va_arg64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 237 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 238 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 239 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 11))
(va_QEmpty (()))))))))))))))))))))))))))))))))))))))))))
val va_lemma_MulAdd_unroll_2way : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 -> index:nat ->
h:poly -> prev:poly -> data:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_MulAdd_unroll_2way ()) va_s0 /\ va_get_ok va_s0 /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 2 /\
in_b_blocks in_b index 2 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1) /\ va_state_eq va_sM
(va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))))))))))
[@"opaque_to_smt"]
let va_lemma_MulAdd_unroll_2way va_b0 va_s0 in_b index h prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec
4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_MulAdd_unroll_2way va_mods in_b index h prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_MulAdd_unroll_2way ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 156 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in label va_range1
"***** POSTCONDITION NOT MET AT line 192 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_MulAdd_unroll_2way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq quad32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 2 /\
in_b_blocks in_b index 2 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64)) /\ (forall
(va_x_r10:nat64) (va_x_v0:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32)
(va_x_v8:quad32) (va_x_v9:quad32) (va_x_v10:quad32) (va_x_v11:quad32) . let va_sM = va_upd_vec
11 va_x_v11 (va_upd_vec 10 va_x_v10 (va_upd_vec 9 va_x_v9 (va_upd_vec 8 va_x_v8 (va_upd_vec 4
va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 (va_upd_reg 10
va_x_r10 va_s0)))))))) in va_get_ok va_sM /\ (let (pdata:(Prims.int ->
Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1) ==> va_k va_sM (())))
val va_wpProof_MulAdd_unroll_2way : in_b:buffer128 -> index:nat -> h:poly -> prev:poly -> data:(seq
quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_MulAdd_unroll_2way in_b index h prev data va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_MulAdd_unroll_2way ()) ([va_Mod_vec
11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 0; va_Mod_reg 10]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_MulAdd_unroll_2way in_b index h prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_MulAdd_unroll_2way (va_code_MulAdd_unroll_2way ()) va_s0 in_b index
h prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM
(va_update_vec 8 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM va_s0)))))))))));
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_MulAdd_unroll_2way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq
quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_2way ())) =
(va_QProc (va_code_MulAdd_unroll_2way ()) ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9;
va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10])
(va_wp_MulAdd_unroll_2way in_b index h prev data) (va_wpProof_MulAdd_unroll_2way in_b index h
prev data))
//--
//-- Reduce
val va_code_Reduce : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr] | false | true | Vale.AES.PPC64LE.GHash.fst | {
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_code_Reduce : va_dummy:unit -> Tot va_code | [] | Vale.AES.PPC64LE.GHash.va_code_Reduce | {
"file_name": "obj/Vale.AES.PPC64LE.GHash.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_dummy: Prims.unit -> Vale.PPC64LE.Decls.va_code | {
"end_col": 33,
"end_line": 534,
"start_col": 2,
"start_line": 523
} |
Prims.Tot | val va_codegen_success_Ghash_register : va_dummy:unit -> Tot va_pbool | [
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math // For lemma_poly_bits64()",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_codegen_success_Ghash_register () =
(va_pbool_and (va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 5) Secret) (va_pbool_and (va_codegen_success_Vspltisw
(va_op_vec_opr_vec 0) 0) (va_pbool_and (va_codegen_success_VSwap (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_High64ToLow (va_op_vec_opr_vec 7)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_Low64ToHigh (va_op_vec_opr_vec 6)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 9)) (va_pbool_and (va_codegen_success_VPolyMulLow
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 7)) (va_pbool_and
(va_codegen_success_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 8) 0)
(va_pbool_and (va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 8) 4) (va_pbool_and (va_codegen_success_ReduceLast ()) (va_ttrue
())))))))))))))))) | val va_codegen_success_Ghash_register : va_dummy:unit -> Tot va_pbool
let va_codegen_success_Ghash_register () = | false | null | false | (va_pbool_and (va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 5)
(va_op_reg_opr_reg 5)
Secret)
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 0) 0)
(va_pbool_and (va_codegen_success_VSwap (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_High64ToLow (va_op_vec_opr_vec 7)
(va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_Low64ToHigh (va_op_vec_opr_vec 6)
(va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 9))
(va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 7))
(va_pbool_and (va_codegen_success_VPolyMul (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 6))
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 8)
0)
(va_pbool_and (va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg
10)
(- 15872))
(va_pbool_and (va_codegen_success_Mtvsrws (va_op_vec_opr_vec
0)
(va_op_reg_opr_reg 10))
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec
1)
(va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 0)
4)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec
8)
(va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 8)
4)
(va_pbool_and (va_codegen_success_ReduceLast
())
(va_ttrue ())))))))))))))))) | {
"checked_file": "Vale.AES.PPC64LE.GHash.fst.checked",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.GCTR_BE.fsti.checked",
"Vale.AES.GCM_helpers_BE.fsti.checked",
"Vale.AES.AES_helpers.fsti.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GHash.fst"
} | [
"total"
] | [
"Prims.unit",
"Vale.PPC64LE.Decls.va_pbool_and",
"Vale.PPC64LE.InsVector.va_codegen_success_Load128_byte16_buffer",
"Vale.PPC64LE.Decls.va_op_heaplet_mem_heaplet",
"Vale.PPC64LE.Decls.va_op_vec_opr_vec",
"Vale.PPC64LE.Decls.va_op_reg_opr_reg",
"Vale.Arch.HeapTypes_s.Secret",
"Vale.PPC64LE.InsVector.va_codegen_success_Vspltisw",
"Vale.AES.PPC64LE.PolyOps.va_codegen_success_VSwap",
"Vale.AES.PPC64LE.GF128_Mul.va_codegen_success_High64ToLow",
"Vale.AES.PPC64LE.GF128_Mul.va_codegen_success_Low64ToHigh",
"Vale.AES.PPC64LE.PolyOps.va_codegen_success_VPolyAdd",
"Vale.AES.PPC64LE.PolyOps.va_codegen_success_VPolyMulLow",
"Vale.AES.PPC64LE.PolyOps.va_codegen_success_VPolyMul",
"Vale.AES.PPC64LE.PolyOps.va_codegen_success_VPolyMulHigh",
"Vale.PPC64LE.InsBasic.va_codegen_success_LoadImmShl64",
"Prims.op_Minus",
"Vale.PPC64LE.InsVector.va_codegen_success_Mtvsrws",
"Vale.PPC64LE.InsVector.va_codegen_success_Vsldoi",
"Vale.AES.PPC64LE.GHash.va_codegen_success_ReduceLast",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | module Vale.AES.PPC64LE.GHash
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.AES_helpers
open Vale.Poly1305.Math // For lemma_poly_bits64()
open Vale.AES.GCM_helpers_BE
open Vale.AES.GCTR_BE_s
open Vale.AES.GCTR_BE
open Vale.Arch.TypesNative
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
#reset-options "--z3rlimit 50"
//-- MulAdd_unroll_1way
val va_code_MulAdd_unroll_1way : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_MulAdd_unroll_1way () =
(va_Block (va_CCons (va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_CCons (va_code_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_CCons
(va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5))
(va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
6)) (va_CNil ())))))))
val va_codegen_success_MulAdd_unroll_1way : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_MulAdd_unroll_1way () =
(va_pbool_and (va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_pbool_and
(va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
7)) (va_pbool_and (va_codegen_success_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (va_ttrue ()))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_MulAdd_unroll_1way (va_mods:va_mods_t) (in_b:buffer128) (index:nat) (h:poly)
(prev:poly) (data:(seq quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_1way ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (pdata:(Prims.int
-> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in let
(data_i:poly) = pdata 0 in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 136 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret in_b index) (fun (va_s:va_state) _ -> let
(va_arg44:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 138 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg44 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 139 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg43:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 140 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg43) (let
(va_arg42:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 141 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg42 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 142 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 143 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg41:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg40:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 144 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg40 va_arg41) (let
(va_arg39:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 145 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg39 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 146 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg38:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg37:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 147 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg37 va_arg38) (let
(va_arg36:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 148 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg36 64) (let
(va_arg35:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 149 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg35 64) (let
(va_arg34:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 150 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg34) (let
(va_arg33:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 151 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg33 64) (let
(va_arg32:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 152 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg32 64) (let
(va_arg31:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg30:Vale.Math.Poly2_s.poly) = add prev data_i in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 153 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg30 va_arg31) (va_QEmpty
(()))))))))))))))))))))
val va_lemma_MulAdd_unroll_1way : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 -> index:nat ->
h:poly -> prev:poly -> data:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_MulAdd_unroll_1way ()) va_s0 /\ va_get_ok va_s0 /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 1 /\
in_b_blocks in_b index 1 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0) /\ va_state_eq va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_ok va_sM va_s0)))))))
[@"opaque_to_smt"]
let va_lemma_MulAdd_unroll_1way va_b0 va_s0 in_b index h prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_MulAdd_unroll_1way va_mods in_b index h prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_MulAdd_unroll_1way ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 106 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in label va_range1
"***** POSTCONDITION NOT MET AT line 133 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_ok]) va_sM
va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_MulAdd_unroll_1way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq quad32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 1 /\
in_b_blocks in_b index 1 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64)) /\ (forall
(va_x_v0:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) . let va_sM = va_upd_vec 4
va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 va_s0))) in va_get_ok
va_sM /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0) ==> va_k va_sM (())))
val va_wpProof_MulAdd_unroll_1way : in_b:buffer128 -> index:nat -> h:poly -> prev:poly -> data:(seq
quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_MulAdd_unroll_1way in_b index h prev data va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_MulAdd_unroll_1way ()) ([va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_MulAdd_unroll_1way in_b index h prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_MulAdd_unroll_1way (va_code_MulAdd_unroll_1way ()) va_s0 in_b index
h prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 0 va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_MulAdd_unroll_1way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq
quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_1way ())) =
(va_QProc (va_code_MulAdd_unroll_1way ()) ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec
0]) (va_wp_MulAdd_unroll_1way in_b index h prev data) (va_wpProof_MulAdd_unroll_1way in_b index
h prev data))
//--
//-- MulAdd_unroll_2way
val va_code_MulAdd_unroll_2way : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_MulAdd_unroll_2way () =
(va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_CCons
(va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret) (va_CCons (va_code_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg
10) Secret) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 7)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 5)) (va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
8) (va_op_vec_opr_vec 6)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 0)) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec
10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (va_CCons (va_code_VPolyMulHigh
(va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 13)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 11)) (va_CNil
())))))))))))))))
val va_codegen_success_MulAdd_unroll_2way : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_MulAdd_unroll_2way () =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret) (va_pbool_and (va_codegen_success_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg
10) Secret) (va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 8) (va_op_vec_opr_vec 7)) (va_pbool_and (va_codegen_success_VPolyMul
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec
6)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 0)) (va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14)) (va_pbool_and (va_codegen_success_VPolyMul
(va_op_vec_opr_vec 10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (va_pbool_and
(va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 13)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_pbool_and
(va_codegen_success_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
11)) (va_ttrue ()))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_MulAdd_unroll_2way (va_mods:va_mods_t) (in_b:buffer128) (index:nat) (h:poly)
(prev:poly) (data:(seq quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_2way ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (pdata:(Prims.int
-> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in let
(data_0:poly) = pdata 0 in let (data_1:poly) = pdata 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 196 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 197 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret in_b index) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 198 column 32 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 10) Secret in_b (index + 1)) (fun (va_s:va_state) _ ->
let (va_arg95:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 200 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg95 1) (let
(va_arg94:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 201 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg94) (let
(va_arg93:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 202 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg93 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 203 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 204 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg92:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg91:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 205 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg91 va_arg92) (let
(va_arg90:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 206 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg90 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 207 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg89:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg88:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 208 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg88 va_arg89) (let
(va_arg87:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 209 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg87 64) (let
(va_arg86:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 210 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg86 64) (let
(va_arg85:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 211 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg85) (let
(va_arg84:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 212 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg84 64) (let
(va_arg83:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 213 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg83 64) (let
(va_arg82:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg81:Vale.Math.Poly2_s.poly) = data_1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 214 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg81 va_arg82) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 215 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 0) (let (va_arg80:Vale.Math.Poly2_s.poly)
= h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 218 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg80 2) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 219 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg79:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 220 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg79) (let
(va_arg78:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 221 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg78 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 222 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 223 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (fun
(va_s:va_state) _ -> let (va_arg77:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg76:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
2) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 224 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg76 va_arg77) (let
(va_arg75:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 225 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg75 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 226 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 13))
(fun (va_s:va_state) _ -> let (va_arg74:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64
in let (va_arg73:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 227 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg73 va_arg74) (let
(va_arg72:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 228 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg72 64) (let
(va_arg71:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 229 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg71 64) (let
(va_arg70:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 230 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg70) (let
(va_arg69:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 231 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg69 64) (let
(va_arg68:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 232 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg68 64) (let
(va_arg67:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift (add prev
data_0) (-64)) (Vale.Math.Poly2.mask (Vale.AES.GHash_BE.gf128_power h 2) 64) in let
(va_arg66:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask (add prev
data_0) 64) (Vale.Math.Poly2_s.shift (Vale.AES.GHash_BE.gf128_power h 2) (-64)) in let
(va_arg65:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec 3 va_s) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 233 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_add_associate va_arg65 va_arg66 va_arg67) (let
(va_arg64:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in let
(va_arg63:Vale.Math.Poly2_s.poly) = add prev data_0 in let (va_arg62:Vale.Math.Poly2_s.poly) =
of_quad32 (va_get_vec 4 va_s) in let (va_arg61:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec
3 va_s) in let (va_arg60:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec 2 va_s) in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 236 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128_accum va_arg60 va_arg61 va_arg62 va_arg63
va_arg64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 237 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 238 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 239 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 11))
(va_QEmpty (()))))))))))))))))))))))))))))))))))))))))))
val va_lemma_MulAdd_unroll_2way : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 -> index:nat ->
h:poly -> prev:poly -> data:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_MulAdd_unroll_2way ()) va_s0 /\ va_get_ok va_s0 /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 2 /\
in_b_blocks in_b index 2 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1) /\ va_state_eq va_sM
(va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))))))))))
[@"opaque_to_smt"]
let va_lemma_MulAdd_unroll_2way va_b0 va_s0 in_b index h prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec
4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_MulAdd_unroll_2way va_mods in_b index h prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_MulAdd_unroll_2way ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 156 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in label va_range1
"***** POSTCONDITION NOT MET AT line 192 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_MulAdd_unroll_2way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq quad32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 2 /\
in_b_blocks in_b index 2 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64)) /\ (forall
(va_x_r10:nat64) (va_x_v0:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32)
(va_x_v8:quad32) (va_x_v9:quad32) (va_x_v10:quad32) (va_x_v11:quad32) . let va_sM = va_upd_vec
11 va_x_v11 (va_upd_vec 10 va_x_v10 (va_upd_vec 9 va_x_v9 (va_upd_vec 8 va_x_v8 (va_upd_vec 4
va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 (va_upd_reg 10
va_x_r10 va_s0)))))))) in va_get_ok va_sM /\ (let (pdata:(Prims.int ->
Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1) ==> va_k va_sM (())))
val va_wpProof_MulAdd_unroll_2way : in_b:buffer128 -> index:nat -> h:poly -> prev:poly -> data:(seq
quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_MulAdd_unroll_2way in_b index h prev data va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_MulAdd_unroll_2way ()) ([va_Mod_vec
11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 0; va_Mod_reg 10]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_MulAdd_unroll_2way in_b index h prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_MulAdd_unroll_2way (va_code_MulAdd_unroll_2way ()) va_s0 in_b index
h prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM
(va_update_vec 8 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM va_s0)))))))))));
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_MulAdd_unroll_2way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq
quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_2way ())) =
(va_QProc (va_code_MulAdd_unroll_2way ()) ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9;
va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10])
(va_wp_MulAdd_unroll_2way in_b index h prev data) (va_wpProof_MulAdd_unroll_2way in_b index h
prev data))
//--
//-- Reduce
val va_code_Reduce : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Reduce () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 0) 0) (va_CCons (va_code_Low64ToHigh
(va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_CCons (va_code_VSwap (va_op_vec_opr_vec 10)
(va_op_vec_opr_vec 2)) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
2) (va_op_vec_opr_vec 8)) (va_CCons (va_code_High64ToLow (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 10)) (va_CCons (va_code_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2))
(va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
8)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
2)) (va_CNil ()))))))))))))))
val va_codegen_success_Reduce : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Reduce () =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 0) 0) (va_pbool_and
(va_codegen_success_Low64ToHigh (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9))
(va_pbool_and (va_codegen_success_VSwap (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 2))
(va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 8)) (va_pbool_and (va_codegen_success_High64ToLow (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 3)) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 10)) (va_pbool_and
(va_codegen_success_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_pbool_and
(va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
8)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_ttrue ())))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Reduce (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_Reduce ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in let
(c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in
let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 265 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 0) 0) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 266 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod a1 64) (let
(va_arg39:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.mask a1 64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 267 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_is_mul va_arg39 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 268 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Low64ToHigh (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3) a1) (fun (va_s:va_state) _ ->
let (va_arg38:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift (Vale.Math.Poly2.mask a1 64) 64
in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 269 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32 va_arg38) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 270 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 271 column 10 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VSwap (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 2)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 272 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 273 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div a1 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 274 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_High64ToLow (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) a1) (fun (va_s:va_state) _ ->
let (va_arg37:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift a1 (-64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 275 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32 va_arg37) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 276 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 3)) (fun
(va_s:va_state) _ -> let (va_arg36:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 10 va_s) in let (va_arg35:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 277 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_add_commute va_arg35 va_arg36) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 278 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 10)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 279 column 10 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 280 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 281 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 4)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 282 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (fun
(va_s:va_state) _ -> let (va_arg34:Vale.Math.Poly2_s.poly) = f in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 283 column 21 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_reduce_rev a0 a1 a2 va_arg34 64) (va_QEmpty
(()))))))))))))))))))))))
val va_lemma_Reduce : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Reduce ()) va_s0 /\ va_get_ok va_s0 /\ (let
(g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in let
(c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in
let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) (-64) == zero /\ Vale.Math.Poly2.mask (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) 64 == c /\ Vale.Math.Poly2_s.degree f < 64 /\ Vale.Math.Poly2_s.degree g
== 128 /\ Vale.Math.Poly2_s.poly_index f 0)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in let
(c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in
let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) ==
Vale.Math.Poly2_s.reverse (mod (Vale.Math.Poly2_s.reverse a 255) g) 127) /\ va_state_eq va_sM
(va_update_vec 1 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 9 va_sM
(va_update_vec 2 va_sM (va_update_vec 8 va_sM (va_update_vec 10 va_sM (va_update_vec 0 va_sM
(va_update_ok va_sM va_s0)))))))))))
[@"opaque_to_smt"]
let va_lemma_Reduce va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2;
va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_Reduce va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Reduce ()) va_qc va_s0 (fun va_s0 va_sM
va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 242 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f
in let (c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1))
63 in let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0)
in let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in label va_range1
"***** POSTCONDITION NOT MET AT line 263 column 60 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.Math.Poly2_s.reverse (mod
(Vale.Math.Poly2_s.reverse a 255) g) 127))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2;
va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Reduce (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in
let (c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63
in let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in
let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) (-64) == zero /\ Vale.Math.Poly2.mask (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) 64 == c /\ Vale.Math.Poly2_s.degree f < 64 /\ Vale.Math.Poly2_s.degree g
== 128 /\ Vale.Math.Poly2_s.poly_index f 0) /\ (forall (va_x_v0:quad32) (va_x_v10:quad32)
(va_x_v8:quad32) (va_x_v2:quad32) (va_x_v9:quad32) (va_x_v3:quad32) (va_x_v4:quad32)
(va_x_v1:quad32) . let va_sM = va_upd_vec 1 va_x_v1 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3
(va_upd_vec 9 va_x_v9 (va_upd_vec 2 va_x_v2 (va_upd_vec 8 va_x_v8 (va_upd_vec 10 va_x_v10
(va_upd_vec 0 va_x_v0 va_s0))))))) in va_get_ok va_sM /\ (let (g:Vale.Math.Poly2_s.poly) = add
(Vale.Math.Poly2_s.monomial 128) f in let (c:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in let
(a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) ==
Vale.Math.Poly2_s.reverse (mod (Vale.Math.Poly2_s.reverse a 255) g) 127) ==> va_k va_sM (())))
val va_wpProof_Reduce : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Reduce f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Reduce ()) ([va_Mod_vec 1; va_Mod_vec
4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2; va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0]) va_s0
va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Reduce f va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Reduce (va_code_Reduce ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 1 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 9 va_sM (va_update_vec 2 va_sM (va_update_vec 8 va_sM (va_update_vec 10 va_sM
(va_update_vec 0 va_sM (va_update_ok va_sM va_s0))))))))));
va_lemma_norm_mods ([va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2;
va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Reduce (f:poly) : (va_quickCode unit (va_code_Reduce ())) =
(va_QProc (va_code_Reduce ()) ([va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9;
va_Mod_vec 2; va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0]) (va_wp_Reduce f) (va_wpProof_Reduce
f))
//--
//-- ReduceLast
[@ "opaque_to_smt" va_qattr]
let va_code_ReduceLast () =
(va_Block (va_CCons (va_code_Reduce ()) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_Block
(va_CNil ())) (va_CNil ())))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ReduceLast () =
(va_pbool_and (va_codegen_success_Reduce ()) (va_ttrue ()))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ReduceLast (va_mods:va_mods_t) (h_BE:quad32) (y_prev:quad32) (data:(seq quad32)) :
(va_quickCode unit (va_code_ReduceLast ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in let
(prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in let (n:Prims.nat) = FStar.Seq.Base.length #quad32 data in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 311 column 35 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_constant_shift_rev ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 312 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_degree ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 313 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Reduce gf128_modulus_low_terms) (fun (va_s:va_state) _ -> va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 314 column 36 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(n - 1 >= 0) (fun _ -> let (va_arg25:Prims.nat) = n - 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 314 column 36 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_ghash_unroll_back_forward h prev pdata 0 va_arg25)
(va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 315 column 31 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(n - 1 >= 0) (fun _ -> let (va_arg24:Prims.nat) = n - 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 315 column 31 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_ghash_poly_of_unroll h prev pdata 0 va_arg24) (let
(va_arg23:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = data in let
(va_arg22:Vale.Def.Types_s.quad32) = y_prev in let (va_arg21:Vale.Def.Types_s.quad32) = h_BE in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 316 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_ghash_incremental_poly va_arg21 va_arg22 va_arg23)
(let (va_arg20:Vale.Def.Types_s.quad32) = Vale.AES.GHash_BE.ghash_incremental h_BE y_prev data
in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 317 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_to_of_quad32 va_arg20) (va_QEmpty (()))))))))))))
[@"opaque_to_smt"]
let va_lemma_ReduceLast va_b0 va_s0 h_BE y_prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_ReduceLast va_mods h_BE y_prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ReduceLast ()) va_qc va_s0 (fun va_s0
va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 286 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in
let (prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in let (n:Prims.nat) = FStar.Seq.Base.length #quad32 data in label va_range1
"***** POSTCONDITION NOT MET AT line 307 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(let xi = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) in label va_range1
"***** POSTCONDITION NOT MET AT line 308 column 63 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.Math.Poly2.Bits_s.to_quad32 xi == Vale.AES.GHash_BE.ghash_incremental h_BE y_prev data)
/\ label va_range1
"***** POSTCONDITION NOT MET AT line 309 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(xi == Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Math.Poly2.Bits_s.to_quad32 xi))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_ReduceLast h_BE y_prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ReduceLast (va_code_ReduceLast ()) va_s0 h_BE y_prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_vec 0 va_sM (va_update_ok va_sM va_s0))))))))));
va_lemma_norm_mods ([va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- GhashUnroll_n
[@ "opaque_to_smt" va_qattr]
let va_code_GhashUnroll_n exactly2 =
(va_Block (va_CCons (if exactly2 then va_Block (va_CCons (va_code_MulAdd_unroll_2way ()) (va_CNil
())) else va_Block (va_CCons (va_code_MulAdd_unroll_1way ()) (va_CNil ()))) (va_CCons
(va_code_Vspltisw (va_op_vec_opr_vec 8) 0) (va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg
10) (-15872)) (va_CCons (va_code_Mtvsrws (va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10))
(va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4)
(va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) 4)
(va_CCons (va_code_ReduceLast ()) (va_CNil ())))))))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_GhashUnroll_n exactly2 =
(va_pbool_and (if exactly2 then va_pbool_and (va_codegen_success_MulAdd_unroll_2way ()) (va_ttrue
()) else va_pbool_and (va_codegen_success_MulAdd_unroll_1way ()) (va_ttrue ())) (va_pbool_and
(va_codegen_success_Vspltisw (va_op_vec_opr_vec 8) 0) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 8) 4) (va_pbool_and (va_codegen_success_ReduceLast ()) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_GhashUnroll_n (va_mods:va_mods_t) (exactly2:bool) (in_b:buffer128) (index:nat)
(h_BE:quad32) (y_prev:quad32) (data:(seq quad32)) : (va_quickCode unit (va_code_GhashUnroll_n
exactly2)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in let
(prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in let (n:Prims.nat) = FStar.Seq.Base.length #quad32 data in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 361 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_qInlineIf va_mods exactly2 (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 363 column 27 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_MulAdd_unroll_2way in_b index h prev data) (va_QEmpty (())))) (qblock va_mods (fun
(va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 367 column 27 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_MulAdd_unroll_1way in_b index h prev data) (va_QEmpty (()))))) (fun (va_s:va_state)
va_g -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 369 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 8) 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 370 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (fun (va_s:va_state) _ -> let
(va_arg27:Vale.Def.Types_s.nat64) = (-15872) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 371 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg27 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 372 column 12 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 373 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 374 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) 4) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 375 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_ReduceLast h_BE y_prev data) (va_QEmpty (())))))))))))
[@"opaque_to_smt"]
let va_lemma_GhashUnroll_n va_b0 va_s0 exactly2 in_b index h_BE y_prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec
4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_GhashUnroll_n va_mods exactly2 in_b index h_BE y_prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_GhashUnroll_n exactly2) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 320 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in
let (prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in let (n:Prims.nat) = FStar.Seq.Base.length #quad32 data in label va_range1
"***** POSTCONDITION NOT MET AT line 359 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.GHash_BE.ghash_incremental h_BE y_prev data))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_GhashUnroll_n exactly2 in_b index h_BE y_prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_GhashUnroll_n (va_code_GhashUnroll_n exactly2) va_s0 exactly2 in_b
index h_BE y_prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM
(va_update_vec 8 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0))))))))))));
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Ghash_register
[@ "opaque_to_smt" va_qattr]
let va_code_Ghash_register () =
(va_Block (va_CCons (va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 5) Secret) (va_CCons (va_code_Vspltisw
(va_op_vec_opr_vec 0) 0) (va_CCons (va_code_VSwap (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5))
(va_CCons (va_code_High64ToLow (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 5)) (va_CCons
(va_code_Low64ToHigh (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 5)) (va_CCons (va_Block (va_CNil
())) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
9)) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 7)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 5)) (va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
9) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 8) 0) (va_CCons
(va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_CCons (va_code_Mtvsrws
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10)) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) 4) (va_CCons (va_code_ReduceLast ()) (va_CNil
()))))))))))))))))))
[@ "opaque_to_smt" va_qattr] | false | true | Vale.AES.PPC64LE.GHash.fst | {
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_codegen_success_Ghash_register : va_dummy:unit -> Tot va_pbool | [] | Vale.AES.PPC64LE.GHash.va_codegen_success_Ghash_register | {
"file_name": "obj/Vale.AES.PPC64LE.GHash.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_dummy: Prims.unit -> Vale.PPC64LE.Decls.va_pbool | {
"end_col": 22,
"end_line": 929,
"start_col": 2,
"start_line": 913
} |
Prims.Tot | val va_code_GhashUnroll_n : exactly2:bool -> Tot va_code | [
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math // For lemma_poly_bits64()",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_code_GhashUnroll_n exactly2 =
(va_Block (va_CCons (if exactly2 then va_Block (va_CCons (va_code_MulAdd_unroll_2way ()) (va_CNil
())) else va_Block (va_CCons (va_code_MulAdd_unroll_1way ()) (va_CNil ()))) (va_CCons
(va_code_Vspltisw (va_op_vec_opr_vec 8) 0) (va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg
10) (-15872)) (va_CCons (va_code_Mtvsrws (va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10))
(va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4)
(va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) 4)
(va_CCons (va_code_ReduceLast ()) (va_CNil ()))))))))) | val va_code_GhashUnroll_n : exactly2:bool -> Tot va_code
let va_code_GhashUnroll_n exactly2 = | false | null | false | (va_Block (va_CCons (if exactly2
then va_Block (va_CCons (va_code_MulAdd_unroll_2way ()) (va_CNil ()))
else va_Block (va_CCons (va_code_MulAdd_unroll_1way ()) (va_CNil ())))
(va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 8) 0)
(va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (- 15872))
(va_CCons (va_code_Mtvsrws (va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10))
(va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 0)
4)
(va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 8)
4)
(va_CCons (va_code_ReduceLast ()) (va_CNil ()))))))))) | {
"checked_file": "Vale.AES.PPC64LE.GHash.fst.checked",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.GCTR_BE.fsti.checked",
"Vale.AES.GCM_helpers_BE.fsti.checked",
"Vale.AES.AES_helpers.fsti.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GHash.fst"
} | [
"total"
] | [
"Prims.bool",
"Vale.PPC64LE.Decls.va_Block",
"Vale.PPC64LE.Decls.va_CCons",
"Vale.AES.PPC64LE.GHash.va_code_MulAdd_unroll_2way",
"Vale.PPC64LE.Decls.va_CNil",
"Vale.AES.PPC64LE.GHash.va_code_MulAdd_unroll_1way",
"Vale.PPC64LE.Decls.va_code",
"Vale.PPC64LE.InsVector.va_code_Vspltisw",
"Vale.PPC64LE.Decls.va_op_vec_opr_vec",
"Vale.PPC64LE.InsBasic.va_code_LoadImmShl64",
"Vale.PPC64LE.Decls.va_op_reg_opr_reg",
"Prims.op_Minus",
"Vale.PPC64LE.InsVector.va_code_Mtvsrws",
"Vale.PPC64LE.InsVector.va_code_Vsldoi",
"Vale.AES.PPC64LE.GHash.va_code_ReduceLast"
] | [] | module Vale.AES.PPC64LE.GHash
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.AES_helpers
open Vale.Poly1305.Math // For lemma_poly_bits64()
open Vale.AES.GCM_helpers_BE
open Vale.AES.GCTR_BE_s
open Vale.AES.GCTR_BE
open Vale.Arch.TypesNative
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
#reset-options "--z3rlimit 50"
//-- MulAdd_unroll_1way
val va_code_MulAdd_unroll_1way : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_MulAdd_unroll_1way () =
(va_Block (va_CCons (va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_CCons (va_code_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_CCons
(va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5))
(va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
6)) (va_CNil ())))))))
val va_codegen_success_MulAdd_unroll_1way : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_MulAdd_unroll_1way () =
(va_pbool_and (va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_pbool_and
(va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
7)) (va_pbool_and (va_codegen_success_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (va_ttrue ()))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_MulAdd_unroll_1way (va_mods:va_mods_t) (in_b:buffer128) (index:nat) (h:poly)
(prev:poly) (data:(seq quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_1way ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (pdata:(Prims.int
-> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in let
(data_i:poly) = pdata 0 in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 136 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret in_b index) (fun (va_s:va_state) _ -> let
(va_arg44:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 138 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg44 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 139 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg43:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 140 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg43) (let
(va_arg42:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 141 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg42 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 142 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 143 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg41:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg40:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 144 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg40 va_arg41) (let
(va_arg39:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 145 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg39 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 146 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg38:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg37:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 147 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg37 va_arg38) (let
(va_arg36:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 148 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg36 64) (let
(va_arg35:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 149 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg35 64) (let
(va_arg34:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 150 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg34) (let
(va_arg33:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 151 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg33 64) (let
(va_arg32:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 152 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg32 64) (let
(va_arg31:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg30:Vale.Math.Poly2_s.poly) = add prev data_i in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 153 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg30 va_arg31) (va_QEmpty
(()))))))))))))))))))))
val va_lemma_MulAdd_unroll_1way : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 -> index:nat ->
h:poly -> prev:poly -> data:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_MulAdd_unroll_1way ()) va_s0 /\ va_get_ok va_s0 /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 1 /\
in_b_blocks in_b index 1 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0) /\ va_state_eq va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_ok va_sM va_s0)))))))
[@"opaque_to_smt"]
let va_lemma_MulAdd_unroll_1way va_b0 va_s0 in_b index h prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_MulAdd_unroll_1way va_mods in_b index h prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_MulAdd_unroll_1way ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 106 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in label va_range1
"***** POSTCONDITION NOT MET AT line 133 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_ok]) va_sM
va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_MulAdd_unroll_1way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq quad32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 1 /\
in_b_blocks in_b index 1 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64)) /\ (forall
(va_x_v0:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) . let va_sM = va_upd_vec 4
va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 va_s0))) in va_get_ok
va_sM /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0) ==> va_k va_sM (())))
val va_wpProof_MulAdd_unroll_1way : in_b:buffer128 -> index:nat -> h:poly -> prev:poly -> data:(seq
quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_MulAdd_unroll_1way in_b index h prev data va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_MulAdd_unroll_1way ()) ([va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_MulAdd_unroll_1way in_b index h prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_MulAdd_unroll_1way (va_code_MulAdd_unroll_1way ()) va_s0 in_b index
h prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 0 va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_MulAdd_unroll_1way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq
quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_1way ())) =
(va_QProc (va_code_MulAdd_unroll_1way ()) ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec
0]) (va_wp_MulAdd_unroll_1way in_b index h prev data) (va_wpProof_MulAdd_unroll_1way in_b index
h prev data))
//--
//-- MulAdd_unroll_2way
val va_code_MulAdd_unroll_2way : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_MulAdd_unroll_2way () =
(va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_CCons
(va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret) (va_CCons (va_code_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg
10) Secret) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 7)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 5)) (va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
8) (va_op_vec_opr_vec 6)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 0)) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec
10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (va_CCons (va_code_VPolyMulHigh
(va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 13)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 11)) (va_CNil
())))))))))))))))
val va_codegen_success_MulAdd_unroll_2way : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_MulAdd_unroll_2way () =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret) (va_pbool_and (va_codegen_success_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg
10) Secret) (va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 8) (va_op_vec_opr_vec 7)) (va_pbool_and (va_codegen_success_VPolyMul
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec
6)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 0)) (va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14)) (va_pbool_and (va_codegen_success_VPolyMul
(va_op_vec_opr_vec 10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (va_pbool_and
(va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 13)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_pbool_and
(va_codegen_success_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
11)) (va_ttrue ()))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_MulAdd_unroll_2way (va_mods:va_mods_t) (in_b:buffer128) (index:nat) (h:poly)
(prev:poly) (data:(seq quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_2way ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (pdata:(Prims.int
-> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in let
(data_0:poly) = pdata 0 in let (data_1:poly) = pdata 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 196 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 197 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret in_b index) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 198 column 32 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 10) Secret in_b (index + 1)) (fun (va_s:va_state) _ ->
let (va_arg95:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 200 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg95 1) (let
(va_arg94:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 201 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg94) (let
(va_arg93:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 202 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg93 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 203 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 204 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg92:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg91:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 205 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg91 va_arg92) (let
(va_arg90:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 206 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg90 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 207 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg89:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg88:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 208 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg88 va_arg89) (let
(va_arg87:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 209 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg87 64) (let
(va_arg86:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 210 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg86 64) (let
(va_arg85:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 211 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg85) (let
(va_arg84:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 212 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg84 64) (let
(va_arg83:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 213 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg83 64) (let
(va_arg82:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg81:Vale.Math.Poly2_s.poly) = data_1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 214 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg81 va_arg82) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 215 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 0) (let (va_arg80:Vale.Math.Poly2_s.poly)
= h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 218 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg80 2) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 219 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg79:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 220 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg79) (let
(va_arg78:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 221 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg78 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 222 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 223 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (fun
(va_s:va_state) _ -> let (va_arg77:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg76:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
2) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 224 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg76 va_arg77) (let
(va_arg75:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 225 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg75 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 226 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 13))
(fun (va_s:va_state) _ -> let (va_arg74:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64
in let (va_arg73:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 227 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg73 va_arg74) (let
(va_arg72:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 228 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg72 64) (let
(va_arg71:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 229 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg71 64) (let
(va_arg70:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 230 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg70) (let
(va_arg69:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 231 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg69 64) (let
(va_arg68:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 232 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg68 64) (let
(va_arg67:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift (add prev
data_0) (-64)) (Vale.Math.Poly2.mask (Vale.AES.GHash_BE.gf128_power h 2) 64) in let
(va_arg66:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask (add prev
data_0) 64) (Vale.Math.Poly2_s.shift (Vale.AES.GHash_BE.gf128_power h 2) (-64)) in let
(va_arg65:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec 3 va_s) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 233 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_add_associate va_arg65 va_arg66 va_arg67) (let
(va_arg64:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in let
(va_arg63:Vale.Math.Poly2_s.poly) = add prev data_0 in let (va_arg62:Vale.Math.Poly2_s.poly) =
of_quad32 (va_get_vec 4 va_s) in let (va_arg61:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec
3 va_s) in let (va_arg60:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec 2 va_s) in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 236 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128_accum va_arg60 va_arg61 va_arg62 va_arg63
va_arg64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 237 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 238 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 239 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 11))
(va_QEmpty (()))))))))))))))))))))))))))))))))))))))))))
val va_lemma_MulAdd_unroll_2way : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 -> index:nat ->
h:poly -> prev:poly -> data:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_MulAdd_unroll_2way ()) va_s0 /\ va_get_ok va_s0 /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 2 /\
in_b_blocks in_b index 2 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1) /\ va_state_eq va_sM
(va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))))))))))
[@"opaque_to_smt"]
let va_lemma_MulAdd_unroll_2way va_b0 va_s0 in_b index h prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec
4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_MulAdd_unroll_2way va_mods in_b index h prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_MulAdd_unroll_2way ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 156 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in label va_range1
"***** POSTCONDITION NOT MET AT line 192 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_MulAdd_unroll_2way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq quad32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 2 /\
in_b_blocks in_b index 2 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64)) /\ (forall
(va_x_r10:nat64) (va_x_v0:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32)
(va_x_v8:quad32) (va_x_v9:quad32) (va_x_v10:quad32) (va_x_v11:quad32) . let va_sM = va_upd_vec
11 va_x_v11 (va_upd_vec 10 va_x_v10 (va_upd_vec 9 va_x_v9 (va_upd_vec 8 va_x_v8 (va_upd_vec 4
va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 (va_upd_reg 10
va_x_r10 va_s0)))))))) in va_get_ok va_sM /\ (let (pdata:(Prims.int ->
Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1) ==> va_k va_sM (())))
val va_wpProof_MulAdd_unroll_2way : in_b:buffer128 -> index:nat -> h:poly -> prev:poly -> data:(seq
quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_MulAdd_unroll_2way in_b index h prev data va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_MulAdd_unroll_2way ()) ([va_Mod_vec
11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 0; va_Mod_reg 10]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_MulAdd_unroll_2way in_b index h prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_MulAdd_unroll_2way (va_code_MulAdd_unroll_2way ()) va_s0 in_b index
h prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM
(va_update_vec 8 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM va_s0)))))))))));
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_MulAdd_unroll_2way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq
quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_2way ())) =
(va_QProc (va_code_MulAdd_unroll_2way ()) ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9;
va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10])
(va_wp_MulAdd_unroll_2way in_b index h prev data) (va_wpProof_MulAdd_unroll_2way in_b index h
prev data))
//--
//-- Reduce
val va_code_Reduce : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Reduce () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 0) 0) (va_CCons (va_code_Low64ToHigh
(va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_CCons (va_code_VSwap (va_op_vec_opr_vec 10)
(va_op_vec_opr_vec 2)) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
2) (va_op_vec_opr_vec 8)) (va_CCons (va_code_High64ToLow (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 10)) (va_CCons (va_code_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2))
(va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
8)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
2)) (va_CNil ()))))))))))))))
val va_codegen_success_Reduce : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Reduce () =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 0) 0) (va_pbool_and
(va_codegen_success_Low64ToHigh (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9))
(va_pbool_and (va_codegen_success_VSwap (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 2))
(va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 8)) (va_pbool_and (va_codegen_success_High64ToLow (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 3)) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 10)) (va_pbool_and
(va_codegen_success_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_pbool_and
(va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
8)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_ttrue ())))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Reduce (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_Reduce ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in let
(c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in
let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 265 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 0) 0) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 266 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod a1 64) (let
(va_arg39:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.mask a1 64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 267 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_is_mul va_arg39 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 268 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Low64ToHigh (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3) a1) (fun (va_s:va_state) _ ->
let (va_arg38:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift (Vale.Math.Poly2.mask a1 64) 64
in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 269 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32 va_arg38) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 270 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 271 column 10 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VSwap (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 2)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 272 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 273 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div a1 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 274 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_High64ToLow (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) a1) (fun (va_s:va_state) _ ->
let (va_arg37:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift a1 (-64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 275 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32 va_arg37) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 276 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 3)) (fun
(va_s:va_state) _ -> let (va_arg36:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 10 va_s) in let (va_arg35:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 277 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_add_commute va_arg35 va_arg36) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 278 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 10)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 279 column 10 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 280 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 281 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 4)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 282 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (fun
(va_s:va_state) _ -> let (va_arg34:Vale.Math.Poly2_s.poly) = f in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 283 column 21 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_reduce_rev a0 a1 a2 va_arg34 64) (va_QEmpty
(()))))))))))))))))))))))
val va_lemma_Reduce : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Reduce ()) va_s0 /\ va_get_ok va_s0 /\ (let
(g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in let
(c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in
let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) (-64) == zero /\ Vale.Math.Poly2.mask (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) 64 == c /\ Vale.Math.Poly2_s.degree f < 64 /\ Vale.Math.Poly2_s.degree g
== 128 /\ Vale.Math.Poly2_s.poly_index f 0)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in let
(c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in
let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) ==
Vale.Math.Poly2_s.reverse (mod (Vale.Math.Poly2_s.reverse a 255) g) 127) /\ va_state_eq va_sM
(va_update_vec 1 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 9 va_sM
(va_update_vec 2 va_sM (va_update_vec 8 va_sM (va_update_vec 10 va_sM (va_update_vec 0 va_sM
(va_update_ok va_sM va_s0)))))))))))
[@"opaque_to_smt"]
let va_lemma_Reduce va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2;
va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_Reduce va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Reduce ()) va_qc va_s0 (fun va_s0 va_sM
va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 242 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f
in let (c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1))
63 in let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0)
in let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in label va_range1
"***** POSTCONDITION NOT MET AT line 263 column 60 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.Math.Poly2_s.reverse (mod
(Vale.Math.Poly2_s.reverse a 255) g) 127))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2;
va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Reduce (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in
let (c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63
in let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in
let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) (-64) == zero /\ Vale.Math.Poly2.mask (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) 64 == c /\ Vale.Math.Poly2_s.degree f < 64 /\ Vale.Math.Poly2_s.degree g
== 128 /\ Vale.Math.Poly2_s.poly_index f 0) /\ (forall (va_x_v0:quad32) (va_x_v10:quad32)
(va_x_v8:quad32) (va_x_v2:quad32) (va_x_v9:quad32) (va_x_v3:quad32) (va_x_v4:quad32)
(va_x_v1:quad32) . let va_sM = va_upd_vec 1 va_x_v1 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3
(va_upd_vec 9 va_x_v9 (va_upd_vec 2 va_x_v2 (va_upd_vec 8 va_x_v8 (va_upd_vec 10 va_x_v10
(va_upd_vec 0 va_x_v0 va_s0))))))) in va_get_ok va_sM /\ (let (g:Vale.Math.Poly2_s.poly) = add
(Vale.Math.Poly2_s.monomial 128) f in let (c:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in let
(a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) ==
Vale.Math.Poly2_s.reverse (mod (Vale.Math.Poly2_s.reverse a 255) g) 127) ==> va_k va_sM (())))
val va_wpProof_Reduce : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Reduce f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Reduce ()) ([va_Mod_vec 1; va_Mod_vec
4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2; va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0]) va_s0
va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Reduce f va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Reduce (va_code_Reduce ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 1 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 9 va_sM (va_update_vec 2 va_sM (va_update_vec 8 va_sM (va_update_vec 10 va_sM
(va_update_vec 0 va_sM (va_update_ok va_sM va_s0))))))))));
va_lemma_norm_mods ([va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2;
va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Reduce (f:poly) : (va_quickCode unit (va_code_Reduce ())) =
(va_QProc (va_code_Reduce ()) ([va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9;
va_Mod_vec 2; va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0]) (va_wp_Reduce f) (va_wpProof_Reduce
f))
//--
//-- ReduceLast
[@ "opaque_to_smt" va_qattr]
let va_code_ReduceLast () =
(va_Block (va_CCons (va_code_Reduce ()) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_Block
(va_CNil ())) (va_CNil ())))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ReduceLast () =
(va_pbool_and (va_codegen_success_Reduce ()) (va_ttrue ()))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ReduceLast (va_mods:va_mods_t) (h_BE:quad32) (y_prev:quad32) (data:(seq quad32)) :
(va_quickCode unit (va_code_ReduceLast ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in let
(prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in let (n:Prims.nat) = FStar.Seq.Base.length #quad32 data in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 311 column 35 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_constant_shift_rev ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 312 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_degree ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 313 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Reduce gf128_modulus_low_terms) (fun (va_s:va_state) _ -> va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 314 column 36 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(n - 1 >= 0) (fun _ -> let (va_arg25:Prims.nat) = n - 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 314 column 36 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_ghash_unroll_back_forward h prev pdata 0 va_arg25)
(va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 315 column 31 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(n - 1 >= 0) (fun _ -> let (va_arg24:Prims.nat) = n - 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 315 column 31 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_ghash_poly_of_unroll h prev pdata 0 va_arg24) (let
(va_arg23:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = data in let
(va_arg22:Vale.Def.Types_s.quad32) = y_prev in let (va_arg21:Vale.Def.Types_s.quad32) = h_BE in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 316 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_ghash_incremental_poly va_arg21 va_arg22 va_arg23)
(let (va_arg20:Vale.Def.Types_s.quad32) = Vale.AES.GHash_BE.ghash_incremental h_BE y_prev data
in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 317 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_to_of_quad32 va_arg20) (va_QEmpty (()))))))))))))
[@"opaque_to_smt"]
let va_lemma_ReduceLast va_b0 va_s0 h_BE y_prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_ReduceLast va_mods h_BE y_prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ReduceLast ()) va_qc va_s0 (fun va_s0
va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 286 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in
let (prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in let (n:Prims.nat) = FStar.Seq.Base.length #quad32 data in label va_range1
"***** POSTCONDITION NOT MET AT line 307 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(let xi = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) in label va_range1
"***** POSTCONDITION NOT MET AT line 308 column 63 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.Math.Poly2.Bits_s.to_quad32 xi == Vale.AES.GHash_BE.ghash_incremental h_BE y_prev data)
/\ label va_range1
"***** POSTCONDITION NOT MET AT line 309 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(xi == Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Math.Poly2.Bits_s.to_quad32 xi))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_ReduceLast h_BE y_prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ReduceLast (va_code_ReduceLast ()) va_s0 h_BE y_prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_vec 0 va_sM (va_update_ok va_sM va_s0))))))))));
va_lemma_norm_mods ([va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- GhashUnroll_n
[@ "opaque_to_smt" va_qattr] | false | true | Vale.AES.PPC64LE.GHash.fst | {
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_code_GhashUnroll_n : exactly2:bool -> Tot va_code | [] | Vale.AES.PPC64LE.GHash.va_code_GhashUnroll_n | {
"file_name": "obj/Vale.AES.PPC64LE.GHash.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | exactly2: Prims.bool -> Vale.PPC64LE.Decls.va_code | {
"end_col": 58,
"end_line": 808,
"start_col": 2,
"start_line": 802
} |
Prims.Tot | val va_codegen_success_Reduce : va_dummy:unit -> Tot va_pbool | [
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math // For lemma_poly_bits64()",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_codegen_success_Reduce () =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 0) 0) (va_pbool_and
(va_codegen_success_Low64ToHigh (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9))
(va_pbool_and (va_codegen_success_VSwap (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 2))
(va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 8)) (va_pbool_and (va_codegen_success_High64ToLow (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 3)) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 10)) (va_pbool_and
(va_codegen_success_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_pbool_and
(va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
8)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_ttrue ()))))))))))))) | val va_codegen_success_Reduce : va_dummy:unit -> Tot va_pbool
let va_codegen_success_Reduce () = | false | null | false | (va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 0) 0)
(va_pbool_and (va_codegen_success_Low64ToHigh (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3))
(va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 9))
(va_pbool_and (va_codegen_success_VSwap (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 2))
(va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 8))
(va_pbool_and (va_codegen_success_High64ToLow (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3))
(va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 3))
(va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 10))
(va_pbool_and (va_codegen_success_VSwap (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 2))
(va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec
2)
(va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 8))
(va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec
1)
(va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 4))
(va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec
1)
(va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 2))
(va_ttrue ()))))))))))))) | {
"checked_file": "Vale.AES.PPC64LE.GHash.fst.checked",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.GCTR_BE.fsti.checked",
"Vale.AES.GCM_helpers_BE.fsti.checked",
"Vale.AES.AES_helpers.fsti.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GHash.fst"
} | [
"total"
] | [
"Prims.unit",
"Vale.PPC64LE.Decls.va_pbool_and",
"Vale.PPC64LE.InsVector.va_codegen_success_Vspltisw",
"Vale.PPC64LE.Decls.va_op_vec_opr_vec",
"Vale.AES.PPC64LE.GF128_Mul.va_codegen_success_Low64ToHigh",
"Vale.AES.PPC64LE.PolyOps.va_codegen_success_VPolyAdd",
"Vale.AES.PPC64LE.PolyOps.va_codegen_success_VSwap",
"Vale.AES.PPC64LE.PolyOps.va_codegen_success_VPolyMulLow",
"Vale.AES.PPC64LE.GF128_Mul.va_codegen_success_High64ToLow",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | module Vale.AES.PPC64LE.GHash
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.AES_helpers
open Vale.Poly1305.Math // For lemma_poly_bits64()
open Vale.AES.GCM_helpers_BE
open Vale.AES.GCTR_BE_s
open Vale.AES.GCTR_BE
open Vale.Arch.TypesNative
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
#reset-options "--z3rlimit 50"
//-- MulAdd_unroll_1way
val va_code_MulAdd_unroll_1way : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_MulAdd_unroll_1way () =
(va_Block (va_CCons (va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_CCons (va_code_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_CCons
(va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5))
(va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
6)) (va_CNil ())))))))
val va_codegen_success_MulAdd_unroll_1way : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_MulAdd_unroll_1way () =
(va_pbool_and (va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_pbool_and
(va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
7)) (va_pbool_and (va_codegen_success_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (va_ttrue ()))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_MulAdd_unroll_1way (va_mods:va_mods_t) (in_b:buffer128) (index:nat) (h:poly)
(prev:poly) (data:(seq quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_1way ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (pdata:(Prims.int
-> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in let
(data_i:poly) = pdata 0 in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 136 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret in_b index) (fun (va_s:va_state) _ -> let
(va_arg44:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 138 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg44 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 139 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg43:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 140 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg43) (let
(va_arg42:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 141 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg42 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 142 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 143 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg41:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg40:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 144 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg40 va_arg41) (let
(va_arg39:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 145 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg39 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 146 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg38:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg37:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 147 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg37 va_arg38) (let
(va_arg36:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 148 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg36 64) (let
(va_arg35:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 149 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg35 64) (let
(va_arg34:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 150 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg34) (let
(va_arg33:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 151 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg33 64) (let
(va_arg32:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 152 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg32 64) (let
(va_arg31:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg30:Vale.Math.Poly2_s.poly) = add prev data_i in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 153 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg30 va_arg31) (va_QEmpty
(()))))))))))))))))))))
val va_lemma_MulAdd_unroll_1way : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 -> index:nat ->
h:poly -> prev:poly -> data:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_MulAdd_unroll_1way ()) va_s0 /\ va_get_ok va_s0 /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 1 /\
in_b_blocks in_b index 1 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0) /\ va_state_eq va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_ok va_sM va_s0)))))))
[@"opaque_to_smt"]
let va_lemma_MulAdd_unroll_1way va_b0 va_s0 in_b index h prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_MulAdd_unroll_1way va_mods in_b index h prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_MulAdd_unroll_1way ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 106 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in label va_range1
"***** POSTCONDITION NOT MET AT line 133 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_ok]) va_sM
va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_MulAdd_unroll_1way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq quad32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 1 /\
in_b_blocks in_b index 1 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64)) /\ (forall
(va_x_v0:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) . let va_sM = va_upd_vec 4
va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 va_s0))) in va_get_ok
va_sM /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0) ==> va_k va_sM (())))
val va_wpProof_MulAdd_unroll_1way : in_b:buffer128 -> index:nat -> h:poly -> prev:poly -> data:(seq
quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_MulAdd_unroll_1way in_b index h prev data va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_MulAdd_unroll_1way ()) ([va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_MulAdd_unroll_1way in_b index h prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_MulAdd_unroll_1way (va_code_MulAdd_unroll_1way ()) va_s0 in_b index
h prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 0 va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_MulAdd_unroll_1way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq
quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_1way ())) =
(va_QProc (va_code_MulAdd_unroll_1way ()) ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec
0]) (va_wp_MulAdd_unroll_1way in_b index h prev data) (va_wpProof_MulAdd_unroll_1way in_b index
h prev data))
//--
//-- MulAdd_unroll_2way
val va_code_MulAdd_unroll_2way : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_MulAdd_unroll_2way () =
(va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_CCons
(va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret) (va_CCons (va_code_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg
10) Secret) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 7)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 5)) (va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
8) (va_op_vec_opr_vec 6)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 0)) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec
10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (va_CCons (va_code_VPolyMulHigh
(va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 13)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 11)) (va_CNil
())))))))))))))))
val va_codegen_success_MulAdd_unroll_2way : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_MulAdd_unroll_2way () =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret) (va_pbool_and (va_codegen_success_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg
10) Secret) (va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 8) (va_op_vec_opr_vec 7)) (va_pbool_and (va_codegen_success_VPolyMul
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec
6)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 0)) (va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14)) (va_pbool_and (va_codegen_success_VPolyMul
(va_op_vec_opr_vec 10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (va_pbool_and
(va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 13)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_pbool_and
(va_codegen_success_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
11)) (va_ttrue ()))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_MulAdd_unroll_2way (va_mods:va_mods_t) (in_b:buffer128) (index:nat) (h:poly)
(prev:poly) (data:(seq quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_2way ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (pdata:(Prims.int
-> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in let
(data_0:poly) = pdata 0 in let (data_1:poly) = pdata 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 196 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 197 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret in_b index) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 198 column 32 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 10) Secret in_b (index + 1)) (fun (va_s:va_state) _ ->
let (va_arg95:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 200 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg95 1) (let
(va_arg94:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 201 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg94) (let
(va_arg93:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 202 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg93 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 203 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 204 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg92:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg91:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 205 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg91 va_arg92) (let
(va_arg90:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 206 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg90 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 207 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg89:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg88:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 208 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg88 va_arg89) (let
(va_arg87:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 209 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg87 64) (let
(va_arg86:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 210 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg86 64) (let
(va_arg85:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 211 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg85) (let
(va_arg84:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 212 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg84 64) (let
(va_arg83:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 213 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg83 64) (let
(va_arg82:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg81:Vale.Math.Poly2_s.poly) = data_1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 214 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg81 va_arg82) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 215 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 0) (let (va_arg80:Vale.Math.Poly2_s.poly)
= h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 218 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg80 2) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 219 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg79:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 220 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg79) (let
(va_arg78:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 221 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg78 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 222 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 223 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (fun
(va_s:va_state) _ -> let (va_arg77:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg76:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
2) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 224 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg76 va_arg77) (let
(va_arg75:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 225 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg75 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 226 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 13))
(fun (va_s:va_state) _ -> let (va_arg74:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64
in let (va_arg73:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 227 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg73 va_arg74) (let
(va_arg72:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 228 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg72 64) (let
(va_arg71:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 229 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg71 64) (let
(va_arg70:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 230 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg70) (let
(va_arg69:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 231 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg69 64) (let
(va_arg68:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 232 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg68 64) (let
(va_arg67:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift (add prev
data_0) (-64)) (Vale.Math.Poly2.mask (Vale.AES.GHash_BE.gf128_power h 2) 64) in let
(va_arg66:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask (add prev
data_0) 64) (Vale.Math.Poly2_s.shift (Vale.AES.GHash_BE.gf128_power h 2) (-64)) in let
(va_arg65:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec 3 va_s) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 233 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_add_associate va_arg65 va_arg66 va_arg67) (let
(va_arg64:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in let
(va_arg63:Vale.Math.Poly2_s.poly) = add prev data_0 in let (va_arg62:Vale.Math.Poly2_s.poly) =
of_quad32 (va_get_vec 4 va_s) in let (va_arg61:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec
3 va_s) in let (va_arg60:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec 2 va_s) in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 236 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128_accum va_arg60 va_arg61 va_arg62 va_arg63
va_arg64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 237 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 238 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 239 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 11))
(va_QEmpty (()))))))))))))))))))))))))))))))))))))))))))
val va_lemma_MulAdd_unroll_2way : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 -> index:nat ->
h:poly -> prev:poly -> data:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_MulAdd_unroll_2way ()) va_s0 /\ va_get_ok va_s0 /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 2 /\
in_b_blocks in_b index 2 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1) /\ va_state_eq va_sM
(va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))))))))))
[@"opaque_to_smt"]
let va_lemma_MulAdd_unroll_2way va_b0 va_s0 in_b index h prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec
4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_MulAdd_unroll_2way va_mods in_b index h prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_MulAdd_unroll_2way ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 156 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in label va_range1
"***** POSTCONDITION NOT MET AT line 192 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_MulAdd_unroll_2way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq quad32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 2 /\
in_b_blocks in_b index 2 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64)) /\ (forall
(va_x_r10:nat64) (va_x_v0:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32)
(va_x_v8:quad32) (va_x_v9:quad32) (va_x_v10:quad32) (va_x_v11:quad32) . let va_sM = va_upd_vec
11 va_x_v11 (va_upd_vec 10 va_x_v10 (va_upd_vec 9 va_x_v9 (va_upd_vec 8 va_x_v8 (va_upd_vec 4
va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 (va_upd_reg 10
va_x_r10 va_s0)))))))) in va_get_ok va_sM /\ (let (pdata:(Prims.int ->
Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1) ==> va_k va_sM (())))
val va_wpProof_MulAdd_unroll_2way : in_b:buffer128 -> index:nat -> h:poly -> prev:poly -> data:(seq
quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_MulAdd_unroll_2way in_b index h prev data va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_MulAdd_unroll_2way ()) ([va_Mod_vec
11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 0; va_Mod_reg 10]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_MulAdd_unroll_2way in_b index h prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_MulAdd_unroll_2way (va_code_MulAdd_unroll_2way ()) va_s0 in_b index
h prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM
(va_update_vec 8 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM va_s0)))))))))));
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_MulAdd_unroll_2way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq
quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_2way ())) =
(va_QProc (va_code_MulAdd_unroll_2way ()) ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9;
va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10])
(va_wp_MulAdd_unroll_2way in_b index h prev data) (va_wpProof_MulAdd_unroll_2way in_b index h
prev data))
//--
//-- Reduce
val va_code_Reduce : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Reduce () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 0) 0) (va_CCons (va_code_Low64ToHigh
(va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_CCons (va_code_VSwap (va_op_vec_opr_vec 10)
(va_op_vec_opr_vec 2)) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
2) (va_op_vec_opr_vec 8)) (va_CCons (va_code_High64ToLow (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 10)) (va_CCons (va_code_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2))
(va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
8)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
2)) (va_CNil ()))))))))))))))
val va_codegen_success_Reduce : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr] | false | true | Vale.AES.PPC64LE.GHash.fst | {
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_codegen_success_Reduce : va_dummy:unit -> Tot va_pbool | [] | Vale.AES.PPC64LE.GHash.va_codegen_success_Reduce | {
"file_name": "obj/Vale.AES.PPC64LE.GHash.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_dummy: Prims.unit -> Vale.PPC64LE.Decls.va_pbool | {
"end_col": 74,
"end_line": 552,
"start_col": 2,
"start_line": 539
} |
Prims.Tot | val va_wp_MulAdd_unroll_1way
(in_b: buffer128)
(index: nat)
(h prev: poly)
(data: (seq quad32))
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | [
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math // For lemma_poly_bits64()",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_wp_MulAdd_unroll_1way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq quad32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 1 /\
in_b_blocks in_b index 1 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64)) /\ (forall
(va_x_v0:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) . let va_sM = va_upd_vec 4
va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 va_s0))) in va_get_ok
va_sM /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0) ==> va_k va_sM (()))) | val va_wp_MulAdd_unroll_1way
(in_b: buffer128)
(index: nat)
(h prev: poly)
(data: (seq quad32))
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0
let va_wp_MulAdd_unroll_1way
(in_b: buffer128)
(index: nat)
(h prev: poly)
(data: (seq quad32))
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 = | false | null | false | (va_get_ok va_s0 /\
(let pdata:(Prims.int -> Vale.AES.GHash_BE.poly128) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data
in
FStar.Seq.Base.length #quad32 data == 1 /\
in_b_blocks in_b
index
1
(va_get_mem_heaplet 1 va_s0)
(va_get_mem_layout va_s0)
(va_get_reg 7 va_s0)
data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) ==
Vale.Math.Poly2.swap (Vale.AES.GHash_BE.gf128_power h 1) 64 /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0) ==
Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) ==
Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64)) /\
(forall (va_x_v0: quad32) (va_x_v2: quad32) (va_x_v3: quad32) (va_x_v4: quad32).
let va_sM =
va_upd_vec 4
va_x_v4
(va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 va_s0)))
in
va_get_ok va_sM /\
(let pdata:(Prims.int -> Vale.AES.GHash_BE.poly128) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data
in
add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM))
(Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64))
(Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0) ==>
va_k va_sM (()))) | {
"checked_file": "Vale.AES.PPC64LE.GHash.fst.checked",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.GCTR_BE.fsti.checked",
"Vale.AES.GCM_helpers_BE.fsti.checked",
"Vale.AES.AES_helpers.fsti.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GHash.fst"
} | [
"total"
] | [
"Vale.PPC64LE.Memory.buffer128",
"Prims.nat",
"Vale.Math.Poly2_s.poly",
"FStar.Seq.Base.seq",
"Vale.PPC64LE.Memory.quad32",
"Vale.PPC64LE.Decls.va_state",
"Prims.unit",
"Prims.l_and",
"Prims.b2t",
"Vale.PPC64LE.Decls.va_get_ok",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"Vale.AES.PPC64LE.GHash.in_b_blocks",
"Vale.PPC64LE.Decls.va_get_mem_heaplet",
"Vale.PPC64LE.Decls.va_get_mem_layout",
"Vale.PPC64LE.Decls.va_get_reg",
"Vale.Math.Poly2.Bits_s.of_quad32",
"Vale.PPC64LE.Decls.va_get_vec",
"Vale.Math.Poly2.swap",
"Vale.AES.GHash_BE.gf128_power",
"Vale.Math.Poly2_s.mul",
"Vale.Math.Poly2_s.div",
"Vale.Math.Poly2_s.monomial",
"Vale.Math.Poly2_s.mod",
"Vale.AES.GHash_BE.poly128",
"Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128",
"Prims.l_Forall",
"Prims.l_imp",
"Vale.Math.Poly2_s.add",
"Vale.Math.Poly2_s.shift",
"Vale.AES.GHash_BE.ghash_unroll_back",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.Decls.va_upd_vec"
] | [] | module Vale.AES.PPC64LE.GHash
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.AES_helpers
open Vale.Poly1305.Math // For lemma_poly_bits64()
open Vale.AES.GCM_helpers_BE
open Vale.AES.GCTR_BE_s
open Vale.AES.GCTR_BE
open Vale.Arch.TypesNative
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
#reset-options "--z3rlimit 50"
//-- MulAdd_unroll_1way
val va_code_MulAdd_unroll_1way : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_MulAdd_unroll_1way () =
(va_Block (va_CCons (va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_CCons (va_code_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_CCons
(va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5))
(va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
6)) (va_CNil ())))))))
val va_codegen_success_MulAdd_unroll_1way : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_MulAdd_unroll_1way () =
(va_pbool_and (va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_pbool_and
(va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
7)) (va_pbool_and (va_codegen_success_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (va_ttrue ()))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_MulAdd_unroll_1way (va_mods:va_mods_t) (in_b:buffer128) (index:nat) (h:poly)
(prev:poly) (data:(seq quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_1way ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (pdata:(Prims.int
-> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in let
(data_i:poly) = pdata 0 in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 136 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret in_b index) (fun (va_s:va_state) _ -> let
(va_arg44:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 138 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg44 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 139 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg43:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 140 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg43) (let
(va_arg42:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 141 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg42 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 142 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 143 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg41:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg40:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 144 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg40 va_arg41) (let
(va_arg39:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 145 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg39 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 146 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg38:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg37:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 147 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg37 va_arg38) (let
(va_arg36:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 148 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg36 64) (let
(va_arg35:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 149 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg35 64) (let
(va_arg34:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 150 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg34) (let
(va_arg33:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 151 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg33 64) (let
(va_arg32:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 152 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg32 64) (let
(va_arg31:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg30:Vale.Math.Poly2_s.poly) = add prev data_i in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 153 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg30 va_arg31) (va_QEmpty
(()))))))))))))))))))))
val va_lemma_MulAdd_unroll_1way : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 -> index:nat ->
h:poly -> prev:poly -> data:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_MulAdd_unroll_1way ()) va_s0 /\ va_get_ok va_s0 /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 1 /\
in_b_blocks in_b index 1 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0) /\ va_state_eq va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_ok va_sM va_s0)))))))
[@"opaque_to_smt"]
let va_lemma_MulAdd_unroll_1way va_b0 va_s0 in_b index h prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_MulAdd_unroll_1way va_mods in_b index h prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_MulAdd_unroll_1way ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 106 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in label va_range1
"***** POSTCONDITION NOT MET AT line 133 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_ok]) va_sM
va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_MulAdd_unroll_1way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq quad32)) | false | true | Vale.AES.PPC64LE.GHash.fst | {
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_wp_MulAdd_unroll_1way
(in_b: buffer128)
(index: nat)
(h prev: poly)
(data: (seq quad32))
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | [] | Vale.AES.PPC64LE.GHash.va_wp_MulAdd_unroll_1way | {
"file_name": "obj/Vale.AES.PPC64LE.GHash.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
in_b: Vale.PPC64LE.Memory.buffer128 ->
index: Prims.nat ->
h: Vale.Math.Poly2_s.poly ->
prev: Vale.Math.Poly2_s.poly ->
data: FStar.Seq.Base.seq Vale.PPC64LE.Memory.quad32 ->
va_s0: Vale.PPC64LE.Decls.va_state ->
va_k: (_: Vale.PPC64LE.Decls.va_state -> _: Prims.unit -> Type0)
-> Type0 | {
"end_col": 89,
"end_line": 188,
"start_col": 2,
"start_line": 172
} |
Prims.Tot | val va_code_MulAdd_unroll_1way : va_dummy:unit -> Tot va_code | [
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math // For lemma_poly_bits64()",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_code_MulAdd_unroll_1way () =
(va_Block (va_CCons (va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_CCons (va_code_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_CCons
(va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5))
(va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
6)) (va_CNil ()))))))) | val va_code_MulAdd_unroll_1way : va_dummy:unit -> Tot va_code
let va_code_MulAdd_unroll_1way () = | false | null | false | (va_Block (va_CCons (va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7)
Secret)
(va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 0))
(va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 7))
(va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 5))
(va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 6))
(va_CNil ()))))))) | {
"checked_file": "Vale.AES.PPC64LE.GHash.fst.checked",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.GCTR_BE.fsti.checked",
"Vale.AES.GCM_helpers_BE.fsti.checked",
"Vale.AES.AES_helpers.fsti.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GHash.fst"
} | [
"total"
] | [
"Prims.unit",
"Vale.PPC64LE.Decls.va_Block",
"Vale.PPC64LE.Decls.va_CCons",
"Vale.PPC64LE.InsVector.va_code_Load128_byte16_buffer",
"Vale.PPC64LE.Decls.va_op_heaplet_mem_heaplet",
"Vale.PPC64LE.Decls.va_op_vec_opr_vec",
"Vale.PPC64LE.Decls.va_op_reg_opr_reg",
"Vale.Arch.HeapTypes_s.Secret",
"Vale.AES.PPC64LE.PolyOps.va_code_VPolyAdd",
"Vale.AES.PPC64LE.PolyOps.va_code_VPolyMulLow",
"Vale.AES.PPC64LE.PolyOps.va_code_VPolyMul",
"Vale.AES.PPC64LE.PolyOps.va_code_VPolyMulHigh",
"Vale.PPC64LE.Decls.va_CNil",
"Vale.PPC64LE.Decls.va_code"
] | [] | module Vale.AES.PPC64LE.GHash
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.AES_helpers
open Vale.Poly1305.Math // For lemma_poly_bits64()
open Vale.AES.GCM_helpers_BE
open Vale.AES.GCTR_BE_s
open Vale.AES.GCTR_BE
open Vale.Arch.TypesNative
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
#reset-options "--z3rlimit 50"
//-- MulAdd_unroll_1way
val va_code_MulAdd_unroll_1way : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr] | false | true | Vale.AES.PPC64LE.GHash.fst | {
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_code_MulAdd_unroll_1way : va_dummy:unit -> Tot va_code | [] | Vale.AES.PPC64LE.GHash.va_code_MulAdd_unroll_1way | {
"file_name": "obj/Vale.AES.PPC64LE.GHash.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_dummy: Prims.unit -> Vale.PPC64LE.Decls.va_code | {
"end_col": 26,
"end_line": 47,
"start_col": 2,
"start_line": 41
} |
Prims.Tot | val va_wp_Reduce (f: poly) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 | [
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math // For lemma_poly_bits64()",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_wp_Reduce (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in
let (c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63
in let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in
let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) (-64) == zero /\ Vale.Math.Poly2.mask (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) 64 == c /\ Vale.Math.Poly2_s.degree f < 64 /\ Vale.Math.Poly2_s.degree g
== 128 /\ Vale.Math.Poly2_s.poly_index f 0) /\ (forall (va_x_v0:quad32) (va_x_v10:quad32)
(va_x_v8:quad32) (va_x_v2:quad32) (va_x_v9:quad32) (va_x_v3:quad32) (va_x_v4:quad32)
(va_x_v1:quad32) . let va_sM = va_upd_vec 1 va_x_v1 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3
(va_upd_vec 9 va_x_v9 (va_upd_vec 2 va_x_v2 (va_upd_vec 8 va_x_v8 (va_upd_vec 10 va_x_v10
(va_upd_vec 0 va_x_v0 va_s0))))))) in va_get_ok va_sM /\ (let (g:Vale.Math.Poly2_s.poly) = add
(Vale.Math.Poly2_s.monomial 128) f in let (c:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in let
(a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) ==
Vale.Math.Poly2_s.reverse (mod (Vale.Math.Poly2_s.reverse a 255) g) 127) ==> va_k va_sM (()))) | val va_wp_Reduce (f: poly) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
let va_wp_Reduce (f: poly) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 = | false | null | false | (va_get_ok va_s0 /\
(let g:Vale.Math.Poly2_s.poly = add (Vale.Math.Poly2_s.monomial 128) f in
let c:Vale.Math.Poly2_s.poly = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (- 1)) 63 in
let a0:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in
let a1:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
let a2:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
let a:Vale.Math.Poly2_s.poly =
add (add a0 (Vale.Math.Poly2_s.shift a1 64)) (Vale.Math.Poly2_s.shift a2 128)
in
Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 8 va_s0)) (- 64) == zero /\
Vale.Math.Poly2.mask (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 8 va_s0)) 64 == c /\
Vale.Math.Poly2_s.degree f < 64 /\ Vale.Math.Poly2_s.degree g == 128 /\
Vale.Math.Poly2_s.poly_index f 0) /\
(forall (va_x_v0: quad32)
(va_x_v10: quad32)
(va_x_v8: quad32)
(va_x_v2: quad32)
(va_x_v9: quad32)
(va_x_v3: quad32)
(va_x_v4: quad32)
(va_x_v1: quad32).
let va_sM =
va_upd_vec 1
va_x_v1
(va_upd_vec 4
va_x_v4
(va_upd_vec 3
va_x_v3
(va_upd_vec 9
va_x_v9
(va_upd_vec 2
va_x_v2
(va_upd_vec 8
va_x_v8
(va_upd_vec 10 va_x_v10 (va_upd_vec 0 va_x_v0 va_s0)))))))
in
va_get_ok va_sM /\
(let g:Vale.Math.Poly2_s.poly = add (Vale.Math.Poly2_s.monomial 128) f in
let c:Vale.Math.Poly2_s.poly =
Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (- 1)) 63
in
let a0:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in
let a1:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
let a2:Vale.Math.Poly2_s.poly = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in
let a:Vale.Math.Poly2_s.poly =
add (add a0 (Vale.Math.Poly2_s.shift a1 64)) (Vale.Math.Poly2_s.shift a2 128)
in
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) ==
Vale.Math.Poly2_s.reverse (mod (Vale.Math.Poly2_s.reverse a 255) g) 127) ==>
va_k va_sM (()))) | {
"checked_file": "Vale.AES.PPC64LE.GHash.fst.checked",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.GCTR_BE.fsti.checked",
"Vale.AES.GCM_helpers_BE.fsti.checked",
"Vale.AES.AES_helpers.fsti.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GHash.fst"
} | [
"total"
] | [
"Vale.Math.Poly2_s.poly",
"Vale.PPC64LE.Decls.va_state",
"Prims.unit",
"Prims.l_and",
"Prims.b2t",
"Vale.PPC64LE.Decls.va_get_ok",
"Prims.eq2",
"Vale.Math.Poly2_s.shift",
"Vale.Math.Poly2.Bits_s.of_quad32",
"Vale.PPC64LE.Decls.va_get_vec",
"Prims.op_Minus",
"Vale.Math.Poly2_s.zero",
"Vale.Math.Poly2.mask",
"Prims.op_LessThan",
"Vale.Math.Poly2_s.degree",
"Prims.int",
"Vale.Math.Poly2_s.poly_index",
"Vale.Math.Poly2_s.add",
"Vale.Math.Poly2_s.reverse",
"Vale.Math.Poly2_s.monomial",
"Prims.l_Forall",
"Vale.PPC64LE.Memory.quad32",
"Prims.l_imp",
"Vale.Math.Poly2_s.mod",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.Decls.va_upd_vec"
] | [] | module Vale.AES.PPC64LE.GHash
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.AES_helpers
open Vale.Poly1305.Math // For lemma_poly_bits64()
open Vale.AES.GCM_helpers_BE
open Vale.AES.GCTR_BE_s
open Vale.AES.GCTR_BE
open Vale.Arch.TypesNative
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
#reset-options "--z3rlimit 50"
//-- MulAdd_unroll_1way
val va_code_MulAdd_unroll_1way : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_MulAdd_unroll_1way () =
(va_Block (va_CCons (va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_CCons (va_code_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_CCons
(va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5))
(va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
6)) (va_CNil ())))))))
val va_codegen_success_MulAdd_unroll_1way : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_MulAdd_unroll_1way () =
(va_pbool_and (va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_pbool_and
(va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
7)) (va_pbool_and (va_codegen_success_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (va_ttrue ()))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_MulAdd_unroll_1way (va_mods:va_mods_t) (in_b:buffer128) (index:nat) (h:poly)
(prev:poly) (data:(seq quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_1way ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (pdata:(Prims.int
-> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in let
(data_i:poly) = pdata 0 in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 136 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret in_b index) (fun (va_s:va_state) _ -> let
(va_arg44:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 138 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg44 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 139 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg43:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 140 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg43) (let
(va_arg42:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 141 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg42 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 142 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 143 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg41:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg40:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 144 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg40 va_arg41) (let
(va_arg39:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 145 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg39 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 146 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg38:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg37:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 147 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg37 va_arg38) (let
(va_arg36:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 148 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg36 64) (let
(va_arg35:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 149 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg35 64) (let
(va_arg34:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 150 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg34) (let
(va_arg33:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 151 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg33 64) (let
(va_arg32:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 152 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg32 64) (let
(va_arg31:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg30:Vale.Math.Poly2_s.poly) = add prev data_i in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 153 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg30 va_arg31) (va_QEmpty
(()))))))))))))))))))))
val va_lemma_MulAdd_unroll_1way : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 -> index:nat ->
h:poly -> prev:poly -> data:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_MulAdd_unroll_1way ()) va_s0 /\ va_get_ok va_s0 /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 1 /\
in_b_blocks in_b index 1 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0) /\ va_state_eq va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_ok va_sM va_s0)))))))
[@"opaque_to_smt"]
let va_lemma_MulAdd_unroll_1way va_b0 va_s0 in_b index h prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_MulAdd_unroll_1way va_mods in_b index h prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_MulAdd_unroll_1way ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 106 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in label va_range1
"***** POSTCONDITION NOT MET AT line 133 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_ok]) va_sM
va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_MulAdd_unroll_1way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq quad32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 1 /\
in_b_blocks in_b index 1 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64)) /\ (forall
(va_x_v0:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) . let va_sM = va_upd_vec 4
va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 va_s0))) in va_get_ok
va_sM /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0) ==> va_k va_sM (())))
val va_wpProof_MulAdd_unroll_1way : in_b:buffer128 -> index:nat -> h:poly -> prev:poly -> data:(seq
quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_MulAdd_unroll_1way in_b index h prev data va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_MulAdd_unroll_1way ()) ([va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_MulAdd_unroll_1way in_b index h prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_MulAdd_unroll_1way (va_code_MulAdd_unroll_1way ()) va_s0 in_b index
h prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 0 va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_MulAdd_unroll_1way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq
quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_1way ())) =
(va_QProc (va_code_MulAdd_unroll_1way ()) ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec
0]) (va_wp_MulAdd_unroll_1way in_b index h prev data) (va_wpProof_MulAdd_unroll_1way in_b index
h prev data))
//--
//-- MulAdd_unroll_2way
val va_code_MulAdd_unroll_2way : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_MulAdd_unroll_2way () =
(va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_CCons
(va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret) (va_CCons (va_code_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg
10) Secret) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 7)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 5)) (va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
8) (va_op_vec_opr_vec 6)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 0)) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec
10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (va_CCons (va_code_VPolyMulHigh
(va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 13)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 11)) (va_CNil
())))))))))))))))
val va_codegen_success_MulAdd_unroll_2way : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_MulAdd_unroll_2way () =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret) (va_pbool_and (va_codegen_success_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg
10) Secret) (va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 8) (va_op_vec_opr_vec 7)) (va_pbool_and (va_codegen_success_VPolyMul
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec
6)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 0)) (va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14)) (va_pbool_and (va_codegen_success_VPolyMul
(va_op_vec_opr_vec 10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (va_pbool_and
(va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 13)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_pbool_and
(va_codegen_success_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
11)) (va_ttrue ()))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_MulAdd_unroll_2way (va_mods:va_mods_t) (in_b:buffer128) (index:nat) (h:poly)
(prev:poly) (data:(seq quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_2way ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (pdata:(Prims.int
-> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in let
(data_0:poly) = pdata 0 in let (data_1:poly) = pdata 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 196 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 197 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret in_b index) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 198 column 32 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 10) Secret in_b (index + 1)) (fun (va_s:va_state) _ ->
let (va_arg95:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 200 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg95 1) (let
(va_arg94:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 201 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg94) (let
(va_arg93:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 202 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg93 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 203 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 204 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg92:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg91:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 205 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg91 va_arg92) (let
(va_arg90:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 206 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg90 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 207 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg89:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg88:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 208 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg88 va_arg89) (let
(va_arg87:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 209 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg87 64) (let
(va_arg86:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 210 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg86 64) (let
(va_arg85:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 211 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg85) (let
(va_arg84:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 212 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg84 64) (let
(va_arg83:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 213 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg83 64) (let
(va_arg82:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg81:Vale.Math.Poly2_s.poly) = data_1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 214 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg81 va_arg82) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 215 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 0) (let (va_arg80:Vale.Math.Poly2_s.poly)
= h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 218 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg80 2) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 219 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg79:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 220 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg79) (let
(va_arg78:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 221 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg78 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 222 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 223 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (fun
(va_s:va_state) _ -> let (va_arg77:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg76:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
2) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 224 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg76 va_arg77) (let
(va_arg75:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 225 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg75 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 226 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 13))
(fun (va_s:va_state) _ -> let (va_arg74:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64
in let (va_arg73:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 227 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg73 va_arg74) (let
(va_arg72:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 228 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg72 64) (let
(va_arg71:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 229 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg71 64) (let
(va_arg70:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 230 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg70) (let
(va_arg69:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 231 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg69 64) (let
(va_arg68:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 232 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg68 64) (let
(va_arg67:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift (add prev
data_0) (-64)) (Vale.Math.Poly2.mask (Vale.AES.GHash_BE.gf128_power h 2) 64) in let
(va_arg66:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask (add prev
data_0) 64) (Vale.Math.Poly2_s.shift (Vale.AES.GHash_BE.gf128_power h 2) (-64)) in let
(va_arg65:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec 3 va_s) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 233 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_add_associate va_arg65 va_arg66 va_arg67) (let
(va_arg64:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in let
(va_arg63:Vale.Math.Poly2_s.poly) = add prev data_0 in let (va_arg62:Vale.Math.Poly2_s.poly) =
of_quad32 (va_get_vec 4 va_s) in let (va_arg61:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec
3 va_s) in let (va_arg60:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec 2 va_s) in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 236 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128_accum va_arg60 va_arg61 va_arg62 va_arg63
va_arg64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 237 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 238 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 239 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 11))
(va_QEmpty (()))))))))))))))))))))))))))))))))))))))))))
val va_lemma_MulAdd_unroll_2way : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 -> index:nat ->
h:poly -> prev:poly -> data:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_MulAdd_unroll_2way ()) va_s0 /\ va_get_ok va_s0 /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 2 /\
in_b_blocks in_b index 2 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1) /\ va_state_eq va_sM
(va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))))))))))
[@"opaque_to_smt"]
let va_lemma_MulAdd_unroll_2way va_b0 va_s0 in_b index h prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec
4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_MulAdd_unroll_2way va_mods in_b index h prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_MulAdd_unroll_2way ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 156 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in label va_range1
"***** POSTCONDITION NOT MET AT line 192 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_MulAdd_unroll_2way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq quad32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 2 /\
in_b_blocks in_b index 2 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64)) /\ (forall
(va_x_r10:nat64) (va_x_v0:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32)
(va_x_v8:quad32) (va_x_v9:quad32) (va_x_v10:quad32) (va_x_v11:quad32) . let va_sM = va_upd_vec
11 va_x_v11 (va_upd_vec 10 va_x_v10 (va_upd_vec 9 va_x_v9 (va_upd_vec 8 va_x_v8 (va_upd_vec 4
va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 (va_upd_reg 10
va_x_r10 va_s0)))))))) in va_get_ok va_sM /\ (let (pdata:(Prims.int ->
Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1) ==> va_k va_sM (())))
val va_wpProof_MulAdd_unroll_2way : in_b:buffer128 -> index:nat -> h:poly -> prev:poly -> data:(seq
quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_MulAdd_unroll_2way in_b index h prev data va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_MulAdd_unroll_2way ()) ([va_Mod_vec
11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 0; va_Mod_reg 10]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_MulAdd_unroll_2way in_b index h prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_MulAdd_unroll_2way (va_code_MulAdd_unroll_2way ()) va_s0 in_b index
h prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM
(va_update_vec 8 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM va_s0)))))))))));
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_MulAdd_unroll_2way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq
quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_2way ())) =
(va_QProc (va_code_MulAdd_unroll_2way ()) ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9;
va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10])
(va_wp_MulAdd_unroll_2way in_b index h prev data) (va_wpProof_MulAdd_unroll_2way in_b index h
prev data))
//--
//-- Reduce
val va_code_Reduce : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Reduce () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 0) 0) (va_CCons (va_code_Low64ToHigh
(va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_CCons (va_code_VSwap (va_op_vec_opr_vec 10)
(va_op_vec_opr_vec 2)) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
2) (va_op_vec_opr_vec 8)) (va_CCons (va_code_High64ToLow (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 10)) (va_CCons (va_code_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2))
(va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
8)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
2)) (va_CNil ()))))))))))))))
val va_codegen_success_Reduce : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Reduce () =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 0) 0) (va_pbool_and
(va_codegen_success_Low64ToHigh (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9))
(va_pbool_and (va_codegen_success_VSwap (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 2))
(va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 8)) (va_pbool_and (va_codegen_success_High64ToLow (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 3)) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 10)) (va_pbool_and
(va_codegen_success_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_pbool_and
(va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
8)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_ttrue ())))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Reduce (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_Reduce ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in let
(c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in
let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 265 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 0) 0) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 266 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod a1 64) (let
(va_arg39:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.mask a1 64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 267 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_is_mul va_arg39 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 268 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Low64ToHigh (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3) a1) (fun (va_s:va_state) _ ->
let (va_arg38:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift (Vale.Math.Poly2.mask a1 64) 64
in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 269 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32 va_arg38) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 270 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 271 column 10 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VSwap (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 2)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 272 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 273 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div a1 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 274 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_High64ToLow (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) a1) (fun (va_s:va_state) _ ->
let (va_arg37:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift a1 (-64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 275 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32 va_arg37) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 276 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 3)) (fun
(va_s:va_state) _ -> let (va_arg36:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 10 va_s) in let (va_arg35:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 277 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_add_commute va_arg35 va_arg36) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 278 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 10)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 279 column 10 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 280 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 281 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 4)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 282 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (fun
(va_s:va_state) _ -> let (va_arg34:Vale.Math.Poly2_s.poly) = f in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 283 column 21 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_reduce_rev a0 a1 a2 va_arg34 64) (va_QEmpty
(()))))))))))))))))))))))
val va_lemma_Reduce : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Reduce ()) va_s0 /\ va_get_ok va_s0 /\ (let
(g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in let
(c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in
let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) (-64) == zero /\ Vale.Math.Poly2.mask (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) 64 == c /\ Vale.Math.Poly2_s.degree f < 64 /\ Vale.Math.Poly2_s.degree g
== 128 /\ Vale.Math.Poly2_s.poly_index f 0)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in let
(c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in
let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) ==
Vale.Math.Poly2_s.reverse (mod (Vale.Math.Poly2_s.reverse a 255) g) 127) /\ va_state_eq va_sM
(va_update_vec 1 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 9 va_sM
(va_update_vec 2 va_sM (va_update_vec 8 va_sM (va_update_vec 10 va_sM (va_update_vec 0 va_sM
(va_update_ok va_sM va_s0)))))))))))
[@"opaque_to_smt"]
let va_lemma_Reduce va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2;
va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_Reduce va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Reduce ()) va_qc va_s0 (fun va_s0 va_sM
va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 242 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f
in let (c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1))
63 in let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0)
in let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in label va_range1
"***** POSTCONDITION NOT MET AT line 263 column 60 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.Math.Poly2_s.reverse (mod
(Vale.Math.Poly2_s.reverse a 255) g) 127))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2;
va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr] | false | true | Vale.AES.PPC64LE.GHash.fst | {
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_wp_Reduce (f: poly) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 | [] | Vale.AES.PPC64LE.GHash.va_wp_Reduce | {
"file_name": "obj/Vale.AES.PPC64LE.GHash.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
f: Vale.Math.Poly2_s.poly ->
va_s0: Vale.PPC64LE.Decls.va_state ->
va_k: (_: Vale.PPC64LE.Decls.va_state -> _: Prims.unit -> Type0)
-> Type0 | {
"end_col": 98,
"end_line": 689,
"start_col": 2,
"start_line": 668
} |
Prims.Tot | val va_codegen_success_Ghash_buffer_while0 : va_dummy:unit -> Tot va_pbool | [
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math // For lemma_poly_bits64()",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_codegen_success_Ghash_buffer_while0 () =
(va_pbool_and (va_codegen_success_Ghash_buffer_body0 ()) (va_ttrue ())) | val va_codegen_success_Ghash_buffer_while0 : va_dummy:unit -> Tot va_pbool
let va_codegen_success_Ghash_buffer_while0 () = | false | null | false | (va_pbool_and (va_codegen_success_Ghash_buffer_body0 ()) (va_ttrue ())) | {
"checked_file": "Vale.AES.PPC64LE.GHash.fst.checked",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.GCTR_BE.fsti.checked",
"Vale.AES.GCM_helpers_BE.fsti.checked",
"Vale.AES.AES_helpers.fsti.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GHash.fst"
} | [
"total"
] | [
"Prims.unit",
"Vale.PPC64LE.Decls.va_pbool_and",
"Vale.AES.PPC64LE.GHash.va_codegen_success_Ghash_buffer_body0",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | module Vale.AES.PPC64LE.GHash
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.AES_helpers
open Vale.Poly1305.Math // For lemma_poly_bits64()
open Vale.AES.GCM_helpers_BE
open Vale.AES.GCTR_BE_s
open Vale.AES.GCTR_BE
open Vale.Arch.TypesNative
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
#reset-options "--z3rlimit 50"
//-- MulAdd_unroll_1way
val va_code_MulAdd_unroll_1way : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_MulAdd_unroll_1way () =
(va_Block (va_CCons (va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_CCons (va_code_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_CCons
(va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5))
(va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
6)) (va_CNil ())))))))
val va_codegen_success_MulAdd_unroll_1way : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_MulAdd_unroll_1way () =
(va_pbool_and (va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_pbool_and
(va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
7)) (va_pbool_and (va_codegen_success_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (va_ttrue ()))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_MulAdd_unroll_1way (va_mods:va_mods_t) (in_b:buffer128) (index:nat) (h:poly)
(prev:poly) (data:(seq quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_1way ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (pdata:(Prims.int
-> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in let
(data_i:poly) = pdata 0 in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 136 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret in_b index) (fun (va_s:va_state) _ -> let
(va_arg44:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 138 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg44 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 139 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg43:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 140 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg43) (let
(va_arg42:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 141 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg42 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 142 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 143 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg41:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg40:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 144 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg40 va_arg41) (let
(va_arg39:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 145 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg39 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 146 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg38:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg37:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 147 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg37 va_arg38) (let
(va_arg36:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 148 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg36 64) (let
(va_arg35:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 149 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg35 64) (let
(va_arg34:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 150 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg34) (let
(va_arg33:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 151 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg33 64) (let
(va_arg32:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 152 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg32 64) (let
(va_arg31:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg30:Vale.Math.Poly2_s.poly) = add prev data_i in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 153 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg30 va_arg31) (va_QEmpty
(()))))))))))))))))))))
val va_lemma_MulAdd_unroll_1way : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 -> index:nat ->
h:poly -> prev:poly -> data:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_MulAdd_unroll_1way ()) va_s0 /\ va_get_ok va_s0 /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 1 /\
in_b_blocks in_b index 1 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0) /\ va_state_eq va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_ok va_sM va_s0)))))))
[@"opaque_to_smt"]
let va_lemma_MulAdd_unroll_1way va_b0 va_s0 in_b index h prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_MulAdd_unroll_1way va_mods in_b index h prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_MulAdd_unroll_1way ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 106 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in label va_range1
"***** POSTCONDITION NOT MET AT line 133 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_ok]) va_sM
va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_MulAdd_unroll_1way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq quad32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 1 /\
in_b_blocks in_b index 1 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64)) /\ (forall
(va_x_v0:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) . let va_sM = va_upd_vec 4
va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 va_s0))) in va_get_ok
va_sM /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0) ==> va_k va_sM (())))
val va_wpProof_MulAdd_unroll_1way : in_b:buffer128 -> index:nat -> h:poly -> prev:poly -> data:(seq
quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_MulAdd_unroll_1way in_b index h prev data va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_MulAdd_unroll_1way ()) ([va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_MulAdd_unroll_1way in_b index h prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_MulAdd_unroll_1way (va_code_MulAdd_unroll_1way ()) va_s0 in_b index
h prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 0 va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_MulAdd_unroll_1way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq
quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_1way ())) =
(va_QProc (va_code_MulAdd_unroll_1way ()) ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec
0]) (va_wp_MulAdd_unroll_1way in_b index h prev data) (va_wpProof_MulAdd_unroll_1way in_b index
h prev data))
//--
//-- MulAdd_unroll_2way
val va_code_MulAdd_unroll_2way : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_MulAdd_unroll_2way () =
(va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_CCons
(va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret) (va_CCons (va_code_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg
10) Secret) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 7)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 5)) (va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
8) (va_op_vec_opr_vec 6)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 0)) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec
10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (va_CCons (va_code_VPolyMulHigh
(va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 13)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 11)) (va_CNil
())))))))))))))))
val va_codegen_success_MulAdd_unroll_2way : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_MulAdd_unroll_2way () =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret) (va_pbool_and (va_codegen_success_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg
10) Secret) (va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 8) (va_op_vec_opr_vec 7)) (va_pbool_and (va_codegen_success_VPolyMul
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec
6)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 0)) (va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14)) (va_pbool_and (va_codegen_success_VPolyMul
(va_op_vec_opr_vec 10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (va_pbool_and
(va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 13)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_pbool_and
(va_codegen_success_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
11)) (va_ttrue ()))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_MulAdd_unroll_2way (va_mods:va_mods_t) (in_b:buffer128) (index:nat) (h:poly)
(prev:poly) (data:(seq quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_2way ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (pdata:(Prims.int
-> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in let
(data_0:poly) = pdata 0 in let (data_1:poly) = pdata 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 196 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 197 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret in_b index) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 198 column 32 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 10) Secret in_b (index + 1)) (fun (va_s:va_state) _ ->
let (va_arg95:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 200 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg95 1) (let
(va_arg94:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 201 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg94) (let
(va_arg93:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 202 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg93 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 203 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 204 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg92:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg91:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 205 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg91 va_arg92) (let
(va_arg90:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 206 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg90 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 207 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg89:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg88:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 208 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg88 va_arg89) (let
(va_arg87:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 209 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg87 64) (let
(va_arg86:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 210 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg86 64) (let
(va_arg85:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 211 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg85) (let
(va_arg84:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 212 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg84 64) (let
(va_arg83:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 213 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg83 64) (let
(va_arg82:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg81:Vale.Math.Poly2_s.poly) = data_1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 214 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg81 va_arg82) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 215 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 0) (let (va_arg80:Vale.Math.Poly2_s.poly)
= h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 218 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg80 2) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 219 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg79:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 220 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg79) (let
(va_arg78:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 221 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg78 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 222 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 223 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (fun
(va_s:va_state) _ -> let (va_arg77:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg76:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
2) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 224 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg76 va_arg77) (let
(va_arg75:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 225 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg75 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 226 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 13))
(fun (va_s:va_state) _ -> let (va_arg74:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64
in let (va_arg73:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 227 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg73 va_arg74) (let
(va_arg72:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 228 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg72 64) (let
(va_arg71:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 229 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg71 64) (let
(va_arg70:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 230 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg70) (let
(va_arg69:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 231 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg69 64) (let
(va_arg68:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 232 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg68 64) (let
(va_arg67:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift (add prev
data_0) (-64)) (Vale.Math.Poly2.mask (Vale.AES.GHash_BE.gf128_power h 2) 64) in let
(va_arg66:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask (add prev
data_0) 64) (Vale.Math.Poly2_s.shift (Vale.AES.GHash_BE.gf128_power h 2) (-64)) in let
(va_arg65:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec 3 va_s) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 233 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_add_associate va_arg65 va_arg66 va_arg67) (let
(va_arg64:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in let
(va_arg63:Vale.Math.Poly2_s.poly) = add prev data_0 in let (va_arg62:Vale.Math.Poly2_s.poly) =
of_quad32 (va_get_vec 4 va_s) in let (va_arg61:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec
3 va_s) in let (va_arg60:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec 2 va_s) in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 236 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128_accum va_arg60 va_arg61 va_arg62 va_arg63
va_arg64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 237 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 238 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 239 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 11))
(va_QEmpty (()))))))))))))))))))))))))))))))))))))))))))
val va_lemma_MulAdd_unroll_2way : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 -> index:nat ->
h:poly -> prev:poly -> data:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_MulAdd_unroll_2way ()) va_s0 /\ va_get_ok va_s0 /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 2 /\
in_b_blocks in_b index 2 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1) /\ va_state_eq va_sM
(va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))))))))))
[@"opaque_to_smt"]
let va_lemma_MulAdd_unroll_2way va_b0 va_s0 in_b index h prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec
4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_MulAdd_unroll_2way va_mods in_b index h prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_MulAdd_unroll_2way ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 156 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in label va_range1
"***** POSTCONDITION NOT MET AT line 192 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_MulAdd_unroll_2way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq quad32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 2 /\
in_b_blocks in_b index 2 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64)) /\ (forall
(va_x_r10:nat64) (va_x_v0:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32)
(va_x_v8:quad32) (va_x_v9:quad32) (va_x_v10:quad32) (va_x_v11:quad32) . let va_sM = va_upd_vec
11 va_x_v11 (va_upd_vec 10 va_x_v10 (va_upd_vec 9 va_x_v9 (va_upd_vec 8 va_x_v8 (va_upd_vec 4
va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 (va_upd_reg 10
va_x_r10 va_s0)))))))) in va_get_ok va_sM /\ (let (pdata:(Prims.int ->
Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1) ==> va_k va_sM (())))
val va_wpProof_MulAdd_unroll_2way : in_b:buffer128 -> index:nat -> h:poly -> prev:poly -> data:(seq
quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_MulAdd_unroll_2way in_b index h prev data va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_MulAdd_unroll_2way ()) ([va_Mod_vec
11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 0; va_Mod_reg 10]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_MulAdd_unroll_2way in_b index h prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_MulAdd_unroll_2way (va_code_MulAdd_unroll_2way ()) va_s0 in_b index
h prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM
(va_update_vec 8 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM va_s0)))))))))));
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_MulAdd_unroll_2way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq
quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_2way ())) =
(va_QProc (va_code_MulAdd_unroll_2way ()) ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9;
va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10])
(va_wp_MulAdd_unroll_2way in_b index h prev data) (va_wpProof_MulAdd_unroll_2way in_b index h
prev data))
//--
//-- Reduce
val va_code_Reduce : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Reduce () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 0) 0) (va_CCons (va_code_Low64ToHigh
(va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_CCons (va_code_VSwap (va_op_vec_opr_vec 10)
(va_op_vec_opr_vec 2)) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
2) (va_op_vec_opr_vec 8)) (va_CCons (va_code_High64ToLow (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 10)) (va_CCons (va_code_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2))
(va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
8)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
2)) (va_CNil ()))))))))))))))
val va_codegen_success_Reduce : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Reduce () =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 0) 0) (va_pbool_and
(va_codegen_success_Low64ToHigh (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9))
(va_pbool_and (va_codegen_success_VSwap (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 2))
(va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 8)) (va_pbool_and (va_codegen_success_High64ToLow (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 3)) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 10)) (va_pbool_and
(va_codegen_success_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_pbool_and
(va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
8)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_ttrue ())))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Reduce (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_Reduce ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in let
(c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in
let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 265 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 0) 0) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 266 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod a1 64) (let
(va_arg39:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.mask a1 64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 267 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_is_mul va_arg39 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 268 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Low64ToHigh (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3) a1) (fun (va_s:va_state) _ ->
let (va_arg38:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift (Vale.Math.Poly2.mask a1 64) 64
in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 269 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32 va_arg38) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 270 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 271 column 10 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VSwap (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 2)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 272 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 273 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div a1 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 274 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_High64ToLow (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) a1) (fun (va_s:va_state) _ ->
let (va_arg37:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift a1 (-64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 275 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32 va_arg37) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 276 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 3)) (fun
(va_s:va_state) _ -> let (va_arg36:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 10 va_s) in let (va_arg35:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 277 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_add_commute va_arg35 va_arg36) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 278 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 10)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 279 column 10 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 280 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 281 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 4)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 282 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (fun
(va_s:va_state) _ -> let (va_arg34:Vale.Math.Poly2_s.poly) = f in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 283 column 21 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_reduce_rev a0 a1 a2 va_arg34 64) (va_QEmpty
(()))))))))))))))))))))))
val va_lemma_Reduce : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Reduce ()) va_s0 /\ va_get_ok va_s0 /\ (let
(g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in let
(c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in
let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) (-64) == zero /\ Vale.Math.Poly2.mask (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) 64 == c /\ Vale.Math.Poly2_s.degree f < 64 /\ Vale.Math.Poly2_s.degree g
== 128 /\ Vale.Math.Poly2_s.poly_index f 0)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in let
(c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in
let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) ==
Vale.Math.Poly2_s.reverse (mod (Vale.Math.Poly2_s.reverse a 255) g) 127) /\ va_state_eq va_sM
(va_update_vec 1 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 9 va_sM
(va_update_vec 2 va_sM (va_update_vec 8 va_sM (va_update_vec 10 va_sM (va_update_vec 0 va_sM
(va_update_ok va_sM va_s0)))))))))))
[@"opaque_to_smt"]
let va_lemma_Reduce va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2;
va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_Reduce va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Reduce ()) va_qc va_s0 (fun va_s0 va_sM
va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 242 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f
in let (c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1))
63 in let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0)
in let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in label va_range1
"***** POSTCONDITION NOT MET AT line 263 column 60 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.Math.Poly2_s.reverse (mod
(Vale.Math.Poly2_s.reverse a 255) g) 127))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2;
va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Reduce (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in
let (c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63
in let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in
let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) (-64) == zero /\ Vale.Math.Poly2.mask (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) 64 == c /\ Vale.Math.Poly2_s.degree f < 64 /\ Vale.Math.Poly2_s.degree g
== 128 /\ Vale.Math.Poly2_s.poly_index f 0) /\ (forall (va_x_v0:quad32) (va_x_v10:quad32)
(va_x_v8:quad32) (va_x_v2:quad32) (va_x_v9:quad32) (va_x_v3:quad32) (va_x_v4:quad32)
(va_x_v1:quad32) . let va_sM = va_upd_vec 1 va_x_v1 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3
(va_upd_vec 9 va_x_v9 (va_upd_vec 2 va_x_v2 (va_upd_vec 8 va_x_v8 (va_upd_vec 10 va_x_v10
(va_upd_vec 0 va_x_v0 va_s0))))))) in va_get_ok va_sM /\ (let (g:Vale.Math.Poly2_s.poly) = add
(Vale.Math.Poly2_s.monomial 128) f in let (c:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in let
(a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) ==
Vale.Math.Poly2_s.reverse (mod (Vale.Math.Poly2_s.reverse a 255) g) 127) ==> va_k va_sM (())))
val va_wpProof_Reduce : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Reduce f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Reduce ()) ([va_Mod_vec 1; va_Mod_vec
4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2; va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0]) va_s0
va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Reduce f va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Reduce (va_code_Reduce ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 1 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 9 va_sM (va_update_vec 2 va_sM (va_update_vec 8 va_sM (va_update_vec 10 va_sM
(va_update_vec 0 va_sM (va_update_ok va_sM va_s0))))))))));
va_lemma_norm_mods ([va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2;
va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Reduce (f:poly) : (va_quickCode unit (va_code_Reduce ())) =
(va_QProc (va_code_Reduce ()) ([va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9;
va_Mod_vec 2; va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0]) (va_wp_Reduce f) (va_wpProof_Reduce
f))
//--
//-- ReduceLast
[@ "opaque_to_smt" va_qattr]
let va_code_ReduceLast () =
(va_Block (va_CCons (va_code_Reduce ()) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_Block
(va_CNil ())) (va_CNil ())))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ReduceLast () =
(va_pbool_and (va_codegen_success_Reduce ()) (va_ttrue ()))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ReduceLast (va_mods:va_mods_t) (h_BE:quad32) (y_prev:quad32) (data:(seq quad32)) :
(va_quickCode unit (va_code_ReduceLast ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in let
(prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in let (n:Prims.nat) = FStar.Seq.Base.length #quad32 data in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 311 column 35 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_constant_shift_rev ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 312 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_degree ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 313 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Reduce gf128_modulus_low_terms) (fun (va_s:va_state) _ -> va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 314 column 36 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(n - 1 >= 0) (fun _ -> let (va_arg25:Prims.nat) = n - 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 314 column 36 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_ghash_unroll_back_forward h prev pdata 0 va_arg25)
(va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 315 column 31 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(n - 1 >= 0) (fun _ -> let (va_arg24:Prims.nat) = n - 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 315 column 31 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_ghash_poly_of_unroll h prev pdata 0 va_arg24) (let
(va_arg23:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = data in let
(va_arg22:Vale.Def.Types_s.quad32) = y_prev in let (va_arg21:Vale.Def.Types_s.quad32) = h_BE in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 316 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_ghash_incremental_poly va_arg21 va_arg22 va_arg23)
(let (va_arg20:Vale.Def.Types_s.quad32) = Vale.AES.GHash_BE.ghash_incremental h_BE y_prev data
in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 317 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_to_of_quad32 va_arg20) (va_QEmpty (()))))))))))))
[@"opaque_to_smt"]
let va_lemma_ReduceLast va_b0 va_s0 h_BE y_prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_ReduceLast va_mods h_BE y_prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ReduceLast ()) va_qc va_s0 (fun va_s0
va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 286 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in
let (prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in let (n:Prims.nat) = FStar.Seq.Base.length #quad32 data in label va_range1
"***** POSTCONDITION NOT MET AT line 307 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(let xi = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) in label va_range1
"***** POSTCONDITION NOT MET AT line 308 column 63 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.Math.Poly2.Bits_s.to_quad32 xi == Vale.AES.GHash_BE.ghash_incremental h_BE y_prev data)
/\ label va_range1
"***** POSTCONDITION NOT MET AT line 309 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(xi == Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Math.Poly2.Bits_s.to_quad32 xi))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_ReduceLast h_BE y_prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ReduceLast (va_code_ReduceLast ()) va_s0 h_BE y_prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_vec 0 va_sM (va_update_ok va_sM va_s0))))))))));
va_lemma_norm_mods ([va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- GhashUnroll_n
[@ "opaque_to_smt" va_qattr]
let va_code_GhashUnroll_n exactly2 =
(va_Block (va_CCons (if exactly2 then va_Block (va_CCons (va_code_MulAdd_unroll_2way ()) (va_CNil
())) else va_Block (va_CCons (va_code_MulAdd_unroll_1way ()) (va_CNil ()))) (va_CCons
(va_code_Vspltisw (va_op_vec_opr_vec 8) 0) (va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg
10) (-15872)) (va_CCons (va_code_Mtvsrws (va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10))
(va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4)
(va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) 4)
(va_CCons (va_code_ReduceLast ()) (va_CNil ())))))))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_GhashUnroll_n exactly2 =
(va_pbool_and (if exactly2 then va_pbool_and (va_codegen_success_MulAdd_unroll_2way ()) (va_ttrue
()) else va_pbool_and (va_codegen_success_MulAdd_unroll_1way ()) (va_ttrue ())) (va_pbool_and
(va_codegen_success_Vspltisw (va_op_vec_opr_vec 8) 0) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 8) 4) (va_pbool_and (va_codegen_success_ReduceLast ()) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_GhashUnroll_n (va_mods:va_mods_t) (exactly2:bool) (in_b:buffer128) (index:nat)
(h_BE:quad32) (y_prev:quad32) (data:(seq quad32)) : (va_quickCode unit (va_code_GhashUnroll_n
exactly2)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in let
(prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in let (n:Prims.nat) = FStar.Seq.Base.length #quad32 data in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 361 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_qInlineIf va_mods exactly2 (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 363 column 27 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_MulAdd_unroll_2way in_b index h prev data) (va_QEmpty (())))) (qblock va_mods (fun
(va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 367 column 27 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_MulAdd_unroll_1way in_b index h prev data) (va_QEmpty (()))))) (fun (va_s:va_state)
va_g -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 369 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 8) 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 370 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (fun (va_s:va_state) _ -> let
(va_arg27:Vale.Def.Types_s.nat64) = (-15872) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 371 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg27 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 372 column 12 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 373 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 374 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) 4) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 375 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_ReduceLast h_BE y_prev data) (va_QEmpty (())))))))))))
[@"opaque_to_smt"]
let va_lemma_GhashUnroll_n va_b0 va_s0 exactly2 in_b index h_BE y_prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec
4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_GhashUnroll_n va_mods exactly2 in_b index h_BE y_prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_GhashUnroll_n exactly2) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 320 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in
let (prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in let (n:Prims.nat) = FStar.Seq.Base.length #quad32 data in label va_range1
"***** POSTCONDITION NOT MET AT line 359 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.GHash_BE.ghash_incremental h_BE y_prev data))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_GhashUnroll_n exactly2 in_b index h_BE y_prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_GhashUnroll_n (va_code_GhashUnroll_n exactly2) va_s0 exactly2 in_b
index h_BE y_prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM
(va_update_vec 8 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0))))))))))));
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Ghash_register
[@ "opaque_to_smt" va_qattr]
let va_code_Ghash_register () =
(va_Block (va_CCons (va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 5) Secret) (va_CCons (va_code_Vspltisw
(va_op_vec_opr_vec 0) 0) (va_CCons (va_code_VSwap (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5))
(va_CCons (va_code_High64ToLow (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 5)) (va_CCons
(va_code_Low64ToHigh (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 5)) (va_CCons (va_Block (va_CNil
())) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
9)) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 7)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 5)) (va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
9) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 8) 0) (va_CCons
(va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_CCons (va_code_Mtvsrws
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10)) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) 4) (va_CCons (va_code_ReduceLast ()) (va_CNil
()))))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Ghash_register () =
(va_pbool_and (va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 5) Secret) (va_pbool_and (va_codegen_success_Vspltisw
(va_op_vec_opr_vec 0) 0) (va_pbool_and (va_codegen_success_VSwap (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_High64ToLow (va_op_vec_opr_vec 7)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_Low64ToHigh (va_op_vec_opr_vec 6)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 9)) (va_pbool_and (va_codegen_success_VPolyMulLow
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 7)) (va_pbool_and
(va_codegen_success_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 8) 0)
(va_pbool_and (va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 8) 4) (va_pbool_and (va_codegen_success_ReduceLast ()) (va_ttrue
()))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Ghash_register (va_mods:va_mods_t) (hkeys_b:buffer128) (h_BE:quad32) (y_prev:quad32) :
(va_quickCode unit (va_code_Ghash_register ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in let
(data:(FStar.Seq.Base.seq quad32)) = FStar.Seq.Base.create #quad32 1 (va_get_vec 9 va_s) in let
(prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 405 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 0) (va_op_vec_opr_vec 5)
(va_op_reg_opr_reg 5) Secret hkeys_b 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 406 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 0) 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 407 column 10 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VSwap (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5)) (fun (va_s:va_state) _ -> let
(va_arg71:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 408 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_quad32_double va_arg71) (let
(va_arg70:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 409 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_double_swap va_arg70) (let
(va_arg69:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.swap (Vale.AES.GHash_BE.gf128_power h 1) 64
in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 410 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_quad32_double va_arg69) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 411 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_High64ToLow (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 5) (Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 412 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Low64ToHigh (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 5) (Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64)) (fun (va_s:va_state) _ -> let
(va_arg68:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 413 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32 va_arg68) (let
(va_arg67:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 414 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32 va_arg67) (va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 416 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(0 >= 0 /\ (fun a_336 (s_337:(FStar.Seq.Base.seq a_336)) (i_338:Prims.nat) -> let
(i_312:Prims.nat) = i_338 in Prims.b2t (Prims.op_LessThan i_312 (FStar.Seq.Base.length #a_336
s_337))) quad32 data 0) (fun _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 416 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_vec 9 va_s == FStar.Seq.Base.index #quad32 data 0) (let (data_i:poly) = pdata 0 in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 419 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power h 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 420 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 9)) (fun
(va_s:va_state) _ -> let (va_arg66:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 421 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg66) (let
(va_arg65:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 422 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg65 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 423 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 424 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg64:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg63:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 425 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg63 va_arg64) (let
(va_arg62:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 426 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg62 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 427 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg61:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg60:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 428 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg60 va_arg61) (let
(va_arg59:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 429 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg59 64) (let
(va_arg58:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 430 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg58 64) (let
(va_arg57:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 431 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg57) (let
(va_arg56:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 432 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg56 64) (let
(va_arg55:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 433 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg55 64) (let
(va_arg54:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg53:Vale.Math.Poly2_s.poly) = add prev data_i in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 434 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg53 va_arg54) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 436 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 8) 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 437 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (fun (va_s:va_state) _ -> let
(va_arg52:Vale.Def.Types_s.nat64) = (-15872) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 438 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg52 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 439 column 12 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 440 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 441 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) 4) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 442 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_ReduceLast h_BE y_prev data) (va_QEmpty (()))))))))))))))))))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Ghash_register va_b0 va_s0 hkeys_b h_BE y_prev =
let (va_mods:va_mods_t) = [va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 7; va_Mod_vec 6;
va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg
10; va_Mod_ok] in
let va_qc = va_qcode_Ghash_register va_mods hkeys_b h_BE y_prev in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Ghash_register ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 378 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in
let (data:(FStar.Seq.Base.seq quad32)) = FStar.Seq.Base.create #quad32 1 (va_get_vec 9 va_s0)
in let (prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in label va_range1
"***** POSTCONDITION NOT MET AT line 403 column 57 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.GHash_BE.ghash_incremental h_BE y_prev data))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 7; va_Mod_vec 6;
va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg
10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Ghash_register hkeys_b h_BE y_prev va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Ghash_register (va_code_Ghash_register ()) va_s0 hkeys_b h_BE
y_prev in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM
(va_update_vec 7 va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM
(va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))))))))))));
va_lemma_norm_mods ([va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 7; va_Mod_vec 6;
va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg
10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Ghash_buffer_loop_body
val va_code_Ghash_buffer_loop_body : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Ghash_buffer_loop_body () =
(va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_Block (va_CNil ())) (va_CCons
(va_code_GhashUnroll_n true) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_Block (va_CNil
())) (va_CCons (va_code_AddImm (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 7) 32) (va_CCons
(va_code_SubImm (va_op_reg_opr_reg 6) (va_op_reg_opr_reg 6) 2) (va_CNil ())))))))))
val va_codegen_success_Ghash_buffer_loop_body : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Ghash_buffer_loop_body () =
(va_pbool_and (va_codegen_success_GhashUnroll_n true) (va_pbool_and (va_codegen_success_AddImm
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 7) 32) (va_pbool_and (va_codegen_success_SubImm
(va_op_reg_opr_reg 6) (va_op_reg_opr_reg 6) 2) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Ghash_buffer_loop_body (va_mods:va_mods_t) (in_b:buffer128) (h_BE:quad32)
(y_prev:quad32) (old_len:nat64) (index:nat) : (va_quickCode unit (va_code_Ghash_buffer_loop_body
())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in let
(prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 501 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
((fun a_1582 (s_1583:(FStar.Seq.Base.seq a_1582)) (i_1584:Prims.nat) (j_1585:Prims.nat) -> let
(j_1545:Prims.nat) = j_1585 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1584
j_1545) (Prims.op_LessThanOrEqual j_1545 (FStar.Seq.Base.length #a_1582 s_1583))))
Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_s) in_b)) index (index + 2)) (fun _ -> let (data:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = FStar.Seq.Base.slice #Vale.Def.Types_s.quad32
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s)
in_b)) index (index + 2) in va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 502 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
((fun a_1582 (s_1583:(FStar.Seq.Base.seq a_1582)) (i_1584:Prims.nat) (j_1585:Prims.nat) -> let
(j_1545:Prims.nat) = j_1585 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1584
j_1545) (Prims.op_LessThanOrEqual j_1545 (FStar.Seq.Base.length #a_1582 s_1583))))
Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_s) in_b)) 0 index) (fun _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 502 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_GhashUnroll_n true in_b index h_BE (Vale.AES.GHash_BE.ghash_incremental0 h_BE y_prev
(FStar.Seq.Base.slice #Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s) in_b)) 0 index)) data) (fun
(va_s:va_state) _ -> va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 503 column 36 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
((fun a_1582 (s_1583:(FStar.Seq.Base.seq a_1582)) (i_1584:Prims.nat) (j_1585:Prims.nat) -> let
(j_1545:Prims.nat) = j_1585 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1584
j_1545) (Prims.op_LessThanOrEqual j_1545 (FStar.Seq.Base.length #a_1582 s_1583))))
Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_s) in_b)) 0 index) (fun _ -> let (va_arg27:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = FStar.Seq.Base.slice #Vale.Def.Types_s.quad32
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s)
in_b)) 0 index in let (va_arg26:Vale.Def.Types_s.quad32) = va_get_vec 1 va_s in let
(va_arg25:Vale.Def.Types_s.quad32) = va_get_vec 1 va_old_s in let
(va_arg24:Vale.Def.Types_s.quad32) = y_prev in let (va_arg23:Vale.Def.Types_s.quad32) = h_BE in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 503 column 36 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_ghash_incremental0_append va_arg23 va_arg24 va_arg25
va_arg26 va_arg27 data) (va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 505 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
((fun a_1582 (s_1583:(FStar.Seq.Base.seq a_1582)) (i_1584:Prims.nat) (j_1585:Prims.nat) -> let
(j_1545:Prims.nat) = j_1585 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1584
j_1545) (Prims.op_LessThanOrEqual j_1545 (FStar.Seq.Base.length #a_1582 s_1583))))
Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_s) in_b)) 0 index /\ (fun a_1582 (s_1583:(FStar.Seq.Base.seq a_1582))
(i_1584:Prims.nat) (j_1585:Prims.nat) -> let (j_1545:Prims.nat) = j_1585 in Prims.b2t
(Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1584 j_1545) (Prims.op_LessThanOrEqual j_1545
(FStar.Seq.Base.length #a_1582 s_1583)))) Vale.Def.Types_s.quad32
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s)
in_b)) 0 (index + 2)) (fun _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 505 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(FStar.Seq.Base.equal #Vale.Def.Types_s.quad32 (FStar.Seq.Base.append #Vale.Def.Types_s.quad32
(FStar.Seq.Base.slice #Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s) in_b)) 0 index) data)
(FStar.Seq.Base.slice #Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s) in_b)) 0 (index + 2))) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 507 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_AddImm (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 7) 32) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 508 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_SubImm (va_op_reg_opr_reg 6) (va_op_reg_opr_reg 6) 2) (va_QEmpty (()))))))))))))
val va_lemma_Ghash_buffer_loop_body : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 ->
h_BE:quad32 -> y_prev:quad32 -> old_len:nat64 -> index:nat
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Ghash_buffer_loop_body ()) va_s0 /\ va_get_ok va_s0 /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in let
(prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in va_get_reg 6 va_s0
>= 2 /\ index + va_get_reg 6 va_s0 == old_len /\ Vale.PPC64LE.Decls.validSrcAddrsOffset128
(va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0) in_b index (va_get_reg 6 va_s0)
(va_get_mem_layout va_s0) Secret /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b == old_len /\ va_get_reg 7 va_s0 + 16 `op_Multiply`
va_get_reg 6 va_s0 < pow2_64 /\ va_get_vec 1 va_s0 == Vale.AES.GHash_BE.ghash_incremental0 h_BE
y_prev (FStar.Seq.Base.slice #Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)) 0 index) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in let
(prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let index' = index +
2 in index' + va_get_reg 6 va_sM == old_len /\ Vale.PPC64LE.Decls.validSrcAddrsOffset128
(va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM) in_b index' (va_get_reg 6 va_sM)
(va_get_mem_layout va_sM) Secret /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b == old_len /\ va_get_reg 7 va_sM + 16 `op_Multiply`
va_get_reg 6 va_sM < pow2_64 /\ va_get_vec 1 va_sM == Vale.AES.GHash_BE.ghash_incremental0 h_BE
y_prev (FStar.Seq.Base.slice #Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) in_b)) 0 index') /\ va_get_reg 7 va_sM ==
va_get_reg 7 va_s0 + 32 /\ va_get_reg 6 va_sM == va_get_reg 6 va_s0 - 2) /\ va_state_eq va_sM
(va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_reg 6 va_sM (va_update_reg 7 va_sM
(va_update_ok va_sM va_s0)))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Ghash_buffer_loop_body va_b0 va_s0 in_b h_BE y_prev old_len index =
let (va_mods:va_mods_t) = [va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec
4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 6;
va_Mod_reg 7; va_Mod_ok] in
let va_qc = va_qcode_Ghash_buffer_loop_body va_mods in_b h_BE y_prev old_len index in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Ghash_buffer_loop_body ()) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 445 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in
let (prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in label va_range1
"***** POSTCONDITION NOT MET AT line 487 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(let index' = index + 2 in label va_range1
"***** POSTCONDITION NOT MET AT line 489 column 32 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(index' + va_get_reg 6 va_sM == old_len) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 492 column 84 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM)
in_b index' (va_get_reg 6 va_sM) (va_get_mem_layout va_sM) Secret) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 493 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b == old_len) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 494 column 38 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_reg 7 va_sM + 16 `op_Multiply` va_get_reg 6 va_sM < pow2_64) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 495 column 110 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.GHash_BE.ghash_incremental0 h_BE y_prev (FStar.Seq.Base.slice
#Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_sM) in_b)) 0 index')) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 498 column 37 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_reg 7 va_sM == va_get_reg 7 va_s0 + 32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 499 column 28 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_reg 6 va_sM == va_get_reg 6 va_s0 - 2)))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 6; va_Mod_reg
7; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Ghash_buffer_loop_body (in_b:buffer128) (h_BE:quad32) (y_prev:quad32) (old_len:nat64)
(index:nat) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in
let (prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in va_get_reg 6
va_s0 >= 2 /\ index + va_get_reg 6 va_s0 == old_len /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
in_b index (va_get_reg 6 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b == old_len /\ va_get_reg 7
va_s0 + 16 `op_Multiply` va_get_reg 6 va_s0 < pow2_64 /\ va_get_vec 1 va_s0 ==
Vale.AES.GHash_BE.ghash_incremental0 h_BE y_prev (FStar.Seq.Base.slice #Vale.Def.Types_s.quad32
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
in_b)) 0 index) /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) ==
Vale.Math.Poly2.swap (Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 6 va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) ==
Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64)) /\ (forall (va_x_r7:nat64)
(va_x_r6:nat64) (va_x_r10:nat64) (va_x_v0:quad32) (va_x_v1:quad32) (va_x_v2:quad32)
(va_x_v3:quad32) (va_x_v4:quad32) (va_x_v8:quad32) (va_x_v9:quad32) (va_x_v10:quad32)
(va_x_v11:quad32) . let va_sM = va_upd_vec 11 va_x_v11 (va_upd_vec 10 va_x_v10 (va_upd_vec 9
va_x_v9 (va_upd_vec 8 va_x_v8 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2
(va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 (va_upd_reg 6 va_x_r6
(va_upd_reg 7 va_x_r7 va_s0))))))))))) in va_get_ok va_sM /\ (let (h:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 h_BE in let (prev:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let index' = index + 2 in index' + va_get_reg 6
va_sM == old_len /\ Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_sM)
(va_get_reg 7 va_sM) in_b index' (va_get_reg 6 va_sM) (va_get_mem_layout va_sM) Secret /\
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b == old_len /\ va_get_reg 7
va_sM + 16 `op_Multiply` va_get_reg 6 va_sM < pow2_64 /\ va_get_vec 1 va_sM ==
Vale.AES.GHash_BE.ghash_incremental0 h_BE y_prev (FStar.Seq.Base.slice #Vale.Def.Types_s.quad32
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
in_b)) 0 index') /\ va_get_reg 7 va_sM == va_get_reg 7 va_s0 + 32 /\ va_get_reg 6 va_sM ==
va_get_reg 6 va_s0 - 2) ==> va_k va_sM (())))
val va_wpProof_Ghash_buffer_loop_body : in_b:buffer128 -> h_BE:quad32 -> y_prev:quad32 ->
old_len:nat64 -> index:nat -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Ghash_buffer_loop_body in_b h_BE y_prev old_len index
va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Ghash_buffer_loop_body ())
([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 6; va_Mod_reg 7]) va_s0
va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Ghash_buffer_loop_body in_b h_BE y_prev old_len index va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Ghash_buffer_loop_body (va_code_Ghash_buffer_loop_body ()) va_s0
in_b h_BE y_prev old_len index in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM
(va_update_vec 8 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_reg 6 va_sM
(va_update_reg 7 va_sM (va_update_ok va_sM va_s0))))))))))))));
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 6; va_Mod_reg
7]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Ghash_buffer_loop_body (in_b:buffer128) (h_BE:quad32) (y_prev:quad32) (old_len:nat64)
(index:nat) : (va_quickCode unit (va_code_Ghash_buffer_loop_body ())) =
(va_QProc (va_code_Ghash_buffer_loop_body ()) ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9;
va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg
10; va_Mod_reg 6; va_Mod_reg 7]) (va_wp_Ghash_buffer_loop_body in_b h_BE y_prev old_len index)
(va_wpProof_Ghash_buffer_loop_body in_b h_BE y_prev old_len index))
//--
//-- Mod_cr0
val va_code_Mod_cr0 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Mod_cr0 () =
(va_Block (va_CNil ()))
val va_codegen_success_Mod_cr0 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Mod_cr0 () =
(va_ttrue ())
[@ "opaque_to_smt" va_qattr]
let va_qcode_Mod_cr0 (va_mods:va_mods_t) : (va_quickCode unit (va_code_Mod_cr0 ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QEmpty (())))
val va_lemma_Mod_cr0 : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Mod_cr0 ()) va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_state_eq va_sM (va_update_cr0 va_sM (va_update_ok va_sM va_s0))))
[@"opaque_to_smt"]
let va_lemma_Mod_cr0 va_b0 va_s0 =
let (va_mods:va_mods_t) = [va_Mod_cr0; va_Mod_ok] in
let va_qc = va_qcode_Mod_cr0 va_mods in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Mod_cr0 ()) va_qc va_s0 (fun va_s0
va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 511 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM)) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_cr0; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Mod_cr0 (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (forall (va_x_cr0:cr0_t) . let va_sM = va_upd_cr0 va_x_cr0 va_s0 in va_get_ok
va_sM ==> va_k va_sM (())))
val va_wpProof_Mod_cr0 : va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Mod_cr0 va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Mod_cr0 ()) ([va_Mod_cr0]) va_s0 va_k
((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Mod_cr0 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mod_cr0 (va_code_Mod_cr0 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_cr0 va_sM (va_update_ok va_sM va_s0)));
va_lemma_norm_mods ([va_Mod_cr0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Mod_cr0 () : (va_quickCode unit (va_code_Mod_cr0 ())) =
(va_QProc (va_code_Mod_cr0 ()) ([va_Mod_cr0]) va_wp_Mod_cr0 va_wpProof_Mod_cr0)
//--
//-- Ghash_buffer_body0
val va_code_Ghash_buffer_body0 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Ghash_buffer_body0 () =
(va_Block (va_CCons (va_code_Mod_cr0 ()) (va_CCons (va_code_Ghash_buffer_loop_body ()) (va_CNil
()))))
val va_codegen_success_Ghash_buffer_body0 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Ghash_buffer_body0 () =
(va_pbool_and (va_codegen_success_Mod_cr0 ()) (va_pbool_and
(va_codegen_success_Ghash_buffer_loop_body ()) (va_ttrue ())))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Ghash_buffer_body0 (va_mods:va_mods_t) (va_old:va_state) (va_in_h:poly)
(va_in_h_BE:quad32) (va_in_in_b:buffer128) (va_in_y_prev:quad32) (va_in_index:nat) :
(va_quickCode (nat) (va_code_Ghash_buffer_body0 ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (h:poly) = va_in_h
in let (h_BE:quad32) = va_in_h_BE in let (in_b:buffer128) = va_in_in_b in let (y_prev:quad32) =
va_in_y_prev in let (index:nat) = va_in_index in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 595 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Mod_cr0 ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 596 column 31 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Ghash_buffer_loop_body in_b h_BE y_prev (va_get_reg 6 va_old) index) (fun
(va_s:va_state) _ -> let (index:nat) = index + 2 in va_QEmpty ((index))))))
val va_lemma_Ghash_buffer_body0 : va_b0:va_code -> va_s0:va_state -> va_old:va_state ->
va_in_h:poly -> va_in_h_BE:quad32 -> va_in_in_b:buffer128 -> va_in_y_prev:quad32 ->
va_in_index:nat
-> Ghost (va_state & va_fuel & nat)
(requires (va_require_total va_b0 (va_code_Ghash_buffer_body0 ()) va_s0 /\ va_get_ok va_s0 /\
va_in_index + va_get_reg 6 va_s0 == va_get_reg 6 va_old /\ va_get_reg 7 va_s0 == va_get_reg 7
va_old + 16 `op_Multiply` va_in_index /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0)
== Vale.Math.Poly2.swap (Vale.AES.GHash_BE.gf128_power va_in_h 1) 64 /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0) == Vale.Math.Poly2_s.mul
(Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power va_in_h 1) (Vale.Math.Poly2_s.monomial
64)) (Vale.Math.Poly2_s.monomial 64) /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0)
== Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power va_in_h 1) (Vale.Math.Poly2_s.monomial
64) /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power va_in_h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power va_in_h
2) (Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power va_in_h 2) (Vale.Math.Poly2_s.monomial 64) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
va_in_in_b va_in_index (va_get_reg 6 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_in_b == va_get_reg 6
va_old /\ va_get_reg 7 va_s0 + 16 `op_Multiply` va_get_reg 6 va_s0 < pow2_64 /\ va_get_vec 1
va_s0 == Vale.AES.GHash_BE.ghash_incremental0 va_in_h_BE va_in_y_prev (FStar.Seq.Base.slice
#Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_s0) va_in_in_b)) 0 va_in_index) /\ (va_get_reg 6 va_old == 0 ==>
va_get_vec 1 va_s0 == va_get_vec 1 va_old) /\ va_in_h == Vale.Math.Poly2.Bits_s.of_quad32
va_in_h_BE /\ va_get_reg 6 va_s0 >= 2))
(ensures (fun (va_sM, va_fM, index) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM
/\ index + va_get_reg 6 va_sM == va_get_reg 6 va_old /\ va_get_reg 7 va_sM == va_get_reg 7
va_old + 16 `op_Multiply` index /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_sM) ==
Vale.Math.Poly2.swap (Vale.AES.GHash_BE.gf128_power va_in_h 1) 64 /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_sM) == Vale.Math.Poly2_s.mul
(Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power va_in_h 1) (Vale.Math.Poly2_s.monomial
64)) (Vale.Math.Poly2_s.monomial 64) /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_sM)
== Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power va_in_h 1) (Vale.Math.Poly2_s.monomial
64) /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_sM) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power va_in_h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_sM) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power va_in_h
2) (Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_sM) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power va_in_h 2) (Vale.Math.Poly2_s.monomial 64) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM)
va_in_in_b index (va_get_reg 6 va_sM) (va_get_mem_layout va_sM) Secret /\
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_in_b == va_get_reg 6
va_old /\ va_get_reg 7 va_sM + 16 `op_Multiply` va_get_reg 6 va_sM < pow2_64 /\ va_get_vec 1
va_sM == Vale.AES.GHash_BE.ghash_incremental0 va_in_h_BE va_in_y_prev (FStar.Seq.Base.slice
#Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_sM) va_in_in_b)) 0 index) /\ (va_get_reg 6 va_old == 0 ==> va_get_vec
1 va_sM == va_get_vec 1 va_old) /\ va_in_h == Vale.Math.Poly2.Bits_s.of_quad32 va_in_h_BE /\
precedes_wrap (va_get_reg 6 va_sM) (va_get_reg 6 va_s0) /\ va_state_eq va_sM (va_update_vec 9
va_sM (va_update_vec 8 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2
va_sM (va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 1 va_sM (va_update_vec 0
va_sM (va_update_reg 7 va_sM (va_update_reg 6 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
(va_update_cr0 va_sM va_s0))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Ghash_buffer_body0 va_b0 va_s0 va_old va_in_h va_in_h_BE va_in_in_b va_in_y_prev
va_in_index =
let va_old = va_expand_state va_old in
let (va_mods:va_mods_t) = [va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 7; va_Mod_reg 6;
va_Mod_reg 10; va_Mod_ok; va_Mod_cr0] in
let va_qc = va_qcode_Ghash_buffer_body0 va_mods va_old va_in_h va_in_h_BE va_in_in_b va_in_y_prev
va_in_index in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Ghash_buffer_body0 ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let index = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 517 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 575 column 36 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(index + va_get_reg 6 va_sM == va_get_reg 6 va_old) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 576 column 49 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_reg 7 va_sM == va_get_reg 7 va_old + 16 `op_Multiply` index) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 579 column 60 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_sM) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power va_in_h 1) 64) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 580 column 88 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_sM) == Vale.Math.Poly2_s.mul
(Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power va_in_h 1) (Vale.Math.Poly2_s.monomial
64)) (Vale.Math.Poly2_s.monomial 64)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 581 column 69 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_sM) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power va_in_h 1) (Vale.Math.Poly2_s.monomial 64)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 582 column 60 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_sM) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power va_in_h 2) 64) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 583 column 88 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13 va_sM) == Vale.Math.Poly2_s.mul
(Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power va_in_h 2) (Vale.Math.Poly2_s.monomial
64)) (Vale.Math.Poly2_s.monomial 64)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 584 column 69 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_sM) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power va_in_h 2) (Vale.Math.Poly2_s.monomial 64)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 585 column 87 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM)
va_in_in_b index (va_get_reg 6 va_sM) (va_get_mem_layout va_sM) Secret) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 586 column 44 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_in_b == va_get_reg 6
va_old) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 587 column 42 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_reg 7 va_sM + 16 `op_Multiply` va_get_reg 6 va_sM < pow2_64) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 588 column 113 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.GHash_BE.ghash_incremental0 va_in_h_BE va_in_y_prev
(FStar.Seq.Base.slice #Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) va_in_in_b)) 0 index)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 589 column 44 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_reg 6 va_old == 0 ==> va_get_vec 1 va_sM == va_get_vec 1 va_old) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 590 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_in_h == Vale.Math.Poly2.Bits_s.of_quad32 va_in_h_BE) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 592 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(precedes_wrap (va_get_reg 6 va_sM) (va_get_reg 6 va_s0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 7; va_Mod_reg 6;
va_Mod_reg 10; va_Mod_ok; va_Mod_cr0]) va_sM va_s0;
let index = va_g in
(va_sM, va_fM, index)
[@ va_qattr]
let va_wp_Ghash_buffer_body0 (va_old:va_state) (va_in_h:poly) (va_in_h_BE:quad32)
(va_in_in_b:buffer128) (va_in_y_prev:quad32) (va_in_index:nat) (va_s0:va_state) (va_k:(va_state
-> nat -> Type0)) : Type0 =
(va_get_ok va_s0 /\ va_in_index + va_get_reg 6 va_s0 == va_get_reg 6 va_old /\ va_get_reg 7 va_s0
== va_get_reg 7 va_old + 16 `op_Multiply` va_in_index /\ Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 5 va_s0) == Vale.Math.Poly2.swap (Vale.AES.GHash_BE.gf128_power va_in_h 1) 64 /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0) == Vale.Math.Poly2_s.mul
(Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power va_in_h 1) (Vale.Math.Poly2_s.monomial
64)) (Vale.Math.Poly2_s.monomial 64) /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0)
== Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power va_in_h 1) (Vale.Math.Poly2_s.monomial
64) /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power va_in_h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power va_in_h
2) (Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power va_in_h 2) (Vale.Math.Poly2_s.monomial 64) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
va_in_in_b va_in_index (va_get_reg 6 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_in_b == va_get_reg 6
va_old /\ va_get_reg 7 va_s0 + 16 `op_Multiply` va_get_reg 6 va_s0 < pow2_64 /\ va_get_vec 1
va_s0 == Vale.AES.GHash_BE.ghash_incremental0 va_in_h_BE va_in_y_prev (FStar.Seq.Base.slice
#Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_s0) va_in_in_b)) 0 va_in_index) /\ (va_get_reg 6 va_old == 0 ==>
va_get_vec 1 va_s0 == va_get_vec 1 va_old) /\ va_in_h == Vale.Math.Poly2.Bits_s.of_quad32
va_in_h_BE /\ va_get_reg 6 va_s0 >= 2 /\ (forall (va_x_cr0:cr0_t) (va_x_ok:bool)
(va_x_r10:nat64) (va_x_r6:nat64) (va_x_r7:nat64) (va_x_v0:quad32) (va_x_v1:quad32)
(va_x_v10:quad32) (va_x_v11:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32)
(va_x_v8:quad32) (va_x_v9:quad32) (index:nat) . let va_sM = va_upd_vec 9 va_x_v9 (va_upd_vec 8
va_x_v8 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 11
va_x_v11 (va_upd_vec 10 va_x_v10 (va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0 (va_upd_reg 7
va_x_r7 (va_upd_reg 6 va_x_r6 (va_upd_reg 10 va_x_r10 (va_upd_ok va_x_ok (va_upd_cr0 va_x_cr0
va_s0))))))))))))) in va_get_ok va_sM /\ index + va_get_reg 6 va_sM == va_get_reg 6 va_old /\
va_get_reg 7 va_sM == va_get_reg 7 va_old + 16 `op_Multiply` index /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_sM) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power va_in_h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6
va_sM) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power va_in_h
1) (Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_sM) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power va_in_h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_sM) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power va_in_h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_sM) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power va_in_h
2) (Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_sM) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power va_in_h 2) (Vale.Math.Poly2_s.monomial 64) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM)
va_in_in_b index (va_get_reg 6 va_sM) (va_get_mem_layout va_sM) Secret /\
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_in_b == va_get_reg 6
va_old /\ va_get_reg 7 va_sM + 16 `op_Multiply` va_get_reg 6 va_sM < pow2_64 /\ va_get_vec 1
va_sM == Vale.AES.GHash_BE.ghash_incremental0 va_in_h_BE va_in_y_prev (FStar.Seq.Base.slice
#Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_sM) va_in_in_b)) 0 index) /\ (va_get_reg 6 va_old == 0 ==> va_get_vec
1 va_sM == va_get_vec 1 va_old) /\ va_in_h == Vale.Math.Poly2.Bits_s.of_quad32 va_in_h_BE /\
precedes_wrap (va_get_reg 6 va_sM) (va_get_reg 6 va_s0) ==> va_k va_sM ((index))))
val va_wpProof_Ghash_buffer_body0 : va_old:va_state -> va_in_h:poly -> va_in_h_BE:quad32 ->
va_in_in_b:buffer128 -> va_in_y_prev:quad32 -> va_in_index:nat -> va_s0:va_state ->
va_k:(va_state -> nat -> Type0)
-> Ghost (va_state & va_fuel & nat)
(requires (va_t_require va_s0 /\ va_wp_Ghash_buffer_body0 va_old va_in_h va_in_h_BE va_in_in_b
va_in_y_prev va_in_index va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Ghash_buffer_body0 ()) ([va_Mod_vec 9;
va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 11; va_Mod_vec 10;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 7; va_Mod_reg 6; va_Mod_reg 10; va_Mod_ok; va_Mod_cr0])
va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Ghash_buffer_body0 va_old va_in_h va_in_h_BE va_in_in_b va_in_y_prev va_in_index
va_s0 va_k =
let (va_sM, va_f0, index) = va_lemma_Ghash_buffer_body0 (va_code_Ghash_buffer_body0 ()) va_s0
va_old va_in_h va_in_h_BE va_in_in_b va_in_y_prev va_in_index in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM (va_update_vec 4 va_sM
(va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 11 va_sM (va_update_vec 10 va_sM
(va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 7 va_sM (va_update_reg 6 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM (va_update_cr0 va_sM va_s0)))))))))))))));
va_lemma_norm_mods ([va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 7; va_Mod_reg 6;
va_Mod_reg 10; va_Mod_ok; va_Mod_cr0]) va_sM va_s0;
let va_g = (index) in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Ghash_buffer_body0 (va_old:va_state) (va_in_h:poly) (va_in_h_BE:quad32)
(va_in_in_b:buffer128) (va_in_y_prev:quad32) (va_in_index:nat) : (va_quickCode nat
(va_code_Ghash_buffer_body0 ())) =
(va_QProc (va_code_Ghash_buffer_body0 ()) ([va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec
3; va_Mod_vec 2; va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 7;
va_Mod_reg 6; va_Mod_reg 10; va_Mod_ok; va_Mod_cr0]) (va_wp_Ghash_buffer_body0 va_old va_in_h
va_in_h_BE va_in_in_b va_in_y_prev va_in_index) (va_wpProof_Ghash_buffer_body0 va_old va_in_h
va_in_h_BE va_in_in_b va_in_y_prev va_in_index))
//--
//-- Ghash_buffer_while0
val va_code_Ghash_buffer_while0 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Ghash_buffer_while0 () =
(va_Block (va_CCons (va_While (va_cmp_ge (va_op_cmp_reg 6) (va_const_cmp 2)) (va_Block (va_CCons
(va_code_Ghash_buffer_body0 ()) (va_CNil ())))) (va_CNil ())))
val va_codegen_success_Ghash_buffer_while0 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr] | false | true | Vale.AES.PPC64LE.GHash.fst | {
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_codegen_success_Ghash_buffer_while0 : va_dummy:unit -> Tot va_pbool | [] | Vale.AES.PPC64LE.GHash.va_codegen_success_Ghash_buffer_while0 | {
"file_name": "obj/Vale.AES.PPC64LE.GHash.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_dummy: Prims.unit -> Vale.PPC64LE.Decls.va_pbool | {
"end_col": 73,
"end_line": 1631,
"start_col": 2,
"start_line": 1631
} |
Prims.Tot | val va_codegen_success_Mod_cr0 : va_dummy:unit -> Tot va_pbool | [
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math // For lemma_poly_bits64()",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_codegen_success_Mod_cr0 () =
(va_ttrue ()) | val va_codegen_success_Mod_cr0 : va_dummy:unit -> Tot va_pbool
let va_codegen_success_Mod_cr0 () = | false | null | false | (va_ttrue ()) | {
"checked_file": "Vale.AES.PPC64LE.GHash.fst.checked",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.GCTR_BE.fsti.checked",
"Vale.AES.GCM_helpers_BE.fsti.checked",
"Vale.AES.AES_helpers.fsti.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GHash.fst"
} | [
"total"
] | [
"Prims.unit",
"Vale.PPC64LE.Decls.va_ttrue",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | module Vale.AES.PPC64LE.GHash
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.AES_helpers
open Vale.Poly1305.Math // For lemma_poly_bits64()
open Vale.AES.GCM_helpers_BE
open Vale.AES.GCTR_BE_s
open Vale.AES.GCTR_BE
open Vale.Arch.TypesNative
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
#reset-options "--z3rlimit 50"
//-- MulAdd_unroll_1way
val va_code_MulAdd_unroll_1way : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_MulAdd_unroll_1way () =
(va_Block (va_CCons (va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_CCons (va_code_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_CCons
(va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5))
(va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
6)) (va_CNil ())))))))
val va_codegen_success_MulAdd_unroll_1way : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_MulAdd_unroll_1way () =
(va_pbool_and (va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_pbool_and
(va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
7)) (va_pbool_and (va_codegen_success_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (va_ttrue ()))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_MulAdd_unroll_1way (va_mods:va_mods_t) (in_b:buffer128) (index:nat) (h:poly)
(prev:poly) (data:(seq quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_1way ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (pdata:(Prims.int
-> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in let
(data_i:poly) = pdata 0 in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 136 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret in_b index) (fun (va_s:va_state) _ -> let
(va_arg44:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 138 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg44 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 139 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg43:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 140 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg43) (let
(va_arg42:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 141 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg42 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 142 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 143 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg41:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg40:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 144 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg40 va_arg41) (let
(va_arg39:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 145 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg39 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 146 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg38:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg37:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 147 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg37 va_arg38) (let
(va_arg36:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 148 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg36 64) (let
(va_arg35:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 149 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg35 64) (let
(va_arg34:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 150 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg34) (let
(va_arg33:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 151 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg33 64) (let
(va_arg32:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 152 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg32 64) (let
(va_arg31:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg30:Vale.Math.Poly2_s.poly) = add prev data_i in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 153 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg30 va_arg31) (va_QEmpty
(()))))))))))))))))))))
val va_lemma_MulAdd_unroll_1way : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 -> index:nat ->
h:poly -> prev:poly -> data:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_MulAdd_unroll_1way ()) va_s0 /\ va_get_ok va_s0 /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 1 /\
in_b_blocks in_b index 1 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0) /\ va_state_eq va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_ok va_sM va_s0)))))))
[@"opaque_to_smt"]
let va_lemma_MulAdd_unroll_1way va_b0 va_s0 in_b index h prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_MulAdd_unroll_1way va_mods in_b index h prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_MulAdd_unroll_1way ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 106 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in label va_range1
"***** POSTCONDITION NOT MET AT line 133 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_ok]) va_sM
va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_MulAdd_unroll_1way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq quad32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 1 /\
in_b_blocks in_b index 1 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64)) /\ (forall
(va_x_v0:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) . let va_sM = va_upd_vec 4
va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 va_s0))) in va_get_ok
va_sM /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0) ==> va_k va_sM (())))
val va_wpProof_MulAdd_unroll_1way : in_b:buffer128 -> index:nat -> h:poly -> prev:poly -> data:(seq
quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_MulAdd_unroll_1way in_b index h prev data va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_MulAdd_unroll_1way ()) ([va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_MulAdd_unroll_1way in_b index h prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_MulAdd_unroll_1way (va_code_MulAdd_unroll_1way ()) va_s0 in_b index
h prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 0 va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_MulAdd_unroll_1way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq
quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_1way ())) =
(va_QProc (va_code_MulAdd_unroll_1way ()) ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec
0]) (va_wp_MulAdd_unroll_1way in_b index h prev data) (va_wpProof_MulAdd_unroll_1way in_b index
h prev data))
//--
//-- MulAdd_unroll_2way
val va_code_MulAdd_unroll_2way : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_MulAdd_unroll_2way () =
(va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_CCons
(va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret) (va_CCons (va_code_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg
10) Secret) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 7)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 5)) (va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
8) (va_op_vec_opr_vec 6)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 0)) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec
10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (va_CCons (va_code_VPolyMulHigh
(va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 13)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 11)) (va_CNil
())))))))))))))))
val va_codegen_success_MulAdd_unroll_2way : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_MulAdd_unroll_2way () =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret) (va_pbool_and (va_codegen_success_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg
10) Secret) (va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 8) (va_op_vec_opr_vec 7)) (va_pbool_and (va_codegen_success_VPolyMul
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec
6)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 0)) (va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14)) (va_pbool_and (va_codegen_success_VPolyMul
(va_op_vec_opr_vec 10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (va_pbool_and
(va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 13)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_pbool_and
(va_codegen_success_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
11)) (va_ttrue ()))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_MulAdd_unroll_2way (va_mods:va_mods_t) (in_b:buffer128) (index:nat) (h:poly)
(prev:poly) (data:(seq quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_2way ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (pdata:(Prims.int
-> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in let
(data_0:poly) = pdata 0 in let (data_1:poly) = pdata 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 196 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 197 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret in_b index) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 198 column 32 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 10) Secret in_b (index + 1)) (fun (va_s:va_state) _ ->
let (va_arg95:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 200 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg95 1) (let
(va_arg94:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 201 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg94) (let
(va_arg93:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 202 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg93 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 203 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 204 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg92:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg91:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 205 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg91 va_arg92) (let
(va_arg90:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 206 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg90 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 207 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg89:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg88:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 208 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg88 va_arg89) (let
(va_arg87:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 209 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg87 64) (let
(va_arg86:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 210 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg86 64) (let
(va_arg85:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 211 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg85) (let
(va_arg84:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 212 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg84 64) (let
(va_arg83:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 213 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg83 64) (let
(va_arg82:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg81:Vale.Math.Poly2_s.poly) = data_1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 214 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg81 va_arg82) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 215 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 0) (let (va_arg80:Vale.Math.Poly2_s.poly)
= h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 218 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg80 2) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 219 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg79:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 220 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg79) (let
(va_arg78:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 221 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg78 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 222 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 223 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (fun
(va_s:va_state) _ -> let (va_arg77:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg76:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
2) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 224 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg76 va_arg77) (let
(va_arg75:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 225 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg75 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 226 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 13))
(fun (va_s:va_state) _ -> let (va_arg74:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64
in let (va_arg73:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 227 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg73 va_arg74) (let
(va_arg72:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 228 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg72 64) (let
(va_arg71:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 229 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg71 64) (let
(va_arg70:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 230 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg70) (let
(va_arg69:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 231 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg69 64) (let
(va_arg68:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 232 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg68 64) (let
(va_arg67:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift (add prev
data_0) (-64)) (Vale.Math.Poly2.mask (Vale.AES.GHash_BE.gf128_power h 2) 64) in let
(va_arg66:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask (add prev
data_0) 64) (Vale.Math.Poly2_s.shift (Vale.AES.GHash_BE.gf128_power h 2) (-64)) in let
(va_arg65:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec 3 va_s) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 233 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_add_associate va_arg65 va_arg66 va_arg67) (let
(va_arg64:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in let
(va_arg63:Vale.Math.Poly2_s.poly) = add prev data_0 in let (va_arg62:Vale.Math.Poly2_s.poly) =
of_quad32 (va_get_vec 4 va_s) in let (va_arg61:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec
3 va_s) in let (va_arg60:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec 2 va_s) in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 236 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128_accum va_arg60 va_arg61 va_arg62 va_arg63
va_arg64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 237 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 238 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 239 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 11))
(va_QEmpty (()))))))))))))))))))))))))))))))))))))))))))
val va_lemma_MulAdd_unroll_2way : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 -> index:nat ->
h:poly -> prev:poly -> data:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_MulAdd_unroll_2way ()) va_s0 /\ va_get_ok va_s0 /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 2 /\
in_b_blocks in_b index 2 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1) /\ va_state_eq va_sM
(va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))))))))))
[@"opaque_to_smt"]
let va_lemma_MulAdd_unroll_2way va_b0 va_s0 in_b index h prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec
4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_MulAdd_unroll_2way va_mods in_b index h prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_MulAdd_unroll_2way ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 156 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in label va_range1
"***** POSTCONDITION NOT MET AT line 192 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_MulAdd_unroll_2way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq quad32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 2 /\
in_b_blocks in_b index 2 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64)) /\ (forall
(va_x_r10:nat64) (va_x_v0:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32)
(va_x_v8:quad32) (va_x_v9:quad32) (va_x_v10:quad32) (va_x_v11:quad32) . let va_sM = va_upd_vec
11 va_x_v11 (va_upd_vec 10 va_x_v10 (va_upd_vec 9 va_x_v9 (va_upd_vec 8 va_x_v8 (va_upd_vec 4
va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 (va_upd_reg 10
va_x_r10 va_s0)))))))) in va_get_ok va_sM /\ (let (pdata:(Prims.int ->
Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1) ==> va_k va_sM (())))
val va_wpProof_MulAdd_unroll_2way : in_b:buffer128 -> index:nat -> h:poly -> prev:poly -> data:(seq
quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_MulAdd_unroll_2way in_b index h prev data va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_MulAdd_unroll_2way ()) ([va_Mod_vec
11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 0; va_Mod_reg 10]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_MulAdd_unroll_2way in_b index h prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_MulAdd_unroll_2way (va_code_MulAdd_unroll_2way ()) va_s0 in_b index
h prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM
(va_update_vec 8 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM va_s0)))))))))));
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_MulAdd_unroll_2way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq
quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_2way ())) =
(va_QProc (va_code_MulAdd_unroll_2way ()) ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9;
va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10])
(va_wp_MulAdd_unroll_2way in_b index h prev data) (va_wpProof_MulAdd_unroll_2way in_b index h
prev data))
//--
//-- Reduce
val va_code_Reduce : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Reduce () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 0) 0) (va_CCons (va_code_Low64ToHigh
(va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_CCons (va_code_VSwap (va_op_vec_opr_vec 10)
(va_op_vec_opr_vec 2)) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
2) (va_op_vec_opr_vec 8)) (va_CCons (va_code_High64ToLow (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 10)) (va_CCons (va_code_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2))
(va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
8)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
2)) (va_CNil ()))))))))))))))
val va_codegen_success_Reduce : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Reduce () =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 0) 0) (va_pbool_and
(va_codegen_success_Low64ToHigh (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9))
(va_pbool_and (va_codegen_success_VSwap (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 2))
(va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 8)) (va_pbool_and (va_codegen_success_High64ToLow (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 3)) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 10)) (va_pbool_and
(va_codegen_success_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_pbool_and
(va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
8)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_ttrue ())))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Reduce (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_Reduce ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in let
(c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in
let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 265 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 0) 0) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 266 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod a1 64) (let
(va_arg39:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.mask a1 64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 267 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_is_mul va_arg39 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 268 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Low64ToHigh (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3) a1) (fun (va_s:va_state) _ ->
let (va_arg38:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift (Vale.Math.Poly2.mask a1 64) 64
in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 269 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32 va_arg38) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 270 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 271 column 10 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VSwap (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 2)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 272 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 273 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div a1 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 274 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_High64ToLow (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) a1) (fun (va_s:va_state) _ ->
let (va_arg37:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift a1 (-64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 275 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32 va_arg37) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 276 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 3)) (fun
(va_s:va_state) _ -> let (va_arg36:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 10 va_s) in let (va_arg35:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 277 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_add_commute va_arg35 va_arg36) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 278 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 10)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 279 column 10 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 280 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 281 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 4)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 282 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (fun
(va_s:va_state) _ -> let (va_arg34:Vale.Math.Poly2_s.poly) = f in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 283 column 21 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_reduce_rev a0 a1 a2 va_arg34 64) (va_QEmpty
(()))))))))))))))))))))))
val va_lemma_Reduce : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Reduce ()) va_s0 /\ va_get_ok va_s0 /\ (let
(g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in let
(c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in
let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) (-64) == zero /\ Vale.Math.Poly2.mask (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) 64 == c /\ Vale.Math.Poly2_s.degree f < 64 /\ Vale.Math.Poly2_s.degree g
== 128 /\ Vale.Math.Poly2_s.poly_index f 0)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in let
(c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in
let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) ==
Vale.Math.Poly2_s.reverse (mod (Vale.Math.Poly2_s.reverse a 255) g) 127) /\ va_state_eq va_sM
(va_update_vec 1 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 9 va_sM
(va_update_vec 2 va_sM (va_update_vec 8 va_sM (va_update_vec 10 va_sM (va_update_vec 0 va_sM
(va_update_ok va_sM va_s0)))))))))))
[@"opaque_to_smt"]
let va_lemma_Reduce va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2;
va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_Reduce va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Reduce ()) va_qc va_s0 (fun va_s0 va_sM
va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 242 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f
in let (c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1))
63 in let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0)
in let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in label va_range1
"***** POSTCONDITION NOT MET AT line 263 column 60 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.Math.Poly2_s.reverse (mod
(Vale.Math.Poly2_s.reverse a 255) g) 127))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2;
va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Reduce (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in
let (c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63
in let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in
let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) (-64) == zero /\ Vale.Math.Poly2.mask (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) 64 == c /\ Vale.Math.Poly2_s.degree f < 64 /\ Vale.Math.Poly2_s.degree g
== 128 /\ Vale.Math.Poly2_s.poly_index f 0) /\ (forall (va_x_v0:quad32) (va_x_v10:quad32)
(va_x_v8:quad32) (va_x_v2:quad32) (va_x_v9:quad32) (va_x_v3:quad32) (va_x_v4:quad32)
(va_x_v1:quad32) . let va_sM = va_upd_vec 1 va_x_v1 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3
(va_upd_vec 9 va_x_v9 (va_upd_vec 2 va_x_v2 (va_upd_vec 8 va_x_v8 (va_upd_vec 10 va_x_v10
(va_upd_vec 0 va_x_v0 va_s0))))))) in va_get_ok va_sM /\ (let (g:Vale.Math.Poly2_s.poly) = add
(Vale.Math.Poly2_s.monomial 128) f in let (c:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in let
(a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) ==
Vale.Math.Poly2_s.reverse (mod (Vale.Math.Poly2_s.reverse a 255) g) 127) ==> va_k va_sM (())))
val va_wpProof_Reduce : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Reduce f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Reduce ()) ([va_Mod_vec 1; va_Mod_vec
4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2; va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0]) va_s0
va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Reduce f va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Reduce (va_code_Reduce ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 1 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 9 va_sM (va_update_vec 2 va_sM (va_update_vec 8 va_sM (va_update_vec 10 va_sM
(va_update_vec 0 va_sM (va_update_ok va_sM va_s0))))))))));
va_lemma_norm_mods ([va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2;
va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Reduce (f:poly) : (va_quickCode unit (va_code_Reduce ())) =
(va_QProc (va_code_Reduce ()) ([va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9;
va_Mod_vec 2; va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0]) (va_wp_Reduce f) (va_wpProof_Reduce
f))
//--
//-- ReduceLast
[@ "opaque_to_smt" va_qattr]
let va_code_ReduceLast () =
(va_Block (va_CCons (va_code_Reduce ()) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_Block
(va_CNil ())) (va_CNil ())))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ReduceLast () =
(va_pbool_and (va_codegen_success_Reduce ()) (va_ttrue ()))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ReduceLast (va_mods:va_mods_t) (h_BE:quad32) (y_prev:quad32) (data:(seq quad32)) :
(va_quickCode unit (va_code_ReduceLast ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in let
(prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in let (n:Prims.nat) = FStar.Seq.Base.length #quad32 data in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 311 column 35 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_constant_shift_rev ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 312 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_degree ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 313 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Reduce gf128_modulus_low_terms) (fun (va_s:va_state) _ -> va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 314 column 36 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(n - 1 >= 0) (fun _ -> let (va_arg25:Prims.nat) = n - 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 314 column 36 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_ghash_unroll_back_forward h prev pdata 0 va_arg25)
(va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 315 column 31 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(n - 1 >= 0) (fun _ -> let (va_arg24:Prims.nat) = n - 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 315 column 31 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_ghash_poly_of_unroll h prev pdata 0 va_arg24) (let
(va_arg23:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = data in let
(va_arg22:Vale.Def.Types_s.quad32) = y_prev in let (va_arg21:Vale.Def.Types_s.quad32) = h_BE in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 316 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_ghash_incremental_poly va_arg21 va_arg22 va_arg23)
(let (va_arg20:Vale.Def.Types_s.quad32) = Vale.AES.GHash_BE.ghash_incremental h_BE y_prev data
in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 317 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_to_of_quad32 va_arg20) (va_QEmpty (()))))))))))))
[@"opaque_to_smt"]
let va_lemma_ReduceLast va_b0 va_s0 h_BE y_prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_ReduceLast va_mods h_BE y_prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ReduceLast ()) va_qc va_s0 (fun va_s0
va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 286 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in
let (prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in let (n:Prims.nat) = FStar.Seq.Base.length #quad32 data in label va_range1
"***** POSTCONDITION NOT MET AT line 307 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(let xi = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) in label va_range1
"***** POSTCONDITION NOT MET AT line 308 column 63 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.Math.Poly2.Bits_s.to_quad32 xi == Vale.AES.GHash_BE.ghash_incremental h_BE y_prev data)
/\ label va_range1
"***** POSTCONDITION NOT MET AT line 309 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(xi == Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Math.Poly2.Bits_s.to_quad32 xi))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_ReduceLast h_BE y_prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ReduceLast (va_code_ReduceLast ()) va_s0 h_BE y_prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_vec 0 va_sM (va_update_ok va_sM va_s0))))))))));
va_lemma_norm_mods ([va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- GhashUnroll_n
[@ "opaque_to_smt" va_qattr]
let va_code_GhashUnroll_n exactly2 =
(va_Block (va_CCons (if exactly2 then va_Block (va_CCons (va_code_MulAdd_unroll_2way ()) (va_CNil
())) else va_Block (va_CCons (va_code_MulAdd_unroll_1way ()) (va_CNil ()))) (va_CCons
(va_code_Vspltisw (va_op_vec_opr_vec 8) 0) (va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg
10) (-15872)) (va_CCons (va_code_Mtvsrws (va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10))
(va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4)
(va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) 4)
(va_CCons (va_code_ReduceLast ()) (va_CNil ())))))))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_GhashUnroll_n exactly2 =
(va_pbool_and (if exactly2 then va_pbool_and (va_codegen_success_MulAdd_unroll_2way ()) (va_ttrue
()) else va_pbool_and (va_codegen_success_MulAdd_unroll_1way ()) (va_ttrue ())) (va_pbool_and
(va_codegen_success_Vspltisw (va_op_vec_opr_vec 8) 0) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 8) 4) (va_pbool_and (va_codegen_success_ReduceLast ()) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_GhashUnroll_n (va_mods:va_mods_t) (exactly2:bool) (in_b:buffer128) (index:nat)
(h_BE:quad32) (y_prev:quad32) (data:(seq quad32)) : (va_quickCode unit (va_code_GhashUnroll_n
exactly2)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in let
(prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in let (n:Prims.nat) = FStar.Seq.Base.length #quad32 data in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 361 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_qInlineIf va_mods exactly2 (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 363 column 27 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_MulAdd_unroll_2way in_b index h prev data) (va_QEmpty (())))) (qblock va_mods (fun
(va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 367 column 27 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_MulAdd_unroll_1way in_b index h prev data) (va_QEmpty (()))))) (fun (va_s:va_state)
va_g -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 369 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 8) 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 370 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (fun (va_s:va_state) _ -> let
(va_arg27:Vale.Def.Types_s.nat64) = (-15872) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 371 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg27 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 372 column 12 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 373 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 374 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) 4) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 375 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_ReduceLast h_BE y_prev data) (va_QEmpty (())))))))))))
[@"opaque_to_smt"]
let va_lemma_GhashUnroll_n va_b0 va_s0 exactly2 in_b index h_BE y_prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec
4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_GhashUnroll_n va_mods exactly2 in_b index h_BE y_prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_GhashUnroll_n exactly2) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 320 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in
let (prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in let (n:Prims.nat) = FStar.Seq.Base.length #quad32 data in label va_range1
"***** POSTCONDITION NOT MET AT line 359 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.GHash_BE.ghash_incremental h_BE y_prev data))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_GhashUnroll_n exactly2 in_b index h_BE y_prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_GhashUnroll_n (va_code_GhashUnroll_n exactly2) va_s0 exactly2 in_b
index h_BE y_prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM
(va_update_vec 8 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0))))))))))));
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Ghash_register
[@ "opaque_to_smt" va_qattr]
let va_code_Ghash_register () =
(va_Block (va_CCons (va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 5) Secret) (va_CCons (va_code_Vspltisw
(va_op_vec_opr_vec 0) 0) (va_CCons (va_code_VSwap (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5))
(va_CCons (va_code_High64ToLow (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 5)) (va_CCons
(va_code_Low64ToHigh (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 5)) (va_CCons (va_Block (va_CNil
())) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
9)) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 7)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 5)) (va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
9) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 8) 0) (va_CCons
(va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_CCons (va_code_Mtvsrws
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10)) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) 4) (va_CCons (va_code_ReduceLast ()) (va_CNil
()))))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Ghash_register () =
(va_pbool_and (va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 5) Secret) (va_pbool_and (va_codegen_success_Vspltisw
(va_op_vec_opr_vec 0) 0) (va_pbool_and (va_codegen_success_VSwap (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_High64ToLow (va_op_vec_opr_vec 7)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_Low64ToHigh (va_op_vec_opr_vec 6)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 9)) (va_pbool_and (va_codegen_success_VPolyMulLow
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 7)) (va_pbool_and
(va_codegen_success_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 8) 0)
(va_pbool_and (va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 8) 4) (va_pbool_and (va_codegen_success_ReduceLast ()) (va_ttrue
()))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Ghash_register (va_mods:va_mods_t) (hkeys_b:buffer128) (h_BE:quad32) (y_prev:quad32) :
(va_quickCode unit (va_code_Ghash_register ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in let
(data:(FStar.Seq.Base.seq quad32)) = FStar.Seq.Base.create #quad32 1 (va_get_vec 9 va_s) in let
(prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 405 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 0) (va_op_vec_opr_vec 5)
(va_op_reg_opr_reg 5) Secret hkeys_b 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 406 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 0) 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 407 column 10 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VSwap (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5)) (fun (va_s:va_state) _ -> let
(va_arg71:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 408 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_quad32_double va_arg71) (let
(va_arg70:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 409 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_double_swap va_arg70) (let
(va_arg69:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.swap (Vale.AES.GHash_BE.gf128_power h 1) 64
in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 410 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_quad32_double va_arg69) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 411 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_High64ToLow (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 5) (Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 412 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Low64ToHigh (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 5) (Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64)) (fun (va_s:va_state) _ -> let
(va_arg68:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 413 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32 va_arg68) (let
(va_arg67:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 414 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32 va_arg67) (va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 416 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(0 >= 0 /\ (fun a_336 (s_337:(FStar.Seq.Base.seq a_336)) (i_338:Prims.nat) -> let
(i_312:Prims.nat) = i_338 in Prims.b2t (Prims.op_LessThan i_312 (FStar.Seq.Base.length #a_336
s_337))) quad32 data 0) (fun _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 416 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_vec 9 va_s == FStar.Seq.Base.index #quad32 data 0) (let (data_i:poly) = pdata 0 in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 419 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power h 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 420 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 9)) (fun
(va_s:va_state) _ -> let (va_arg66:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 421 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg66) (let
(va_arg65:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 422 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg65 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 423 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 424 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg64:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg63:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 425 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg63 va_arg64) (let
(va_arg62:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 426 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg62 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 427 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg61:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg60:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 428 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg60 va_arg61) (let
(va_arg59:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 429 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg59 64) (let
(va_arg58:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 430 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg58 64) (let
(va_arg57:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 431 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg57) (let
(va_arg56:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 432 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg56 64) (let
(va_arg55:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 433 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg55 64) (let
(va_arg54:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg53:Vale.Math.Poly2_s.poly) = add prev data_i in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 434 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg53 va_arg54) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 436 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 8) 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 437 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (fun (va_s:va_state) _ -> let
(va_arg52:Vale.Def.Types_s.nat64) = (-15872) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 438 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg52 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 439 column 12 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 440 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 441 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) 4) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 442 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_ReduceLast h_BE y_prev data) (va_QEmpty (()))))))))))))))))))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Ghash_register va_b0 va_s0 hkeys_b h_BE y_prev =
let (va_mods:va_mods_t) = [va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 7; va_Mod_vec 6;
va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg
10; va_Mod_ok] in
let va_qc = va_qcode_Ghash_register va_mods hkeys_b h_BE y_prev in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Ghash_register ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 378 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in
let (data:(FStar.Seq.Base.seq quad32)) = FStar.Seq.Base.create #quad32 1 (va_get_vec 9 va_s0)
in let (prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in label va_range1
"***** POSTCONDITION NOT MET AT line 403 column 57 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.GHash_BE.ghash_incremental h_BE y_prev data))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 7; va_Mod_vec 6;
va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg
10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Ghash_register hkeys_b h_BE y_prev va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Ghash_register (va_code_Ghash_register ()) va_s0 hkeys_b h_BE
y_prev in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM
(va_update_vec 7 va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM
(va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))))))))))));
va_lemma_norm_mods ([va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 7; va_Mod_vec 6;
va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg
10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Ghash_buffer_loop_body
val va_code_Ghash_buffer_loop_body : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Ghash_buffer_loop_body () =
(va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_Block (va_CNil ())) (va_CCons
(va_code_GhashUnroll_n true) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_Block (va_CNil
())) (va_CCons (va_code_AddImm (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 7) 32) (va_CCons
(va_code_SubImm (va_op_reg_opr_reg 6) (va_op_reg_opr_reg 6) 2) (va_CNil ())))))))))
val va_codegen_success_Ghash_buffer_loop_body : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Ghash_buffer_loop_body () =
(va_pbool_and (va_codegen_success_GhashUnroll_n true) (va_pbool_and (va_codegen_success_AddImm
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 7) 32) (va_pbool_and (va_codegen_success_SubImm
(va_op_reg_opr_reg 6) (va_op_reg_opr_reg 6) 2) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Ghash_buffer_loop_body (va_mods:va_mods_t) (in_b:buffer128) (h_BE:quad32)
(y_prev:quad32) (old_len:nat64) (index:nat) : (va_quickCode unit (va_code_Ghash_buffer_loop_body
())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in let
(prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 501 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
((fun a_1582 (s_1583:(FStar.Seq.Base.seq a_1582)) (i_1584:Prims.nat) (j_1585:Prims.nat) -> let
(j_1545:Prims.nat) = j_1585 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1584
j_1545) (Prims.op_LessThanOrEqual j_1545 (FStar.Seq.Base.length #a_1582 s_1583))))
Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_s) in_b)) index (index + 2)) (fun _ -> let (data:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = FStar.Seq.Base.slice #Vale.Def.Types_s.quad32
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s)
in_b)) index (index + 2) in va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 502 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
((fun a_1582 (s_1583:(FStar.Seq.Base.seq a_1582)) (i_1584:Prims.nat) (j_1585:Prims.nat) -> let
(j_1545:Prims.nat) = j_1585 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1584
j_1545) (Prims.op_LessThanOrEqual j_1545 (FStar.Seq.Base.length #a_1582 s_1583))))
Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_s) in_b)) 0 index) (fun _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 502 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_GhashUnroll_n true in_b index h_BE (Vale.AES.GHash_BE.ghash_incremental0 h_BE y_prev
(FStar.Seq.Base.slice #Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s) in_b)) 0 index)) data) (fun
(va_s:va_state) _ -> va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 503 column 36 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
((fun a_1582 (s_1583:(FStar.Seq.Base.seq a_1582)) (i_1584:Prims.nat) (j_1585:Prims.nat) -> let
(j_1545:Prims.nat) = j_1585 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1584
j_1545) (Prims.op_LessThanOrEqual j_1545 (FStar.Seq.Base.length #a_1582 s_1583))))
Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_s) in_b)) 0 index) (fun _ -> let (va_arg27:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = FStar.Seq.Base.slice #Vale.Def.Types_s.quad32
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s)
in_b)) 0 index in let (va_arg26:Vale.Def.Types_s.quad32) = va_get_vec 1 va_s in let
(va_arg25:Vale.Def.Types_s.quad32) = va_get_vec 1 va_old_s in let
(va_arg24:Vale.Def.Types_s.quad32) = y_prev in let (va_arg23:Vale.Def.Types_s.quad32) = h_BE in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 503 column 36 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_ghash_incremental0_append va_arg23 va_arg24 va_arg25
va_arg26 va_arg27 data) (va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 505 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
((fun a_1582 (s_1583:(FStar.Seq.Base.seq a_1582)) (i_1584:Prims.nat) (j_1585:Prims.nat) -> let
(j_1545:Prims.nat) = j_1585 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1584
j_1545) (Prims.op_LessThanOrEqual j_1545 (FStar.Seq.Base.length #a_1582 s_1583))))
Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_s) in_b)) 0 index /\ (fun a_1582 (s_1583:(FStar.Seq.Base.seq a_1582))
(i_1584:Prims.nat) (j_1585:Prims.nat) -> let (j_1545:Prims.nat) = j_1585 in Prims.b2t
(Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1584 j_1545) (Prims.op_LessThanOrEqual j_1545
(FStar.Seq.Base.length #a_1582 s_1583)))) Vale.Def.Types_s.quad32
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s)
in_b)) 0 (index + 2)) (fun _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 505 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(FStar.Seq.Base.equal #Vale.Def.Types_s.quad32 (FStar.Seq.Base.append #Vale.Def.Types_s.quad32
(FStar.Seq.Base.slice #Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s) in_b)) 0 index) data)
(FStar.Seq.Base.slice #Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s) in_b)) 0 (index + 2))) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 507 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_AddImm (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 7) 32) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 508 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_SubImm (va_op_reg_opr_reg 6) (va_op_reg_opr_reg 6) 2) (va_QEmpty (()))))))))))))
val va_lemma_Ghash_buffer_loop_body : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 ->
h_BE:quad32 -> y_prev:quad32 -> old_len:nat64 -> index:nat
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Ghash_buffer_loop_body ()) va_s0 /\ va_get_ok va_s0 /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in let
(prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in va_get_reg 6 va_s0
>= 2 /\ index + va_get_reg 6 va_s0 == old_len /\ Vale.PPC64LE.Decls.validSrcAddrsOffset128
(va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0) in_b index (va_get_reg 6 va_s0)
(va_get_mem_layout va_s0) Secret /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b == old_len /\ va_get_reg 7 va_s0 + 16 `op_Multiply`
va_get_reg 6 va_s0 < pow2_64 /\ va_get_vec 1 va_s0 == Vale.AES.GHash_BE.ghash_incremental0 h_BE
y_prev (FStar.Seq.Base.slice #Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)) 0 index) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in let
(prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let index' = index +
2 in index' + va_get_reg 6 va_sM == old_len /\ Vale.PPC64LE.Decls.validSrcAddrsOffset128
(va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM) in_b index' (va_get_reg 6 va_sM)
(va_get_mem_layout va_sM) Secret /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b == old_len /\ va_get_reg 7 va_sM + 16 `op_Multiply`
va_get_reg 6 va_sM < pow2_64 /\ va_get_vec 1 va_sM == Vale.AES.GHash_BE.ghash_incremental0 h_BE
y_prev (FStar.Seq.Base.slice #Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) in_b)) 0 index') /\ va_get_reg 7 va_sM ==
va_get_reg 7 va_s0 + 32 /\ va_get_reg 6 va_sM == va_get_reg 6 va_s0 - 2) /\ va_state_eq va_sM
(va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_reg 6 va_sM (va_update_reg 7 va_sM
(va_update_ok va_sM va_s0)))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Ghash_buffer_loop_body va_b0 va_s0 in_b h_BE y_prev old_len index =
let (va_mods:va_mods_t) = [va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec
4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 6;
va_Mod_reg 7; va_Mod_ok] in
let va_qc = va_qcode_Ghash_buffer_loop_body va_mods in_b h_BE y_prev old_len index in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Ghash_buffer_loop_body ()) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 445 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in
let (prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in label va_range1
"***** POSTCONDITION NOT MET AT line 487 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(let index' = index + 2 in label va_range1
"***** POSTCONDITION NOT MET AT line 489 column 32 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(index' + va_get_reg 6 va_sM == old_len) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 492 column 84 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM)
in_b index' (va_get_reg 6 va_sM) (va_get_mem_layout va_sM) Secret) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 493 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b == old_len) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 494 column 38 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_reg 7 va_sM + 16 `op_Multiply` va_get_reg 6 va_sM < pow2_64) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 495 column 110 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.GHash_BE.ghash_incremental0 h_BE y_prev (FStar.Seq.Base.slice
#Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_sM) in_b)) 0 index')) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 498 column 37 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_reg 7 va_sM == va_get_reg 7 va_s0 + 32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 499 column 28 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_reg 6 va_sM == va_get_reg 6 va_s0 - 2)))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 6; va_Mod_reg
7; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Ghash_buffer_loop_body (in_b:buffer128) (h_BE:quad32) (y_prev:quad32) (old_len:nat64)
(index:nat) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in
let (prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in va_get_reg 6
va_s0 >= 2 /\ index + va_get_reg 6 va_s0 == old_len /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
in_b index (va_get_reg 6 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b == old_len /\ va_get_reg 7
va_s0 + 16 `op_Multiply` va_get_reg 6 va_s0 < pow2_64 /\ va_get_vec 1 va_s0 ==
Vale.AES.GHash_BE.ghash_incremental0 h_BE y_prev (FStar.Seq.Base.slice #Vale.Def.Types_s.quad32
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
in_b)) 0 index) /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) ==
Vale.Math.Poly2.swap (Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 6 va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) ==
Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64)) /\ (forall (va_x_r7:nat64)
(va_x_r6:nat64) (va_x_r10:nat64) (va_x_v0:quad32) (va_x_v1:quad32) (va_x_v2:quad32)
(va_x_v3:quad32) (va_x_v4:quad32) (va_x_v8:quad32) (va_x_v9:quad32) (va_x_v10:quad32)
(va_x_v11:quad32) . let va_sM = va_upd_vec 11 va_x_v11 (va_upd_vec 10 va_x_v10 (va_upd_vec 9
va_x_v9 (va_upd_vec 8 va_x_v8 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2
(va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 (va_upd_reg 6 va_x_r6
(va_upd_reg 7 va_x_r7 va_s0))))))))))) in va_get_ok va_sM /\ (let (h:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 h_BE in let (prev:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let index' = index + 2 in index' + va_get_reg 6
va_sM == old_len /\ Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_sM)
(va_get_reg 7 va_sM) in_b index' (va_get_reg 6 va_sM) (va_get_mem_layout va_sM) Secret /\
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b == old_len /\ va_get_reg 7
va_sM + 16 `op_Multiply` va_get_reg 6 va_sM < pow2_64 /\ va_get_vec 1 va_sM ==
Vale.AES.GHash_BE.ghash_incremental0 h_BE y_prev (FStar.Seq.Base.slice #Vale.Def.Types_s.quad32
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
in_b)) 0 index') /\ va_get_reg 7 va_sM == va_get_reg 7 va_s0 + 32 /\ va_get_reg 6 va_sM ==
va_get_reg 6 va_s0 - 2) ==> va_k va_sM (())))
val va_wpProof_Ghash_buffer_loop_body : in_b:buffer128 -> h_BE:quad32 -> y_prev:quad32 ->
old_len:nat64 -> index:nat -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Ghash_buffer_loop_body in_b h_BE y_prev old_len index
va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Ghash_buffer_loop_body ())
([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 6; va_Mod_reg 7]) va_s0
va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Ghash_buffer_loop_body in_b h_BE y_prev old_len index va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Ghash_buffer_loop_body (va_code_Ghash_buffer_loop_body ()) va_s0
in_b h_BE y_prev old_len index in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM
(va_update_vec 8 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_reg 6 va_sM
(va_update_reg 7 va_sM (va_update_ok va_sM va_s0))))))))))))));
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 6; va_Mod_reg
7]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Ghash_buffer_loop_body (in_b:buffer128) (h_BE:quad32) (y_prev:quad32) (old_len:nat64)
(index:nat) : (va_quickCode unit (va_code_Ghash_buffer_loop_body ())) =
(va_QProc (va_code_Ghash_buffer_loop_body ()) ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9;
va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg
10; va_Mod_reg 6; va_Mod_reg 7]) (va_wp_Ghash_buffer_loop_body in_b h_BE y_prev old_len index)
(va_wpProof_Ghash_buffer_loop_body in_b h_BE y_prev old_len index))
//--
//-- Mod_cr0
val va_code_Mod_cr0 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Mod_cr0 () =
(va_Block (va_CNil ()))
val va_codegen_success_Mod_cr0 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr] | false | true | Vale.AES.PPC64LE.GHash.fst | {
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_codegen_success_Mod_cr0 : va_dummy:unit -> Tot va_pbool | [] | Vale.AES.PPC64LE.GHash.va_codegen_success_Mod_cr0 | {
"file_name": "obj/Vale.AES.PPC64LE.GHash.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_dummy: Prims.unit -> Vale.PPC64LE.Decls.va_pbool | {
"end_col": 15,
"end_line": 1335,
"start_col": 2,
"start_line": 1335
} |
Prims.Tot | val va_code_Ghash_buffer_body0 : va_dummy:unit -> Tot va_code | [
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math // For lemma_poly_bits64()",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let va_code_Ghash_buffer_body0 () =
(va_Block (va_CCons (va_code_Mod_cr0 ()) (va_CCons (va_code_Ghash_buffer_loop_body ()) (va_CNil
())))) | val va_code_Ghash_buffer_body0 : va_dummy:unit -> Tot va_code
let va_code_Ghash_buffer_body0 () = | false | null | false | (va_Block (va_CCons (va_code_Mod_cr0 ()) (va_CCons (va_code_Ghash_buffer_loop_body ()) (va_CNil ()))
)) | {
"checked_file": "Vale.AES.PPC64LE.GHash.fst.checked",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Words.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.PolyOps.fsti.checked",
"Vale.AES.PPC64LE.GF128_Mul.fsti.checked",
"Vale.AES.GHash_BE.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.GCTR_BE.fsti.checked",
"Vale.AES.GCM_helpers_BE.fsti.checked",
"Vale.AES.AES_helpers.fsti.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.GHash.fst"
} | [
"total"
] | [
"Prims.unit",
"Vale.PPC64LE.Decls.va_Block",
"Vale.PPC64LE.Decls.va_CCons",
"Vale.AES.PPC64LE.GHash.va_code_Mod_cr0",
"Vale.AES.PPC64LE.GHash.va_code_Ghash_buffer_loop_body",
"Vale.PPC64LE.Decls.va_CNil",
"Vale.PPC64LE.Decls.va_code"
] | [] | module Vale.AES.PPC64LE.GHash
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.AES_helpers
open Vale.Poly1305.Math // For lemma_poly_bits64()
open Vale.AES.GCM_helpers_BE
open Vale.AES.GCTR_BE_s
open Vale.AES.GCTR_BE
open Vale.Arch.TypesNative
open Vale.AES.PPC64LE.PolyOps
open Vale.AES.PPC64LE.GF128_Mul
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash_BE
#reset-options "--z3rlimit 50"
//-- MulAdd_unroll_1way
val va_code_MulAdd_unroll_1way : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_MulAdd_unroll_1way () =
(va_Block (va_CCons (va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_CCons (va_code_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_CCons
(va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5))
(va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
6)) (va_CNil ())))))))
val va_codegen_success_MulAdd_unroll_1way : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_MulAdd_unroll_1way () =
(va_pbool_and (va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_pbool_and
(va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
7)) (va_pbool_and (va_codegen_success_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (va_ttrue ()))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_MulAdd_unroll_1way (va_mods:va_mods_t) (in_b:buffer128) (index:nat) (h:poly)
(prev:poly) (data:(seq quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_1way ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (pdata:(Prims.int
-> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in let
(data_i:poly) = pdata 0 in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 136 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret in_b index) (fun (va_s:va_state) _ -> let
(va_arg44:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 138 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg44 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 139 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg43:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 140 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg43) (let
(va_arg42:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 141 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg42 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 142 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 143 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg41:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg40:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 144 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg40 va_arg41) (let
(va_arg39:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 145 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg39 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 146 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg38:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg37:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 147 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg37 va_arg38) (let
(va_arg36:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 148 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg36 64) (let
(va_arg35:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 149 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg35 64) (let
(va_arg34:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 150 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg34) (let
(va_arg33:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 151 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg33 64) (let
(va_arg32:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 152 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg32 64) (let
(va_arg31:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg30:Vale.Math.Poly2_s.poly) = add prev data_i in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 153 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg30 va_arg31) (va_QEmpty
(()))))))))))))))))))))
val va_lemma_MulAdd_unroll_1way : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 -> index:nat ->
h:poly -> prev:poly -> data:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_MulAdd_unroll_1way ()) va_s0 /\ va_get_ok va_s0 /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 1 /\
in_b_blocks in_b index 1 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0) /\ va_state_eq va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_ok va_sM va_s0)))))))
[@"opaque_to_smt"]
let va_lemma_MulAdd_unroll_1way va_b0 va_s0 in_b index h prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_MulAdd_unroll_1way va_mods in_b index h prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_MulAdd_unroll_1way ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 106 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in label va_range1
"***** POSTCONDITION NOT MET AT line 133 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_ok]) va_sM
va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_MulAdd_unroll_1way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq quad32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 1 /\
in_b_blocks in_b index 1 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64)) /\ (forall
(va_x_v0:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) . let va_sM = va_upd_vec 4
va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 va_s0))) in va_get_ok
va_sM /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 1 0) ==> va_k va_sM (())))
val va_wpProof_MulAdd_unroll_1way : in_b:buffer128 -> index:nat -> h:poly -> prev:poly -> data:(seq
quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_MulAdd_unroll_1way in_b index h prev data va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_MulAdd_unroll_1way ()) ([va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_MulAdd_unroll_1way in_b index h prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_MulAdd_unroll_1way (va_code_MulAdd_unroll_1way ()) va_s0 in_b index
h prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 0 va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_MulAdd_unroll_1way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq
quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_1way ())) =
(va_QProc (va_code_MulAdd_unroll_1way ()) ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec
0]) (va_wp_MulAdd_unroll_1way in_b index h prev data) (va_wpProof_MulAdd_unroll_1way in_b index
h prev data))
//--
//-- MulAdd_unroll_2way
val va_code_MulAdd_unroll_2way : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_MulAdd_unroll_2way () =
(va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_CCons
(va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret) (va_CCons (va_code_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg
10) Secret) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 7)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 5)) (va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
8) (va_op_vec_opr_vec 6)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
1) (va_op_vec_opr_vec 0)) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec
10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (va_CCons (va_code_VPolyMulHigh
(va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 13)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_CCons
(va_code_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 11)) (va_CNil
())))))))))))))))
val va_codegen_success_MulAdd_unroll_2way : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_MulAdd_unroll_2way () =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret) (va_pbool_and (va_codegen_success_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg
10) Secret) (va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 8) (va_op_vec_opr_vec 7)) (va_pbool_and (va_codegen_success_VPolyMul
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec
6)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 0)) (va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14)) (va_pbool_and (va_codegen_success_VPolyMul
(va_op_vec_opr_vec 10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (va_pbool_and
(va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 13)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_pbool_and
(va_codegen_success_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
11)) (va_ttrue ()))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_MulAdd_unroll_2way (va_mods:va_mods_t) (in_b:buffer128) (index:nat) (h:poly)
(prev:poly) (data:(seq quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_2way ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (pdata:(Prims.int
-> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in let
(data_0:poly) = pdata 0 in let (data_1:poly) = pdata 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 196 column 14 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 197 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret in_b index) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 198 column 32 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 8)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 10) Secret in_b (index + 1)) (fun (va_s:va_state) _ ->
let (va_arg95:Vale.Math.Poly2_s.poly) = h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 200 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg95 1) (let
(va_arg94:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 201 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg94) (let
(va_arg93:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 202 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg93 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 203 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 204 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg92:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg91:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 205 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg91 va_arg92) (let
(va_arg90:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 206 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg90 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 207 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg89:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg88:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 208 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg88 va_arg89) (let
(va_arg87:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 209 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg87 64) (let
(va_arg86:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 210 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg86 64) (let
(va_arg85:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 211 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg85) (let
(va_arg84:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 212 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg84 64) (let
(va_arg83:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 213 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg83 64) (let
(va_arg82:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg81:Vale.Math.Poly2_s.poly) = data_1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 214 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg81 va_arg82) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 215 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 0) (let (va_arg80:Vale.Math.Poly2_s.poly)
= h in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 218 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power va_arg80 2) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 219 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg79:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 220 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg79) (let
(va_arg78:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 221 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg78 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 222 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 223 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 12)) (fun
(va_s:va_state) _ -> let (va_arg77:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg76:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
2) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 224 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg76 va_arg77) (let
(va_arg75:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 225 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg75 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 226 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 11) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 13))
(fun (va_s:va_state) _ -> let (va_arg74:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64
in let (va_arg73:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 227 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg73 va_arg74) (let
(va_arg72:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 228 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg72 64) (let
(va_arg71:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 229 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg71 64) (let
(va_arg70:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 230 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg70) (let
(va_arg69:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 231 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg69 64) (let
(va_arg68:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 232 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg68 64) (let
(va_arg67:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.shift (add prev
data_0) (-64)) (Vale.Math.Poly2.mask (Vale.AES.GHash_BE.gf128_power h 2) 64) in let
(va_arg66:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2.mask (add prev
data_0) 64) (Vale.Math.Poly2_s.shift (Vale.AES.GHash_BE.gf128_power h 2) (-64)) in let
(va_arg65:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec 3 va_s) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 233 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_add_associate va_arg65 va_arg66 va_arg67) (let
(va_arg64:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 2 in let
(va_arg63:Vale.Math.Poly2_s.poly) = add prev data_0 in let (va_arg62:Vale.Math.Poly2_s.poly) =
of_quad32 (va_get_vec 4 va_s) in let (va_arg61:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec
3 va_s) in let (va_arg60:Vale.Math.Poly2_s.poly) = of_quad32 (va_get_vec 2 va_s) in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 236 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128_accum va_arg60 va_arg61 va_arg62 va_arg63
va_arg64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 237 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 238 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 10)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 239 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 11))
(va_QEmpty (()))))))))))))))))))))))))))))))))))))))))))
val va_lemma_MulAdd_unroll_2way : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 -> index:nat ->
h:poly -> prev:poly -> data:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_MulAdd_unroll_2way ()) va_s0 /\ va_get_ok va_s0 /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 2 /\
in_b_blocks in_b index 2 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3
va_sM)) 64)) (Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM))
128) == Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1) /\ va_state_eq va_sM
(va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))))))))))
[@"opaque_to_smt"]
let va_lemma_MulAdd_unroll_2way va_b0 va_s0 in_b index h prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec
4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_MulAdd_unroll_2way va_mods in_b index h prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_MulAdd_unroll_2way ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 156 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in label va_range1
"***** POSTCONDITION NOT MET AT line 192 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(add (add (Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_MulAdd_unroll_2way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq quad32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) =
Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in FStar.Seq.Base.length #quad32 data == 2 /\
in_b_blocks in_b index 2 (va_get_mem_heaplet 1 va_s0) (va_get_mem_layout va_s0) (va_get_reg 7
va_s0) data /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_s0) == prev /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64)) /\ (forall
(va_x_r10:nat64) (va_x_v0:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32)
(va_x_v8:quad32) (va_x_v9:quad32) (va_x_v10:quad32) (va_x_v11:quad32) . let va_sM = va_upd_vec
11 va_x_v11 (va_upd_vec 10 va_x_v10 (va_upd_vec 9 va_x_v9 (va_upd_vec 8 va_x_v8 (va_upd_vec 4
va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 (va_upd_reg 10
va_x_r10 va_s0)))))))) in va_get_ok va_sM /\ (let (pdata:(Prims.int ->
Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128 data in add (add
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_sM)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_sM)) 64)) (Vale.Math.Poly2_s.shift
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_sM)) 128) ==
Vale.AES.GHash_BE.ghash_unroll_back h prev pdata 0 2 1) ==> va_k va_sM (())))
val va_wpProof_MulAdd_unroll_2way : in_b:buffer128 -> index:nat -> h:poly -> prev:poly -> data:(seq
quad32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_MulAdd_unroll_2way in_b index h prev data va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_MulAdd_unroll_2way ()) ([va_Mod_vec
11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 0; va_Mod_reg 10]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_MulAdd_unroll_2way in_b index h prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_MulAdd_unroll_2way (va_code_MulAdd_unroll_2way ()) va_s0 in_b index
h prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM
(va_update_vec 8 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM va_s0)))))))))));
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_MulAdd_unroll_2way (in_b:buffer128) (index:nat) (h:poly) (prev:poly) (data:(seq
quad32)) : (va_quickCode unit (va_code_MulAdd_unroll_2way ())) =
(va_QProc (va_code_MulAdd_unroll_2way ()) ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9;
va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10])
(va_wp_MulAdd_unroll_2way in_b index h prev data) (va_wpProof_MulAdd_unroll_2way in_b index h
prev data))
//--
//-- Reduce
val va_code_Reduce : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Reduce () =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 0) 0) (va_CCons (va_code_Low64ToHigh
(va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_CCons (va_code_VSwap (va_op_vec_opr_vec 10)
(va_op_vec_opr_vec 2)) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
2) (va_op_vec_opr_vec 8)) (va_CCons (va_code_High64ToLow (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 3)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 10)) (va_CCons (va_code_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2))
(va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
8)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
4)) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
2)) (va_CNil ()))))))))))))))
val va_codegen_success_Reduce : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Reduce () =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 0) 0) (va_pbool_and
(va_codegen_success_Low64ToHigh (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9))
(va_pbool_and (va_codegen_success_VSwap (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 2))
(va_pbool_and (va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 8)) (va_pbool_and (va_codegen_success_High64ToLow (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 3)) (va_pbool_and (va_codegen_success_VPolyAdd
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 10)) (va_pbool_and
(va_codegen_success_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_pbool_and
(va_codegen_success_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
8)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_ttrue ())))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Reduce (va_mods:va_mods_t) (f:poly) : (va_quickCode unit (va_code_Reduce ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in let
(c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in
let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 265 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 0) 0) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 266 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod a1 64) (let
(va_arg39:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.mask a1 64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 267 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_shift_is_mul va_arg39 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 268 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Low64ToHigh (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 3) a1) (fun (va_s:va_state) _ ->
let (va_arg38:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift (Vale.Math.Poly2.mask a1 64) 64
in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 269 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32 va_arg38) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 270 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 271 column 10 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VSwap (va_op_vec_opr_vec 10) (va_op_vec_opr_vec 2)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 272 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 273 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div a1 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 274 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_High64ToLow (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) a1) (fun (va_s:va_state) _ ->
let (va_arg37:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.shift a1 (-64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 275 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32 va_arg37) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 276 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 3)) (fun
(va_s:va_state) _ -> let (va_arg36:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 10 va_s) in let (va_arg35:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 277 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.lemma_add_commute va_arg35 va_arg36) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 278 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 10)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 279 column 10 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VSwap (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 280 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 8))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 281 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 4)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 282 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (fun
(va_s:va_state) _ -> let (va_arg34:Vale.Math.Poly2_s.poly) = f in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 283 column 21 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_reduce_rev a0 a1 a2 va_arg34 64) (va_QEmpty
(()))))))))))))))))))))))
val va_lemma_Reduce : va_b0:va_code -> va_s0:va_state -> f:poly
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Reduce ()) va_s0 /\ va_get_ok va_s0 /\ (let
(g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in let
(c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in
let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) (-64) == zero /\ Vale.Math.Poly2.mask (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) 64 == c /\ Vale.Math.Poly2_s.degree f < 64 /\ Vale.Math.Poly2_s.degree g
== 128 /\ Vale.Math.Poly2_s.poly_index f 0)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in let
(c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in
let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) ==
Vale.Math.Poly2_s.reverse (mod (Vale.Math.Poly2_s.reverse a 255) g) 127) /\ va_state_eq va_sM
(va_update_vec 1 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 9 va_sM
(va_update_vec 2 va_sM (va_update_vec 8 va_sM (va_update_vec 10 va_sM (va_update_vec 0 va_sM
(va_update_ok va_sM va_s0)))))))))))
[@"opaque_to_smt"]
let va_lemma_Reduce va_b0 va_s0 f =
let (va_mods:va_mods_t) = [va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2;
va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_Reduce va_mods f in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Reduce ()) va_qc va_s0 (fun va_s0 va_sM
va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 242 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f
in let (c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1))
63 in let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0)
in let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in
let (a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in label va_range1
"***** POSTCONDITION NOT MET AT line 263 column 60 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) == Vale.Math.Poly2_s.reverse (mod
(Vale.Math.Poly2_s.reverse a 255) g) 127))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2;
va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Reduce (f:poly) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (g:Vale.Math.Poly2_s.poly) = add (Vale.Math.Poly2_s.monomial 128) f in
let (c:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63
in let (a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in
let (a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2_s.shift (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) (-64) == zero /\ Vale.Math.Poly2.mask (Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 8 va_s0)) 64 == c /\ Vale.Math.Poly2_s.degree f < 64 /\ Vale.Math.Poly2_s.degree g
== 128 /\ Vale.Math.Poly2_s.poly_index f 0) /\ (forall (va_x_v0:quad32) (va_x_v10:quad32)
(va_x_v8:quad32) (va_x_v2:quad32) (va_x_v9:quad32) (va_x_v3:quad32) (va_x_v4:quad32)
(va_x_v1:quad32) . let va_sM = va_upd_vec 1 va_x_v1 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3
(va_upd_vec 9 va_x_v9 (va_upd_vec 2 va_x_v2 (va_upd_vec 8 va_x_v8 (va_upd_vec 10 va_x_v10
(va_upd_vec 0 va_x_v0 va_s0))))))) in va_get_ok va_sM /\ (let (g:Vale.Math.Poly2_s.poly) = add
(Vale.Math.Poly2_s.monomial 128) f in let (c:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2_s.reverse (Vale.Math.Poly2_s.shift f (-1)) 63 in let
(a0:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 2 va_s0) in let
(a1:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 3 va_s0) in let
(a2:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 4 va_s0) in let
(a:Vale.Math.Poly2_s.poly) = add (add a0 (Vale.Math.Poly2_s.shift a1 64))
(Vale.Math.Poly2_s.shift a2 128) in Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) ==
Vale.Math.Poly2_s.reverse (mod (Vale.Math.Poly2_s.reverse a 255) g) 127) ==> va_k va_sM (())))
val va_wpProof_Reduce : f:poly -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Reduce f va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Reduce ()) ([va_Mod_vec 1; va_Mod_vec
4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2; va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0]) va_s0
va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Reduce f va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Reduce (va_code_Reduce ()) va_s0 f in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 1 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 9 va_sM (va_update_vec 2 va_sM (va_update_vec 8 va_sM (va_update_vec 10 va_sM
(va_update_vec 0 va_sM (va_update_ok va_sM va_s0))))))))));
va_lemma_norm_mods ([va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9; va_Mod_vec 2;
va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Reduce (f:poly) : (va_quickCode unit (va_code_Reduce ())) =
(va_QProc (va_code_Reduce ()) ([va_Mod_vec 1; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 9;
va_Mod_vec 2; va_Mod_vec 8; va_Mod_vec 10; va_Mod_vec 0]) (va_wp_Reduce f) (va_wpProof_Reduce
f))
//--
//-- ReduceLast
[@ "opaque_to_smt" va_qattr]
let va_code_ReduceLast () =
(va_Block (va_CCons (va_code_Reduce ()) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_Block
(va_CNil ())) (va_CNil ())))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_ReduceLast () =
(va_pbool_and (va_codegen_success_Reduce ()) (va_ttrue ()))
[@ "opaque_to_smt" va_qattr]
let va_qcode_ReduceLast (va_mods:va_mods_t) (h_BE:quad32) (y_prev:quad32) (data:(seq quad32)) :
(va_quickCode unit (va_code_ReduceLast ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in let
(prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in let (n:Prims.nat) = FStar.Seq.Base.length #quad32 data in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 311 column 35 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_constant_shift_rev ()) (va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 312 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_gf128_degree ()) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 313 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Reduce gf128_modulus_low_terms) (fun (va_s:va_state) _ -> va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 314 column 36 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(n - 1 >= 0) (fun _ -> let (va_arg25:Prims.nat) = n - 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 314 column 36 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_ghash_unroll_back_forward h prev pdata 0 va_arg25)
(va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 315 column 31 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(n - 1 >= 0) (fun _ -> let (va_arg24:Prims.nat) = n - 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 315 column 31 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_ghash_poly_of_unroll h prev pdata 0 va_arg24) (let
(va_arg23:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = data in let
(va_arg22:Vale.Def.Types_s.quad32) = y_prev in let (va_arg21:Vale.Def.Types_s.quad32) = h_BE in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 316 column 33 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_ghash_incremental_poly va_arg21 va_arg22 va_arg23)
(let (va_arg20:Vale.Def.Types_s.quad32) = Vale.AES.GHash_BE.ghash_incremental h_BE y_prev data
in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 317 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_to_of_quad32 va_arg20) (va_QEmpty (()))))))))))))
[@"opaque_to_smt"]
let va_lemma_ReduceLast va_b0 va_s0 h_BE y_prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_ok] in
let va_qc = va_qcode_ReduceLast va_mods h_BE y_prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_ReduceLast ()) va_qc va_s0 (fun va_s0
va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 286 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in
let (prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in let (n:Prims.nat) = FStar.Seq.Base.length #quad32 data in label va_range1
"***** POSTCONDITION NOT MET AT line 307 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(let xi = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 1 va_sM) in label va_range1
"***** POSTCONDITION NOT MET AT line 308 column 63 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.Math.Poly2.Bits_s.to_quad32 xi == Vale.AES.GHash_BE.ghash_incremental h_BE y_prev data)
/\ label va_range1
"***** POSTCONDITION NOT MET AT line 309 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(xi == Vale.Math.Poly2.Bits_s.of_quad32 (Vale.Math.Poly2.Bits_s.to_quad32 xi))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_ReduceLast h_BE y_prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_ReduceLast (va_code_ReduceLast ()) va_s0 h_BE y_prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_vec 0 va_sM (va_update_ok va_sM va_s0))))))))));
va_lemma_norm_mods ([va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- GhashUnroll_n
[@ "opaque_to_smt" va_qattr]
let va_code_GhashUnroll_n exactly2 =
(va_Block (va_CCons (if exactly2 then va_Block (va_CCons (va_code_MulAdd_unroll_2way ()) (va_CNil
())) else va_Block (va_CCons (va_code_MulAdd_unroll_1way ()) (va_CNil ()))) (va_CCons
(va_code_Vspltisw (va_op_vec_opr_vec 8) 0) (va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg
10) (-15872)) (va_CCons (va_code_Mtvsrws (va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10))
(va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4)
(va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) 4)
(va_CCons (va_code_ReduceLast ()) (va_CNil ())))))))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_GhashUnroll_n exactly2 =
(va_pbool_and (if exactly2 then va_pbool_and (va_codegen_success_MulAdd_unroll_2way ()) (va_ttrue
()) else va_pbool_and (va_codegen_success_MulAdd_unroll_1way ()) (va_ttrue ())) (va_pbool_and
(va_codegen_success_Vspltisw (va_op_vec_opr_vec 8) 0) (va_pbool_and
(va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 8) 4) (va_pbool_and (va_codegen_success_ReduceLast ()) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_GhashUnroll_n (va_mods:va_mods_t) (exactly2:bool) (in_b:buffer128) (index:nat)
(h_BE:quad32) (y_prev:quad32) (data:(seq quad32)) : (va_quickCode unit (va_code_GhashUnroll_n
exactly2)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in let
(prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in let (n:Prims.nat) = FStar.Seq.Base.length #quad32 data in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 361 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_qInlineIf va_mods exactly2 (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 363 column 27 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_MulAdd_unroll_2way in_b index h prev data) (va_QEmpty (())))) (qblock va_mods (fun
(va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 367 column 27 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_MulAdd_unroll_1way in_b index h prev data) (va_QEmpty (()))))) (fun (va_s:va_state)
va_g -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 369 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 8) 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 370 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (fun (va_s:va_state) _ -> let
(va_arg27:Vale.Def.Types_s.nat64) = (-15872) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 371 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg27 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 372 column 12 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 373 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 374 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) 4) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 375 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_ReduceLast h_BE y_prev data) (va_QEmpty (())))))))))))
[@"opaque_to_smt"]
let va_lemma_GhashUnroll_n va_b0 va_s0 exactly2 in_b index h_BE y_prev data =
let (va_mods:va_mods_t) = [va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec
4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_GhashUnroll_n va_mods exactly2 in_b index h_BE y_prev data in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_GhashUnroll_n exactly2) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 320 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in
let (prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in let (n:Prims.nat) = FStar.Seq.Base.length #quad32 data in label va_range1
"***** POSTCONDITION NOT MET AT line 359 column 52 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.GHash_BE.ghash_incremental h_BE y_prev data))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_GhashUnroll_n exactly2 in_b index h_BE y_prev data va_s0 va_k =
let (va_sM, va_f0) = va_lemma_GhashUnroll_n (va_code_GhashUnroll_n exactly2) va_s0 exactly2 in_b
index h_BE y_prev data in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM
(va_update_vec 8 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0))))))))))));
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Ghash_register
[@ "opaque_to_smt" va_qattr]
let va_code_Ghash_register () =
(va_Block (va_CCons (va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 5) Secret) (va_CCons (va_code_Vspltisw
(va_op_vec_opr_vec 0) 0) (va_CCons (va_code_VSwap (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5))
(va_CCons (va_code_High64ToLow (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 5)) (va_CCons
(va_code_Low64ToHigh (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 5)) (va_CCons (va_Block (va_CNil
())) (va_CCons (va_code_VPolyAdd (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec
9)) (va_CCons (va_code_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 7)) (va_CCons (va_code_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 5)) (va_CCons (va_code_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
9) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 8) 0) (va_CCons
(va_code_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_CCons (va_code_Mtvsrws
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10)) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 8)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) 4) (va_CCons (va_code_ReduceLast ()) (va_CNil
()))))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Ghash_register () =
(va_pbool_and (va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 5) Secret) (va_pbool_and (va_codegen_success_Vspltisw
(va_op_vec_opr_vec 0) 0) (va_pbool_and (va_codegen_success_VSwap (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_High64ToLow (va_op_vec_opr_vec 7)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_Low64ToHigh (va_op_vec_opr_vec 6)
(va_op_vec_opr_vec 5)) (va_pbool_and (va_codegen_success_VPolyAdd (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 9)) (va_pbool_and (va_codegen_success_VPolyMulLow
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 7)) (va_pbool_and
(va_codegen_success_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 5))
(va_pbool_and (va_codegen_success_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 9)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 8) 0)
(va_pbool_and (va_codegen_success_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (va_pbool_and
(va_codegen_success_Mtvsrws (va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4)
(va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 8) 4) (va_pbool_and (va_codegen_success_ReduceLast ()) (va_ttrue
()))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Ghash_register (va_mods:va_mods_t) (hkeys_b:buffer128) (h_BE:quad32) (y_prev:quad32) :
(va_quickCode unit (va_code_Ghash_register ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in let
(data:(FStar.Seq.Base.seq quad32)) = FStar.Seq.Base.create #quad32 1 (va_get_vec 9 va_s) in let
(prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 405 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 0) (va_op_vec_opr_vec 5)
(va_op_reg_opr_reg 5) Secret hkeys_b 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 406 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 0) 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 407 column 10 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VSwap (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5)) (fun (va_s:va_state) _ -> let
(va_arg71:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 408 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_quad32_double va_arg71) (let
(va_arg70:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 409 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Words.lemma_quad32_double_swap va_arg70) (let
(va_arg69:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.swap (Vale.AES.GHash_BE.gf128_power h 1) 64
in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 410 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_quad32_double va_arg69) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 411 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_High64ToLow (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 5) (Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 412 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Low64ToHigh (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 5) (Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64)) (fun (va_s:va_state) _ -> let
(va_arg68:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 413 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32 va_arg68) (let
(va_arg67:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 414 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Bits.lemma_of_to_quad32 va_arg67) (va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 416 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(0 >= 0 /\ (fun a_336 (s_337:(FStar.Seq.Base.seq a_336)) (i_338:Prims.nat) -> let
(i_312:Prims.nat) = i_338 in Prims.b2t (Prims.op_LessThan i_312 (FStar.Seq.Base.length #a_336
s_337))) quad32 data 0) (fun _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 416 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_vec 9 va_s == FStar.Seq.Base.index #quad32 data 0) (let (data_i:poly) = pdata 0 in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 419 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_gf128_power h 1) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 420 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyAdd (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 9)) (fun
(va_s:va_state) _ -> let (va_arg66:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div
(Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s)) (Vale.Math.Poly2_s.monomial 64) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 421 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_degree_negative va_arg66) (let
(va_arg65:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 422 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg65 64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 423 column 16 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulLow (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 7))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 424 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMul (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 5)) (fun
(va_s:va_state) _ -> let (va_arg64:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg63:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h
1) (Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 425 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_div_mod_exact va_arg63 va_arg64) (let
(va_arg62:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s) in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 426 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg62 64) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 427 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_VPolyMulHigh (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 9) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> let (va_arg61:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.monomial 64 in
let (va_arg60:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 428 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mod_mod va_arg60 va_arg61) (let
(va_arg59:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 429 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg59 64) (let
(va_arg58:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 430 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_mask_is_mod va_arg58 64) (let
(va_arg57:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 431 column 29 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_swap128_mask_shift va_arg57) (let
(va_arg56:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 432 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg56 64) (let
(va_arg55:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 433 column 23 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.Math.Poly2.Lemmas.lemma_shift_is_div va_arg55 64) (let
(va_arg54:Vale.Math.Poly2_s.poly) = Vale.AES.GHash_BE.gf128_power h 1 in let
(va_arg53:Vale.Math.Poly2_s.poly) = add prev data_i in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 434 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GF128.lemma_Mul128 va_arg53 va_arg54) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 436 column 13 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 8) 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 437 column 17 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) (-15872)) (fun (va_s:va_state) _ -> let
(va_arg52:Vale.Def.Types_s.nat64) = (-15872) `op_Modulus` pow2_64 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 438 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.Types_helpers.lemma_ishl_64 va_arg52 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 439 column 12 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 0) (va_op_reg_opr_reg 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 440 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 0) 4) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 441 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 8) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 8) 4) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 442 column 15 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_ReduceLast h_BE y_prev data) (va_QEmpty (()))))))))))))))))))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Ghash_register va_b0 va_s0 hkeys_b h_BE y_prev =
let (va_mods:va_mods_t) = [va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 7; va_Mod_vec 6;
va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg
10; va_Mod_ok] in
let va_qc = va_qcode_Ghash_register va_mods hkeys_b h_BE y_prev in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Ghash_register ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 378 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in
let (data:(FStar.Seq.Base.seq quad32)) = FStar.Seq.Base.create #quad32 1 (va_get_vec 9 va_s0)
in let (prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let
(pdata:(Prims.int -> Vale.AES.GHash_BE.poly128)) = Vale.AES.GHash_BE.fun_seq_quad32_BE_poly128
data in label va_range1
"***** POSTCONDITION NOT MET AT line 403 column 57 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.GHash_BE.ghash_incremental h_BE y_prev data))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 7; va_Mod_vec 6;
va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg
10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Ghash_register hkeys_b h_BE y_prev va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Ghash_register (va_code_Ghash_register ()) va_s0 hkeys_b h_BE
y_prev in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM
(va_update_vec 7 va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM
(va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))))))))))));
va_lemma_norm_mods ([va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 7; va_Mod_vec 6;
va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg
10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Ghash_buffer_loop_body
val va_code_Ghash_buffer_loop_body : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Ghash_buffer_loop_body () =
(va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_Block (va_CNil ())) (va_CCons
(va_code_GhashUnroll_n true) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_Block (va_CNil
())) (va_CCons (va_code_AddImm (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 7) 32) (va_CCons
(va_code_SubImm (va_op_reg_opr_reg 6) (va_op_reg_opr_reg 6) 2) (va_CNil ())))))))))
val va_codegen_success_Ghash_buffer_loop_body : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Ghash_buffer_loop_body () =
(va_pbool_and (va_codegen_success_GhashUnroll_n true) (va_pbool_and (va_codegen_success_AddImm
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 7) 32) (va_pbool_and (va_codegen_success_SubImm
(va_op_reg_opr_reg 6) (va_op_reg_opr_reg 6) 2) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Ghash_buffer_loop_body (va_mods:va_mods_t) (in_b:buffer128) (h_BE:quad32)
(y_prev:quad32) (old_len:nat64) (index:nat) : (va_quickCode unit (va_code_Ghash_buffer_loop_body
())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in let
(prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 501 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
((fun a_1582 (s_1583:(FStar.Seq.Base.seq a_1582)) (i_1584:Prims.nat) (j_1585:Prims.nat) -> let
(j_1545:Prims.nat) = j_1585 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1584
j_1545) (Prims.op_LessThanOrEqual j_1545 (FStar.Seq.Base.length #a_1582 s_1583))))
Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_s) in_b)) index (index + 2)) (fun _ -> let (data:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = FStar.Seq.Base.slice #Vale.Def.Types_s.quad32
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s)
in_b)) index (index + 2) in va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 502 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
((fun a_1582 (s_1583:(FStar.Seq.Base.seq a_1582)) (i_1584:Prims.nat) (j_1585:Prims.nat) -> let
(j_1545:Prims.nat) = j_1585 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1584
j_1545) (Prims.op_LessThanOrEqual j_1545 (FStar.Seq.Base.length #a_1582 s_1583))))
Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_s) in_b)) 0 index) (fun _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 502 column 18 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_GhashUnroll_n true in_b index h_BE (Vale.AES.GHash_BE.ghash_incremental0 h_BE y_prev
(FStar.Seq.Base.slice #Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s) in_b)) 0 index)) data) (fun
(va_s:va_state) _ -> va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 503 column 36 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
((fun a_1582 (s_1583:(FStar.Seq.Base.seq a_1582)) (i_1584:Prims.nat) (j_1585:Prims.nat) -> let
(j_1545:Prims.nat) = j_1585 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1584
j_1545) (Prims.op_LessThanOrEqual j_1545 (FStar.Seq.Base.length #a_1582 s_1583))))
Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_s) in_b)) 0 index) (fun _ -> let (va_arg27:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = FStar.Seq.Base.slice #Vale.Def.Types_s.quad32
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s)
in_b)) 0 index in let (va_arg26:Vale.Def.Types_s.quad32) = va_get_vec 1 va_s in let
(va_arg25:Vale.Def.Types_s.quad32) = va_get_vec 1 va_old_s in let
(va_arg24:Vale.Def.Types_s.quad32) = y_prev in let (va_arg23:Vale.Def.Types_s.quad32) = h_BE in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 503 column 36 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(fun (_:unit) -> Vale.AES.GHash_BE.lemma_ghash_incremental0_append va_arg23 va_arg24 va_arg25
va_arg26 va_arg27 data) (va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 505 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
((fun a_1582 (s_1583:(FStar.Seq.Base.seq a_1582)) (i_1584:Prims.nat) (j_1585:Prims.nat) -> let
(j_1545:Prims.nat) = j_1585 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1584
j_1545) (Prims.op_LessThanOrEqual j_1545 (FStar.Seq.Base.length #a_1582 s_1583))))
Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_s) in_b)) 0 index /\ (fun a_1582 (s_1583:(FStar.Seq.Base.seq a_1582))
(i_1584:Prims.nat) (j_1585:Prims.nat) -> let (j_1545:Prims.nat) = j_1585 in Prims.b2t
(Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1584 j_1545) (Prims.op_LessThanOrEqual j_1545
(FStar.Seq.Base.length #a_1582 s_1583)))) Vale.Def.Types_s.quad32
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s)
in_b)) 0 (index + 2)) (fun _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 505 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(FStar.Seq.Base.equal #Vale.Def.Types_s.quad32 (FStar.Seq.Base.append #Vale.Def.Types_s.quad32
(FStar.Seq.Base.slice #Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s) in_b)) 0 index) data)
(FStar.Seq.Base.slice #Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s) in_b)) 0 (index + 2))) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 507 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_AddImm (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 7) 32) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 508 column 11 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_quick_SubImm (va_op_reg_opr_reg 6) (va_op_reg_opr_reg 6) 2) (va_QEmpty (()))))))))))))
val va_lemma_Ghash_buffer_loop_body : va_b0:va_code -> va_s0:va_state -> in_b:buffer128 ->
h_BE:quad32 -> y_prev:quad32 -> old_len:nat64 -> index:nat
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Ghash_buffer_loop_body ()) va_s0 /\ va_get_ok va_s0 /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in let
(prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in va_get_reg 6 va_s0
>= 2 /\ index + va_get_reg 6 va_s0 == old_len /\ Vale.PPC64LE.Decls.validSrcAddrsOffset128
(va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0) in_b index (va_get_reg 6 va_s0)
(va_get_mem_layout va_s0) Secret /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b == old_len /\ va_get_reg 7 va_s0 + 16 `op_Multiply`
va_get_reg 6 va_s0 < pow2_64 /\ va_get_vec 1 va_s0 == Vale.AES.GHash_BE.ghash_incremental0 h_BE
y_prev (FStar.Seq.Base.slice #Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)) 0 index) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 6 va_s0)
== Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 1)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in let
(prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let index' = index +
2 in index' + va_get_reg 6 va_sM == old_len /\ Vale.PPC64LE.Decls.validSrcAddrsOffset128
(va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM) in_b index' (va_get_reg 6 va_sM)
(va_get_mem_layout va_sM) Secret /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b == old_len /\ va_get_reg 7 va_sM + 16 `op_Multiply`
va_get_reg 6 va_sM < pow2_64 /\ va_get_vec 1 va_sM == Vale.AES.GHash_BE.ghash_incremental0 h_BE
y_prev (FStar.Seq.Base.slice #Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) in_b)) 0 index') /\ va_get_reg 7 va_sM ==
va_get_reg 7 va_s0 + 32 /\ va_get_reg 6 va_sM == va_get_reg 6 va_s0 - 2) /\ va_state_eq va_sM
(va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM
(va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM
(va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_reg 6 va_sM (va_update_reg 7 va_sM
(va_update_ok va_sM va_s0)))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Ghash_buffer_loop_body va_b0 va_s0 in_b h_BE y_prev old_len index =
let (va_mods:va_mods_t) = [va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec
4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 6;
va_Mod_reg 7; va_Mod_ok] in
let va_qc = va_qcode_Ghash_buffer_loop_body va_mods in_b h_BE y_prev old_len index in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Ghash_buffer_loop_body ()) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 445 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM) /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in
let (prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in label va_range1
"***** POSTCONDITION NOT MET AT line 487 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(let index' = index + 2 in label va_range1
"***** POSTCONDITION NOT MET AT line 489 column 32 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(index' + va_get_reg 6 va_sM == old_len) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 492 column 84 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM)
in_b index' (va_get_reg 6 va_sM) (va_get_mem_layout va_sM) Secret) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 493 column 39 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b == old_len) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 494 column 38 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_reg 7 va_sM + 16 `op_Multiply` va_get_reg 6 va_sM < pow2_64) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 495 column 110 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.GHash_BE.ghash_incremental0 h_BE y_prev (FStar.Seq.Base.slice
#Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_sM) in_b)) 0 index')) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 498 column 37 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_reg 7 va_sM == va_get_reg 7 va_s0 + 32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 499 column 28 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_reg 6 va_sM == va_get_reg 6 va_s0 - 2)))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 6; va_Mod_reg
7; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Ghash_buffer_loop_body (in_b:buffer128) (h_BE:quad32) (y_prev:quad32) (old_len:nat64)
(index:nat) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (h:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 h_BE in
let (prev:Vale.Math.Poly2_s.poly) = Vale.Math.Poly2.Bits_s.of_quad32 y_prev in va_get_reg 6
va_s0 >= 2 /\ index + va_get_reg 6 va_s0 == old_len /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
in_b index (va_get_reg 6 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b == old_len /\ va_get_reg 7
va_s0 + 16 `op_Multiply` va_get_reg 6 va_s0 < pow2_64 /\ va_get_vec 1 va_s0 ==
Vale.AES.GHash_BE.ghash_incremental0 h_BE y_prev (FStar.Seq.Base.slice #Vale.Def.Types_s.quad32
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
in_b)) 0 index) /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 5 va_s0) ==
Vale.Math.Poly2.swap (Vale.AES.GHash_BE.gf128_power h 1) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32
(va_get_vec 6 va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div
(Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64))
(Vale.Math.Poly2_s.monomial 64) /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 7 va_s0) ==
Vale.Math.Poly2_s.mod (Vale.AES.GHash_BE.gf128_power h 1) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 12 va_s0) == Vale.Math.Poly2.swap
(Vale.AES.GHash_BE.gf128_power h 2) 64 /\ Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 13
va_s0) == Vale.Math.Poly2_s.mul (Vale.Math.Poly2_s.div (Vale.AES.GHash_BE.gf128_power h 2)
(Vale.Math.Poly2_s.monomial 64)) (Vale.Math.Poly2_s.monomial 64) /\
Vale.Math.Poly2.Bits_s.of_quad32 (va_get_vec 14 va_s0) == Vale.Math.Poly2_s.mod
(Vale.AES.GHash_BE.gf128_power h 2) (Vale.Math.Poly2_s.monomial 64)) /\ (forall (va_x_r7:nat64)
(va_x_r6:nat64) (va_x_r10:nat64) (va_x_v0:quad32) (va_x_v1:quad32) (va_x_v2:quad32)
(va_x_v3:quad32) (va_x_v4:quad32) (va_x_v8:quad32) (va_x_v9:quad32) (va_x_v10:quad32)
(va_x_v11:quad32) . let va_sM = va_upd_vec 11 va_x_v11 (va_upd_vec 10 va_x_v10 (va_upd_vec 9
va_x_v9 (va_upd_vec 8 va_x_v8 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2
(va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 (va_upd_reg 6 va_x_r6
(va_upd_reg 7 va_x_r7 va_s0))))))))))) in va_get_ok va_sM /\ (let (h:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 h_BE in let (prev:Vale.Math.Poly2_s.poly) =
Vale.Math.Poly2.Bits_s.of_quad32 y_prev in let index' = index + 2 in index' + va_get_reg 6
va_sM == old_len /\ Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_sM)
(va_get_reg 7 va_sM) in_b index' (va_get_reg 6 va_sM) (va_get_mem_layout va_sM) Secret /\
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b == old_len /\ va_get_reg 7
va_sM + 16 `op_Multiply` va_get_reg 6 va_sM < pow2_64 /\ va_get_vec 1 va_sM ==
Vale.AES.GHash_BE.ghash_incremental0 h_BE y_prev (FStar.Seq.Base.slice #Vale.Def.Types_s.quad32
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
in_b)) 0 index') /\ va_get_reg 7 va_sM == va_get_reg 7 va_s0 + 32 /\ va_get_reg 6 va_sM ==
va_get_reg 6 va_s0 - 2) ==> va_k va_sM (())))
val va_wpProof_Ghash_buffer_loop_body : in_b:buffer128 -> h_BE:quad32 -> y_prev:quad32 ->
old_len:nat64 -> index:nat -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Ghash_buffer_loop_body in_b h_BE y_prev old_len index
va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Ghash_buffer_loop_body ())
([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 6; va_Mod_reg 7]) va_s0
va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Ghash_buffer_loop_body in_b h_BE y_prev old_len index va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Ghash_buffer_loop_body (va_code_Ghash_buffer_loop_body ()) va_s0
in_b h_BE y_prev old_len index in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 11 va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM
(va_update_vec 8 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_reg 6 va_sM
(va_update_reg 7 va_sM (va_update_ok va_sM va_s0))))))))))))));
va_lemma_norm_mods ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 6; va_Mod_reg
7]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Ghash_buffer_loop_body (in_b:buffer128) (h_BE:quad32) (y_prev:quad32) (old_len:nat64)
(index:nat) : (va_quickCode unit (va_code_Ghash_buffer_loop_body ())) =
(va_QProc (va_code_Ghash_buffer_loop_body ()) ([va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9;
va_Mod_vec 8; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg
10; va_Mod_reg 6; va_Mod_reg 7]) (va_wp_Ghash_buffer_loop_body in_b h_BE y_prev old_len index)
(va_wpProof_Ghash_buffer_loop_body in_b h_BE y_prev old_len index))
//--
//-- Mod_cr0
val va_code_Mod_cr0 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Mod_cr0 () =
(va_Block (va_CNil ()))
val va_codegen_success_Mod_cr0 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Mod_cr0 () =
(va_ttrue ())
[@ "opaque_to_smt" va_qattr]
let va_qcode_Mod_cr0 (va_mods:va_mods_t) : (va_quickCode unit (va_code_Mod_cr0 ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QEmpty (())))
val va_lemma_Mod_cr0 : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Mod_cr0 ()) va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_state_eq va_sM (va_update_cr0 va_sM (va_update_ok va_sM va_s0))))
[@"opaque_to_smt"]
let va_lemma_Mod_cr0 va_b0 va_s0 =
let (va_mods:va_mods_t) = [va_Mod_cr0; va_Mod_ok] in
let va_qc = va_qcode_Mod_cr0 va_mods in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Mod_cr0 ()) va_qc va_s0 (fun va_s0
va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 511 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GHash.vaf *****"
(va_get_ok va_sM)) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_cr0; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Mod_cr0 (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (forall (va_x_cr0:cr0_t) . let va_sM = va_upd_cr0 va_x_cr0 va_s0 in va_get_ok
va_sM ==> va_k va_sM (())))
val va_wpProof_Mod_cr0 : va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Mod_cr0 va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Mod_cr0 ()) ([va_Mod_cr0]) va_s0 va_k
((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Mod_cr0 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mod_cr0 (va_code_Mod_cr0 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_cr0 va_sM (va_update_ok va_sM va_s0)));
va_lemma_norm_mods ([va_Mod_cr0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Mod_cr0 () : (va_quickCode unit (va_code_Mod_cr0 ())) =
(va_QProc (va_code_Mod_cr0 ()) ([va_Mod_cr0]) va_wp_Mod_cr0 va_wpProof_Mod_cr0)
//--
//-- Ghash_buffer_body0
val va_code_Ghash_buffer_body0 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr] | false | true | Vale.AES.PPC64LE.GHash.fst | {
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val va_code_Ghash_buffer_body0 : va_dummy:unit -> Tot va_code | [] | Vale.AES.PPC64LE.GHash.va_code_Ghash_buffer_body0 | {
"file_name": "obj/Vale.AES.PPC64LE.GHash.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | va_dummy: Prims.unit -> Vale.PPC64LE.Decls.va_code | {
"end_col": 10,
"end_line": 1389,
"start_col": 2,
"start_line": 1388
} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.