file_name
stringlengths 5
52
| name
stringlengths 4
95
| original_source_type
stringlengths 0
23k
| source_type
stringlengths 9
23k
| source_definition
stringlengths 9
57.9k
| source
dict | source_range
dict | file_context
stringlengths 0
721k
| dependencies
dict | opens_and_abbrevs
listlengths 2
94
| vconfig
dict | interleaved
bool 1
class | verbose_type
stringlengths 1
7.42k
| effect
stringclasses 118
values | effect_flags
sequencelengths 0
2
| mutual_with
sequencelengths 0
11
| ideal_premises
sequencelengths 0
236
| proof_features
sequencelengths 0
1
| is_simple_lemma
bool 2
classes | is_div
bool 2
classes | is_proof
bool 2
classes | is_simply_typed
bool 2
classes | is_type
bool 2
classes | partial_definition
stringlengths 5
3.99k
| completed_definiton
stringlengths 1
1.63M
| isa_cross_project_example
bool 1
class |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Vale.X64.Instructions_s.fsti | Vale.X64.Instructions_s.eval_AESNI_enc | val eval_AESNI_enc (src1 src2: quad32) : option quad32 | val eval_AESNI_enc (src1 src2: quad32) : option quad32 | let eval_AESNI_enc (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2)
else None | {
"file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 315,
"start_col": 0,
"start_line": 312
} | module Vale.X64.Instructions_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.CPU_Features_s
open Vale.X64.CryptoInstructions_s
open FStar.Seq.Base
let eval_Mov64 (src:nat64) : option nat64 = Some src
val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64
let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None
val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64
let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst)
val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64
let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst)
val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64
let eval_Add64 (dst src:nat64) : option (bool & nat64) =
let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64)
val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64
let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64)
val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64
let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_carry then 1 else 0) in
Some (sum >= pow2_64, sum % pow2_64)
val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64
let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_flag then 1 else 0) in
if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None
val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
let eval_Sub64 (dst src:nat64) : option (bool & nat64) =
let diff = dst - src in Some (diff < 0, diff % pow2_64)
val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64
let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let diff = dst - (src + (if old_carry then 1 else 0)) in
Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags)
val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64
let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) =
Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src)
val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64
let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) =
let hi = FStar.UInt.mul_div #64 rdx src in
let lo = FStar.UInt.mul_mod #64 rdx src in
if bmi2_enabled then Some (hi, lo) else None
val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64
let eval_IMul64 (dst src:nat64) : option nat64 =
Some (FStar.UInt.mul_mod #64 dst src)
val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64
let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src)
val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64
let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) =
Some (Vale.Def.Types_s.ixor dst src, (false, false))
val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64
let eval_Shr64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None
val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64
let eval_Shl64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None
val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64
let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) =
Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx)))
val ins_Cpuid :
instr_dep
[inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)]
[] PreserveFlags eval_Cpuid
// The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled.
// We underspecify XGETBV here to only support fetching XCR0, which
// is supported on any processor supporting the XGETBV instruction
let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) =
if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None
val ins_Xgetbv :
instr_dep
[out (one64Reg rRax); out (one64Reg rRdx)]
[one64Reg rRcx] PreserveFlags eval_Xgetbv
let check_avx (#a:Type0) (x:option a) : option a =
if avx_enabled then x else None
let check_sse2 (#a:Type0) (x:option a) : option a =
if sse2_enabled then x else None
let check_ssse3 (#a:Type0) (x:option a) : option a =
if ssse3_enabled then x else None
let check_sse4_1 (#a:Type0) (x:option a) : option a =
if sse4_1_enabled then x else None
let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src)
val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu
let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src))
val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor
let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2))
val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor
let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src))
val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand
let eval_Paddd_raw (src1 src2:quad32) : option quad32 =
Some (Mkfour
((src1.lo0 + src2.lo0) % pow2_32)
((src1.lo1 + src2.lo1) % pow2_32)
((src1.hi2 + src2.hi2) % pow2_32)
((src1.hi3 + src2.hi3) % pow2_32))
let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2)
val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd
let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2)
val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd
let eval_Pslld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None)
val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt)
let eval_Psrld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None)
val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt)
let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 (
if 0 <= amt && amt < 16 then
let src_bytes = le_quad32_to_bytes dst in
let zero_pad = Seq.create amt 0 in
let remaining_bytes = slice src_bytes amt (length src_bytes) in
Some (le_bytes_to_quad32 (append zero_pad remaining_bytes))
else None)
val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt)
let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if amount = 4 then
Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0)
else if amount = 8 then
Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1)
else None
let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_ssse3 (eval_Palignr_raw amount src1 src2)
val ins_Palignr (amount:nat8) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount)
let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_avx (eval_Palignr_raw amount src1 src2)
val ins_VPalignr (amount:nat8) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount)
let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 =
if 0 <= permutation && permutation < 4 then
Some (Mkfour
(if permutation % 2 = 0 then src1.lo0 else src1.hi2)
(if permutation % 2 = 0 then src1.lo1 else src1.hi3)
(if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2)
(if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3))
else None
let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_sse2 (eval_Shufpd_raw permutation src1 src2)
val ins_Shufpd (permutation:int) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation)
let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Shufpd_raw permutation src1 src2)
val ins_VShufpd (permutation:int) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation)
let is_full_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x04050607 &&
q.hi3 = 0x00010203
let is_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x00010203 &&
q.lo1 = 0x04050607 &&
q.hi2 = 0x08090A0B &&
q.hi3 = 0x0C0D0E0F
let is_high_dup_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let is_lower_upper_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x04050607 &&
q.lo1 = 0x00010203 &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let eval_Pshufb_raw (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if is_full_byte_reversal_mask src2 then
Some (reverse_bytes_quad32 src1)
else if is_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3))
else if is_high_dup_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else if is_lower_upper_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else None
let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2)
val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb
let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2)
val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb
let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 (
let bits:bits_of_byte = byte_to_twobits permutation in
Some (Mkfour
(select_word src bits.lo0)
(select_word src bits.lo1)
(select_word src bits.hi2)
(select_word src bits.hi3)))
val ins_Pshufd (permutation:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation)
let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 (
let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in
Some (Mkfour
(eq_result (src.lo0 = dst.lo0))
(eq_result (src.lo1 = dst.lo1))
(eq_result (src.hi2 = dst.hi2))
(eq_result (src.hi3 = dst.hi3))))
val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd
let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 (
let src_two = four_to_two_two src in
Some (two_to_nat 32 (two_select src_two (index % 2))))
val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index)
let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4)))
val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index)
let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat64_def dst src (index % 2)))
val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index)
let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the two very special cases we need
if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2)
else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1)
else None
let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src)
val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count)
let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the one very special case we need
if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0)
else None
let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src)
val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count)
let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
let Mkfour a0 a1 a2 a3 = src1 in
let Mkfour b0 b1 b2 b3 = src2 in
let f x0 x1 y0 y1 =
let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in
let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y)
in
if pclmulqdq_enabled then
match imm with
| 0 -> Some (f a0 a1 b0 b1)
| 1 -> Some (f a2 a3 b0 b1)
| 16 -> Some (f a0 a1 b2 b3)
| 17 -> Some (f a2 a3 b2 b3)
| _ -> None
else None
val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm)
let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Pclmulqdq imm src1 src2)
val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instructions_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | src1: Vale.X64.Machine_s.quad32 -> src2: Vale.X64.Machine_s.quad32
-> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32 | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Machine_s.quad32",
"Vale.X64.CPU_Features_s.aesni_enabled",
"FStar.Pervasives.Native.Some",
"Vale.Def.Types_s.quad32_xor",
"Vale.AES.AES_s.mix_columns_LE",
"Vale.AES.AES_common_s.sub_bytes",
"Vale.AES.AES_s.shift_rows_LE",
"Prims.bool",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | true | false | let eval_AESNI_enc (src1 src2: quad32) : option quad32 =
| if aesni_enabled
then
Some
(quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE
src1)))
src2)
else None | false |
Vale.AES.X64.GCMdecryptOpt.fst | Vale.AES.X64.GCMdecryptOpt.va_wpProof_Gcm_blocks128 | val va_wpProof_Gcm_blocks128 : alg:algorithm -> in_b:buffer128 -> out_b:buffer128 -> key:(seq
nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> h_LE: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_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b
h_LE va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks128 alg) ([va_Mod_flags;
va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6;
va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0;
va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10; va_Mod_reg64 rR11; va_Mod_reg64 rRdi;
va_Mod_reg64 rRbx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) | val va_wpProof_Gcm_blocks128 : alg:algorithm -> in_b:buffer128 -> out_b:buffer128 -> key:(seq
nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> h_LE: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_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b
h_LE va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks128 alg) ([va_Mod_flags;
va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6;
va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0;
va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10; va_Mod_reg64 rR11; va_Mod_reg64 rRdi;
va_Mod_reg64 rRbx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) | let va_wpProof_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_blocks128 (va_code_Gcm_blocks128 alg) va_s0 alg in_b out_b key
round_keys keys_b hkeys_b h_LE in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 1 va_sM (va_update_xmm 10
va_sM (va_update_xmm 11 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6
va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2
va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR12 va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rRdi va_sM (va_update_reg64 rRbx va_sM (va_update_ok va_sM (va_update_mem
va_sM va_s0))))))))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm
8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2;
va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | {
"file_name": "obj/Vale.AES.X64.GCMdecryptOpt.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 481,
"start_col": 0,
"start_line": 465
} | module Vale.AES.X64.GCMdecryptOpt
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open FStar.Seq
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_s
open Vale.AES.GCTR_s
open Vale.AES.GCTR
open Vale.AES.GCM
open Vale.AES.GHash_s
open Vale.AES.GHash
open Vale.AES.GCM_s
open Vale.AES.X64.AES
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.Poly1305.Math
open Vale.AES.GCM_helpers
open Vale.AES.X64.GHash
open Vale.AES.X64.GCTR
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.X64.Stack_i
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.InsBasic
open Vale.X64.InsMem
open Vale.X64.InsVector
open Vale.X64.InsStack
open Vale.X64.InsAes
open Vale.X64.QuickCode
open Vale.X64.QuickCodes
open Vale.AES.X64.GF128_Mul
open Vale.X64.Stack
open Vale.X64.CPU_Features_s
open Vale.Math.Poly2.Bits_s
open Vale.AES.X64.AESopt
open Vale.AES.X64.AESGCM
open Vale.AES.X64.AESopt2
open Vale.Lib.Meta
open Vale.AES.X64.GCMencryptOpt
open Vale.AES.OptPublic
open Vale.Lib.Basic
#reset-options "--z3rlimit 20 --max_ifuel 0"
//-- Gcm_extra_bytes
val va_code_Gcm_extra_bytes : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_extra_bytes alg =
(va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0)
(va_op_reg_opr64_reg64 rRax) 0 Secret) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 10)
(va_op_xmm_xmm 0)) (va_CCons (va_code_Ghash_extra_bytes ()) (va_CCons (va_code_Mov128
(va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_CCons (va_code_Pshufb (va_op_xmm_xmm 0)
(va_op_xmm_xmm 9)) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons (va_code_Pxor
(va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_CCons (va_code_Store128_buffer
(va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret)
(va_CNil ()))))))))))
val va_codegen_success_Gcm_extra_bytes : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_extra_bytes alg =
(va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0)
(va_op_reg_opr64_reg64 rRax) 0 Secret) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm
10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Ghash_extra_bytes ()) (va_pbool_and
(va_codegen_success_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_pbool_and
(va_codegen_success_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and
(va_codegen_success_AESEncryptBlock alg) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm
10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Store128_buffer
(va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret)
(va_ttrue ())))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_extra_bytes (va_mods:va_mods_t) (alg:algorithm) (inout_b:buffer128) (key:(seq
nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat)
(old_hash:quad32) (completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit
(va_code_Gcm_extra_bytes alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (len:(va_int_range
1 1)) = 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 188 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRax) 0 Secret inout_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 189 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (fun (va_s:va_state) _ -> let
(hash_input:quad32) = va_get_xmm 0 va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 193 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_extra_bytes hkeys_b total_bytes old_hash h_LE completed_quads) (fun
(va_s:va_state) _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 194 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.equal #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s)
inout_b) (FStar.Seq.Base.create #quad32 1 hash_input)) (let (snap:(FStar.Seq.Base.seq
Vale.X64.Decls.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 198 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 199 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 200 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AESEncryptBlock alg (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 11 va_s)) key
round_keys keys_b) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 201 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.AES_s.aes_encrypt_LE_reveal ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 204 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 205 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax)
(va_op_xmm_xmm 10) 0 Secret inout_b 0) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 207 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.gctr_partial_reveal ()) (va_QEmpty (()))))))))))))))
val va_lemma_Gcm_extra_bytes : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
inout_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> total_bytes:nat -> old_hash:quad32 -> completed_quads:(seq quad32) ->
h_LE:quad32
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_extra_bytes alg) va_s0 /\ va_get_ok va_s0 /\ (let
(len:(va_int_range 1 1)) = 1 in sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b
inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b inout_b /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax va_s0) inout_b
len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys
keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0
va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32
(Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length
#quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply`
FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes
`op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16
`op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
(Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads =
FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0)
inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes =
Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) /\ va_state_eq va_sM
(va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM (va_update_ok va_sM
(va_update_mem va_sM va_s0))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_extra_bytes va_b0 va_s0 alg inout_b key round_keys keys_b hkeys_b total_bytes
old_hash completed_quads h_LE =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_extra_bytes va_mods alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_extra_bytes alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 121 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (len:(va_int_range 1 1)) = 1 in label va_range1
"***** POSTCONDITION NOT MET AT line 174 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 177 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg len (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0)) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 180 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let raw_quads = FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 181 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 182 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 183 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let input_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 186 column 59 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(l_and (FStar.Seq.Base.length #Vale.Def.Types_s.quad32 input_quads > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE old_hash input_quads)))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm
7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32)
(completed_quads:(seq quad32)) (h_LE:quad32) (va_s0:va_state) (va_k:(va_state -> unit -> Type0))
: Type0 =
(va_get_ok va_s0 /\ (let (len:(va_int_range 1 1)) = 1 in sse_enabled /\
Vale.X64.Decls.buffers_disjoint128 keys_b inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b
inout_b /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax
va_s0) inout_b len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys
keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0
va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32
(Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length
#quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply`
FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes
`op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16
`op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
(Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes) /\ (forall
(va_x_mem:vale_heap) (va_x_rcx:nat64) (va_x_r11:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32)
(va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32)
(va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm10:quad32) (va_x_heap5:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 5
va_x_heap5 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7
(va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3
(va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR11
va_x_r11 (va_upd_reg64 rRcx va_x_rcx (va_upd_mem va_x_mem va_s0)))))))))))))) in va_get_ok
va_sM /\ (let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads =
FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0)
inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes =
Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) ==> va_k va_sM (())))
val va_wpProof_Gcm_extra_bytes : alg:algorithm -> inout_b:buffer128 -> key:(seq nat32) ->
round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> total_bytes:nat ->
old_hash:quad32 -> completed_quads:(seq quad32) -> h_LE: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_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_extra_bytes alg) ([va_Mod_flags;
va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5;
va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11;
va_Mod_reg64 rRcx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash
completed_quads h_LE va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_extra_bytes (va_code_Gcm_extra_bytes alg) va_s0 alg inout_b key
round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10
va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm
7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32)
(completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit (va_code_Gcm_extra_bytes alg)) =
(va_QProc (va_code_Gcm_extra_bytes alg) ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10;
va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm
2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem])
(va_wp_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash
completed_quads h_LE) (va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE))
//--
//-- Gcm_blocks128
val va_code_Gcm_blocks128 : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks128 alg =
(va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi))
(va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_CCons
(va_code_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_CCons
(va_code_Ghash_buffer ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdi)
(va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx)
(va_op_opr64_reg64 rR12)) (va_CCons (va_code_Gctr_blocks128 alg) (va_CNil ())))))))))
val va_codegen_success_Gcm_blocks128 : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks128 alg =
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi))
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx))
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax))
(va_pbool_and (va_codegen_success_Ghash_buffer ()) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_pbool_and
(va_codegen_success_Gctr_blocks128 alg) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks128 (va_mods:va_mods_t) (alg:algorithm) (in_b:buffer128) (out_b:buffer128)
(key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32)
: (va_quickCode unit (va_code_Gcm_blocks128 alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 274 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 275 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 276 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 277 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_buffer hkeys_b in_b h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_old_s))) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 278 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 279 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 280 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gctr_blocks128 alg in_b out_b key round_keys keys_b) (va_QEmpty (()))))))))))
val va_lemma_Gcm_blocks128 : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> in_b:buffer128 ->
out_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> h_LE:quad32
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks128 alg) va_s0 /\ va_get_ok va_s0 /\
(sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b out_b /\
Vale.X64.Decls.buffers_disjoint128 hkeys_b out_b /\ (Vale.X64.Decls.buffers_disjoint128 in_b
out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16
`op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply`
va_get_reg64 rRdx va_s0 < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b)
(Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx
va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\
va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8
va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0)
(va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM ==
va_get_xmm 8 va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b ==
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ (va_get_reg64 rRdx va_s0 > 0 ==>
l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==> FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b)))) /\ va_state_eq va_sM (va_update_flags va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 10 va_sM (va_update_xmm 11 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rR10 va_sM
(va_update_reg64 rR11 va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRbx va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_blocks128 va_b0 va_s0 alg in_b out_b key round_keys keys_b hkeys_b h_LE =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11;
va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm
2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks128 va_mods alg in_b out_b key round_keys keys_b hkeys_b h_LE in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks128 alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 210 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 255 column 53 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 261 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 262 column 45 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0) (va_get_reg64 rRdx
va_s0)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 265 column 93 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM == va_get_xmm 8 va_s0)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b == Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) out_b)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 267 column 131 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRdx va_s0 > 0 ==> l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==>
FStar.Seq.Base.length #Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm
8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2;
va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_blocks128 (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32) (va_s0:va_state)
(va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b out_b /\
Vale.X64.Decls.buffers_disjoint128 hkeys_b out_b /\ (Vale.X64.Decls.buffers_disjoint128 in_b
out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16
`op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply`
va_get_reg64 rRdx va_s0 < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b)
(Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx
va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\
va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8
va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret) /\ (forall (va_x_mem:vale_heap) (va_x_rbx:nat64) (va_x_rdi:nat64) (va_x_r11:nat64)
(va_x_r10:nat64) (va_x_rdx:nat64) (va_x_r12:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32)
(va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32)
(va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm11:quad32) (va_x_xmm10:quad32)
(va_x_heap1:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 11 va_x_xmm11
(va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5
(va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1
(va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64
rR10 va_x_r10 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRbx
va_x_rbx (va_upd_mem va_x_mem va_s0))))))))))))))))))) in va_get_ok va_sM /\
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0)
(va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM ==
va_get_xmm 8 va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b ==
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ (va_get_reg64 rRdx va_s0 > 0 ==>
l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==> FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b)))) ==> va_k va_sM (())))
val va_wpProof_Gcm_blocks128 : alg:algorithm -> in_b:buffer128 -> out_b:buffer128 -> key:(seq
nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> h_LE: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_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b
h_LE va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks128 alg) ([va_Mod_flags;
va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6;
va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0;
va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10; va_Mod_reg64 rR11; va_Mod_reg64 rRdi;
va_Mod_reg64 rRbx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Stack.fsti.checked",
"Vale.X64.QuickCodes.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.InsVector.fsti.checked",
"Vale.X64.InsStack.fsti.checked",
"Vale.X64.InsMem.fsti.checked",
"Vale.X64.InsBasic.fsti.checked",
"Vale.X64.InsAes.fsti.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Lib.Meta.fsti.checked",
"Vale.Lib.Basic.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_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",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.X64.GHash.fsti.checked",
"Vale.AES.X64.GF128_Mul.fsti.checked",
"Vale.AES.X64.GCTR.fsti.checked",
"Vale.AES.X64.GCMencryptOpt.fsti.checked",
"Vale.AES.X64.AESopt2.fsti.checked",
"Vale.AES.X64.AESopt.fsti.checked",
"Vale.AES.X64.AESGCM.fsti.checked",
"Vale.AES.X64.AES.fsti.checked",
"Vale.AES.OptPublic.fsti.checked",
"Vale.AES.GHash_s.fst.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_s.fst.checked",
"Vale.AES.GCTR.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"Vale.AES.GCM.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_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.X64.GCMdecryptOpt.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Lib.Basic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"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.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_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": "Vale.Def.Types_s",
"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": "FStar.Seq",
"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.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"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.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_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": "Vale.Def.Types_s",
"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": "FStar.Seq",
"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.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
alg: Vale.AES.AES_common_s.algorithm ->
in_b: Vale.X64.Memory.buffer128 ->
out_b: Vale.X64.Memory.buffer128 ->
key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 ->
round_keys: FStar.Seq.Base.seq Vale.X64.Decls.quad32 ->
keys_b: Vale.X64.Memory.buffer128 ->
hkeys_b: Vale.X64.Memory.buffer128 ->
h_LE: Vale.X64.Decls.quad32 ->
va_s0: Vale.X64.Decls.va_state ->
va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit) | Prims.Ghost | [] | [] | [
"Vale.AES.AES_common_s.algorithm",
"Vale.X64.Memory.buffer128",
"FStar.Seq.Base.seq",
"Vale.X64.Memory.nat32",
"Vale.X64.Decls.quad32",
"Vale.X64.Decls.va_state",
"Prims.unit",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple3",
"Vale.X64.QuickCode.va_lemma_norm_mods",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_Mod_flags",
"Vale.X64.QuickCode.va_Mod_mem_heaplet",
"Vale.X64.QuickCode.va_Mod_xmm",
"Vale.X64.QuickCode.va_Mod_reg64",
"Vale.X64.Machine_s.rR12",
"Vale.X64.Machine_s.rRdx",
"Vale.X64.Machine_s.rR10",
"Vale.X64.Machine_s.rR11",
"Vale.X64.Machine_s.rRdi",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.QuickCode.va_Mod_mem",
"Prims.Nil",
"Prims._assert",
"Vale.X64.Decls.va_state_eq",
"Vale.X64.Decls.va_update_flags",
"Vale.X64.Decls.va_update_mem_heaplet",
"Vale.X64.Decls.va_update_xmm",
"Vale.X64.Decls.va_update_reg64",
"Vale.X64.Decls.va_update_ok",
"Vale.X64.Decls.va_update_mem",
"Vale.X64.Decls.va_lemma_upd_update",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.State.vale_state",
"Vale.AES.X64.GCMdecryptOpt.va_lemma_Gcm_blocks128",
"Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_blocks128"
] | [] | false | false | false | false | false | let va_wpProof_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE va_s0 va_k =
| let va_sM, va_f0 =
va_lemma_Gcm_blocks128 (va_code_Gcm_blocks128 alg) va_s0 alg in_b out_b key round_keys keys_b
hkeys_b h_LE
in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM
(va_update_flags va_sM
(va_update_mem_heaplet 1
va_sM
(va_update_xmm 10
va_sM
(va_update_xmm 11
va_sM
(va_update_xmm 8
va_sM
(va_update_xmm 7
va_sM
(va_update_xmm 6
va_sM
(va_update_xmm 5
va_sM
(va_update_xmm 4
va_sM
(va_update_xmm 3
va_sM
(va_update_xmm 2
va_sM
(va_update_xmm 1
va_sM
(va_update_xmm 0
va_sM
(va_update_reg64 rR12
va_sM
(va_update_reg64 rRdx
va_sM
(va_update_reg64 rR10
va_sM
(va_update_reg64 rR11
va_sM
(va_update_reg64 rRdi
va_sM
(va_update_reg64 rRbx
va_sM
(va_update_ok va_sM
(va_update_mem
va_sM
va_s0)))))
)))))))))))))))));
va_lemma_norm_mods ([
va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10; va_Mod_reg64 rR11;
va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_mem
])
va_sM
va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | false |
Vale.X64.Instructions_s.fsti | Vale.X64.Instructions_s.eval_VAESNI_enc | val eval_VAESNI_enc (src1 src2: quad32) : option quad32 | val eval_VAESNI_enc (src1 src2: quad32) : option quad32 | let eval_VAESNI_enc (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc src1 src2) | {
"file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 93,
"end_line": 318,
"start_col": 0,
"start_line": 318
} | module Vale.X64.Instructions_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.CPU_Features_s
open Vale.X64.CryptoInstructions_s
open FStar.Seq.Base
let eval_Mov64 (src:nat64) : option nat64 = Some src
val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64
let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None
val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64
let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst)
val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64
let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst)
val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64
let eval_Add64 (dst src:nat64) : option (bool & nat64) =
let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64)
val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64
let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64)
val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64
let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_carry then 1 else 0) in
Some (sum >= pow2_64, sum % pow2_64)
val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64
let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_flag then 1 else 0) in
if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None
val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
let eval_Sub64 (dst src:nat64) : option (bool & nat64) =
let diff = dst - src in Some (diff < 0, diff % pow2_64)
val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64
let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let diff = dst - (src + (if old_carry then 1 else 0)) in
Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags)
val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64
let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) =
Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src)
val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64
let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) =
let hi = FStar.UInt.mul_div #64 rdx src in
let lo = FStar.UInt.mul_mod #64 rdx src in
if bmi2_enabled then Some (hi, lo) else None
val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64
let eval_IMul64 (dst src:nat64) : option nat64 =
Some (FStar.UInt.mul_mod #64 dst src)
val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64
let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src)
val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64
let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) =
Some (Vale.Def.Types_s.ixor dst src, (false, false))
val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64
let eval_Shr64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None
val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64
let eval_Shl64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None
val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64
let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) =
Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx)))
val ins_Cpuid :
instr_dep
[inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)]
[] PreserveFlags eval_Cpuid
// The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled.
// We underspecify XGETBV here to only support fetching XCR0, which
// is supported on any processor supporting the XGETBV instruction
let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) =
if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None
val ins_Xgetbv :
instr_dep
[out (one64Reg rRax); out (one64Reg rRdx)]
[one64Reg rRcx] PreserveFlags eval_Xgetbv
let check_avx (#a:Type0) (x:option a) : option a =
if avx_enabled then x else None
let check_sse2 (#a:Type0) (x:option a) : option a =
if sse2_enabled then x else None
let check_ssse3 (#a:Type0) (x:option a) : option a =
if ssse3_enabled then x else None
let check_sse4_1 (#a:Type0) (x:option a) : option a =
if sse4_1_enabled then x else None
let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src)
val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu
let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src))
val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor
let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2))
val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor
let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src))
val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand
let eval_Paddd_raw (src1 src2:quad32) : option quad32 =
Some (Mkfour
((src1.lo0 + src2.lo0) % pow2_32)
((src1.lo1 + src2.lo1) % pow2_32)
((src1.hi2 + src2.hi2) % pow2_32)
((src1.hi3 + src2.hi3) % pow2_32))
let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2)
val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd
let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2)
val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd
let eval_Pslld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None)
val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt)
let eval_Psrld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None)
val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt)
let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 (
if 0 <= amt && amt < 16 then
let src_bytes = le_quad32_to_bytes dst in
let zero_pad = Seq.create amt 0 in
let remaining_bytes = slice src_bytes amt (length src_bytes) in
Some (le_bytes_to_quad32 (append zero_pad remaining_bytes))
else None)
val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt)
let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if amount = 4 then
Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0)
else if amount = 8 then
Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1)
else None
let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_ssse3 (eval_Palignr_raw amount src1 src2)
val ins_Palignr (amount:nat8) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount)
let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_avx (eval_Palignr_raw amount src1 src2)
val ins_VPalignr (amount:nat8) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount)
let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 =
if 0 <= permutation && permutation < 4 then
Some (Mkfour
(if permutation % 2 = 0 then src1.lo0 else src1.hi2)
(if permutation % 2 = 0 then src1.lo1 else src1.hi3)
(if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2)
(if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3))
else None
let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_sse2 (eval_Shufpd_raw permutation src1 src2)
val ins_Shufpd (permutation:int) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation)
let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Shufpd_raw permutation src1 src2)
val ins_VShufpd (permutation:int) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation)
let is_full_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x04050607 &&
q.hi3 = 0x00010203
let is_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x00010203 &&
q.lo1 = 0x04050607 &&
q.hi2 = 0x08090A0B &&
q.hi3 = 0x0C0D0E0F
let is_high_dup_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let is_lower_upper_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x04050607 &&
q.lo1 = 0x00010203 &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let eval_Pshufb_raw (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if is_full_byte_reversal_mask src2 then
Some (reverse_bytes_quad32 src1)
else if is_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3))
else if is_high_dup_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else if is_lower_upper_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else None
let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2)
val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb
let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2)
val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb
let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 (
let bits:bits_of_byte = byte_to_twobits permutation in
Some (Mkfour
(select_word src bits.lo0)
(select_word src bits.lo1)
(select_word src bits.hi2)
(select_word src bits.hi3)))
val ins_Pshufd (permutation:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation)
let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 (
let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in
Some (Mkfour
(eq_result (src.lo0 = dst.lo0))
(eq_result (src.lo1 = dst.lo1))
(eq_result (src.hi2 = dst.hi2))
(eq_result (src.hi3 = dst.hi3))))
val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd
let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 (
let src_two = four_to_two_two src in
Some (two_to_nat 32 (two_select src_two (index % 2))))
val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index)
let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4)))
val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index)
let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat64_def dst src (index % 2)))
val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index)
let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the two very special cases we need
if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2)
else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1)
else None
let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src)
val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count)
let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the one very special case we need
if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0)
else None
let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src)
val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count)
let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
let Mkfour a0 a1 a2 a3 = src1 in
let Mkfour b0 b1 b2 b3 = src2 in
let f x0 x1 y0 y1 =
let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in
let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y)
in
if pclmulqdq_enabled then
match imm with
| 0 -> Some (f a0 a1 b0 b1)
| 1 -> Some (f a2 a3 b0 b1)
| 16 -> Some (f a0 a1 b2 b3)
| 17 -> Some (f a2 a3 b2 b3)
| _ -> None
else None
val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm)
let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Pclmulqdq imm src1 src2)
val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm)
let eval_AESNI_enc (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2)
else None
val ins_AESNI_enc : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instructions_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | src1: Vale.X64.Machine_s.quad32 -> src2: Vale.X64.Machine_s.quad32
-> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32 | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Machine_s.quad32",
"Vale.X64.Instructions_s.check_avx",
"Vale.X64.Instructions_s.eval_AESNI_enc",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | true | false | let eval_VAESNI_enc (src1 src2: quad32) : option quad32 =
| check_avx (eval_AESNI_enc src1 src2) | false |
Vale.X64.Instructions_s.fsti | Vale.X64.Instructions_s.eval_Psrldq_8_raw | val eval_Psrldq_8_raw (count: nat8) (src: quad32) : option quad32 | val eval_Psrldq_8_raw (count: nat8) (src: quad32) : option quad32 | let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the one very special case we need
if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0)
else None | {
"file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 286,
"start_col": 0,
"start_line": 283
} | module Vale.X64.Instructions_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.CPU_Features_s
open Vale.X64.CryptoInstructions_s
open FStar.Seq.Base
let eval_Mov64 (src:nat64) : option nat64 = Some src
val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64
let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None
val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64
let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst)
val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64
let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst)
val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64
let eval_Add64 (dst src:nat64) : option (bool & nat64) =
let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64)
val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64
let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64)
val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64
let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_carry then 1 else 0) in
Some (sum >= pow2_64, sum % pow2_64)
val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64
let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_flag then 1 else 0) in
if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None
val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
let eval_Sub64 (dst src:nat64) : option (bool & nat64) =
let diff = dst - src in Some (diff < 0, diff % pow2_64)
val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64
let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let diff = dst - (src + (if old_carry then 1 else 0)) in
Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags)
val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64
let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) =
Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src)
val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64
let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) =
let hi = FStar.UInt.mul_div #64 rdx src in
let lo = FStar.UInt.mul_mod #64 rdx src in
if bmi2_enabled then Some (hi, lo) else None
val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64
let eval_IMul64 (dst src:nat64) : option nat64 =
Some (FStar.UInt.mul_mod #64 dst src)
val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64
let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src)
val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64
let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) =
Some (Vale.Def.Types_s.ixor dst src, (false, false))
val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64
let eval_Shr64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None
val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64
let eval_Shl64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None
val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64
let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) =
Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx)))
val ins_Cpuid :
instr_dep
[inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)]
[] PreserveFlags eval_Cpuid
// The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled.
// We underspecify XGETBV here to only support fetching XCR0, which
// is supported on any processor supporting the XGETBV instruction
let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) =
if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None
val ins_Xgetbv :
instr_dep
[out (one64Reg rRax); out (one64Reg rRdx)]
[one64Reg rRcx] PreserveFlags eval_Xgetbv
let check_avx (#a:Type0) (x:option a) : option a =
if avx_enabled then x else None
let check_sse2 (#a:Type0) (x:option a) : option a =
if sse2_enabled then x else None
let check_ssse3 (#a:Type0) (x:option a) : option a =
if ssse3_enabled then x else None
let check_sse4_1 (#a:Type0) (x:option a) : option a =
if sse4_1_enabled then x else None
let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src)
val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu
let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src))
val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor
let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2))
val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor
let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src))
val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand
let eval_Paddd_raw (src1 src2:quad32) : option quad32 =
Some (Mkfour
((src1.lo0 + src2.lo0) % pow2_32)
((src1.lo1 + src2.lo1) % pow2_32)
((src1.hi2 + src2.hi2) % pow2_32)
((src1.hi3 + src2.hi3) % pow2_32))
let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2)
val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd
let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2)
val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd
let eval_Pslld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None)
val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt)
let eval_Psrld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None)
val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt)
let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 (
if 0 <= amt && amt < 16 then
let src_bytes = le_quad32_to_bytes dst in
let zero_pad = Seq.create amt 0 in
let remaining_bytes = slice src_bytes amt (length src_bytes) in
Some (le_bytes_to_quad32 (append zero_pad remaining_bytes))
else None)
val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt)
let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if amount = 4 then
Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0)
else if amount = 8 then
Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1)
else None
let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_ssse3 (eval_Palignr_raw amount src1 src2)
val ins_Palignr (amount:nat8) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount)
let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_avx (eval_Palignr_raw amount src1 src2)
val ins_VPalignr (amount:nat8) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount)
let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 =
if 0 <= permutation && permutation < 4 then
Some (Mkfour
(if permutation % 2 = 0 then src1.lo0 else src1.hi2)
(if permutation % 2 = 0 then src1.lo1 else src1.hi3)
(if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2)
(if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3))
else None
let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_sse2 (eval_Shufpd_raw permutation src1 src2)
val ins_Shufpd (permutation:int) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation)
let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Shufpd_raw permutation src1 src2)
val ins_VShufpd (permutation:int) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation)
let is_full_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x04050607 &&
q.hi3 = 0x00010203
let is_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x00010203 &&
q.lo1 = 0x04050607 &&
q.hi2 = 0x08090A0B &&
q.hi3 = 0x0C0D0E0F
let is_high_dup_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let is_lower_upper_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x04050607 &&
q.lo1 = 0x00010203 &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let eval_Pshufb_raw (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if is_full_byte_reversal_mask src2 then
Some (reverse_bytes_quad32 src1)
else if is_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3))
else if is_high_dup_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else if is_lower_upper_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else None
let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2)
val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb
let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2)
val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb
let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 (
let bits:bits_of_byte = byte_to_twobits permutation in
Some (Mkfour
(select_word src bits.lo0)
(select_word src bits.lo1)
(select_word src bits.hi2)
(select_word src bits.hi3)))
val ins_Pshufd (permutation:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation)
let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 (
let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in
Some (Mkfour
(eq_result (src.lo0 = dst.lo0))
(eq_result (src.lo1 = dst.lo1))
(eq_result (src.hi2 = dst.hi2))
(eq_result (src.hi3 = dst.hi3))))
val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd
let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 (
let src_two = four_to_two_two src in
Some (two_to_nat 32 (two_select src_two (index % 2))))
val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index)
let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4)))
val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index)
let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat64_def dst src (index % 2)))
val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index)
let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the two very special cases we need
if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2)
else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1)
else None
let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src)
val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instructions_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | count: Vale.Def.Types_s.nat8 -> src: Vale.X64.Machine_s.quad32
-> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32 | Prims.Tot | [
"total"
] | [] | [
"Vale.Def.Types_s.nat8",
"Vale.X64.Machine_s.quad32",
"Prims.op_Equality",
"Prims.int",
"FStar.Pervasives.Native.Some",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Prims.bool",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | true | false | let eval_Psrldq_8_raw (count: nat8) (src: quad32) : option quad32 =
| if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0) else None | false |
Vale.X64.Instructions_s.fsti | Vale.X64.Instructions_s.eval_Comment | val eval_Comment:option unit | val eval_Comment:option unit | let eval_Comment : option unit = Some () | {
"file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 40,
"end_line": 373,
"start_col": 0,
"start_line": 373
} | module Vale.X64.Instructions_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.CPU_Features_s
open Vale.X64.CryptoInstructions_s
open FStar.Seq.Base
let eval_Mov64 (src:nat64) : option nat64 = Some src
val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64
let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None
val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64
let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst)
val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64
let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst)
val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64
let eval_Add64 (dst src:nat64) : option (bool & nat64) =
let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64)
val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64
let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64)
val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64
let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_carry then 1 else 0) in
Some (sum >= pow2_64, sum % pow2_64)
val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64
let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_flag then 1 else 0) in
if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None
val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
let eval_Sub64 (dst src:nat64) : option (bool & nat64) =
let diff = dst - src in Some (diff < 0, diff % pow2_64)
val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64
let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let diff = dst - (src + (if old_carry then 1 else 0)) in
Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags)
val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64
let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) =
Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src)
val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64
let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) =
let hi = FStar.UInt.mul_div #64 rdx src in
let lo = FStar.UInt.mul_mod #64 rdx src in
if bmi2_enabled then Some (hi, lo) else None
val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64
let eval_IMul64 (dst src:nat64) : option nat64 =
Some (FStar.UInt.mul_mod #64 dst src)
val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64
let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src)
val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64
let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) =
Some (Vale.Def.Types_s.ixor dst src, (false, false))
val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64
let eval_Shr64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None
val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64
let eval_Shl64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None
val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64
let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) =
Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx)))
val ins_Cpuid :
instr_dep
[inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)]
[] PreserveFlags eval_Cpuid
// The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled.
// We underspecify XGETBV here to only support fetching XCR0, which
// is supported on any processor supporting the XGETBV instruction
let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) =
if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None
val ins_Xgetbv :
instr_dep
[out (one64Reg rRax); out (one64Reg rRdx)]
[one64Reg rRcx] PreserveFlags eval_Xgetbv
let check_avx (#a:Type0) (x:option a) : option a =
if avx_enabled then x else None
let check_sse2 (#a:Type0) (x:option a) : option a =
if sse2_enabled then x else None
let check_ssse3 (#a:Type0) (x:option a) : option a =
if ssse3_enabled then x else None
let check_sse4_1 (#a:Type0) (x:option a) : option a =
if sse4_1_enabled then x else None
let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src)
val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu
let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src))
val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor
let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2))
val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor
let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src))
val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand
let eval_Paddd_raw (src1 src2:quad32) : option quad32 =
Some (Mkfour
((src1.lo0 + src2.lo0) % pow2_32)
((src1.lo1 + src2.lo1) % pow2_32)
((src1.hi2 + src2.hi2) % pow2_32)
((src1.hi3 + src2.hi3) % pow2_32))
let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2)
val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd
let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2)
val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd
let eval_Pslld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None)
val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt)
let eval_Psrld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None)
val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt)
let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 (
if 0 <= amt && amt < 16 then
let src_bytes = le_quad32_to_bytes dst in
let zero_pad = Seq.create amt 0 in
let remaining_bytes = slice src_bytes amt (length src_bytes) in
Some (le_bytes_to_quad32 (append zero_pad remaining_bytes))
else None)
val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt)
let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if amount = 4 then
Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0)
else if amount = 8 then
Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1)
else None
let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_ssse3 (eval_Palignr_raw amount src1 src2)
val ins_Palignr (amount:nat8) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount)
let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_avx (eval_Palignr_raw amount src1 src2)
val ins_VPalignr (amount:nat8) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount)
let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 =
if 0 <= permutation && permutation < 4 then
Some (Mkfour
(if permutation % 2 = 0 then src1.lo0 else src1.hi2)
(if permutation % 2 = 0 then src1.lo1 else src1.hi3)
(if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2)
(if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3))
else None
let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_sse2 (eval_Shufpd_raw permutation src1 src2)
val ins_Shufpd (permutation:int) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation)
let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Shufpd_raw permutation src1 src2)
val ins_VShufpd (permutation:int) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation)
let is_full_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x04050607 &&
q.hi3 = 0x00010203
let is_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x00010203 &&
q.lo1 = 0x04050607 &&
q.hi2 = 0x08090A0B &&
q.hi3 = 0x0C0D0E0F
let is_high_dup_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let is_lower_upper_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x04050607 &&
q.lo1 = 0x00010203 &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let eval_Pshufb_raw (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if is_full_byte_reversal_mask src2 then
Some (reverse_bytes_quad32 src1)
else if is_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3))
else if is_high_dup_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else if is_lower_upper_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else None
let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2)
val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb
let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2)
val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb
let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 (
let bits:bits_of_byte = byte_to_twobits permutation in
Some (Mkfour
(select_word src bits.lo0)
(select_word src bits.lo1)
(select_word src bits.hi2)
(select_word src bits.hi3)))
val ins_Pshufd (permutation:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation)
let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 (
let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in
Some (Mkfour
(eq_result (src.lo0 = dst.lo0))
(eq_result (src.lo1 = dst.lo1))
(eq_result (src.hi2 = dst.hi2))
(eq_result (src.hi3 = dst.hi3))))
val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd
let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 (
let src_two = four_to_two_two src in
Some (two_to_nat 32 (two_select src_two (index % 2))))
val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index)
let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4)))
val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index)
let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat64_def dst src (index % 2)))
val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index)
let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the two very special cases we need
if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2)
else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1)
else None
let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src)
val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count)
let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the one very special case we need
if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0)
else None
let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src)
val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count)
let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
let Mkfour a0 a1 a2 a3 = src1 in
let Mkfour b0 b1 b2 b3 = src2 in
let f x0 x1 y0 y1 =
let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in
let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y)
in
if pclmulqdq_enabled then
match imm with
| 0 -> Some (f a0 a1 b0 b1)
| 1 -> Some (f a2 a3 b0 b1)
| 16 -> Some (f a0 a1 b2 b3)
| 17 -> Some (f a2 a3 b2 b3)
| _ -> None
else None
val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm)
let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Pclmulqdq imm src1 src2)
val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm)
let eval_AESNI_enc (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2)
else None
val ins_AESNI_enc : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc
let eval_VAESNI_enc (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc src1 src2)
val ins_VAESNI_enc : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc
let eval_AESNI_enc_last (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1)) src2)
else None
val ins_AESNI_enc_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc_last
let eval_VAESNI_enc_last (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc_last src1 src2)
val ins_VAESNI_enc_last : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc_last
let eval_AESNI_dec (dst src:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.inv_mix_columns_LE (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst))) src)
else None
val ins_AESNI_dec : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec
let eval_AESNI_dec_last (dst src:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst)) src)
else None
val ins_AESNI_dec_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec_last
let eval_AESNI_imc (src:quad32) : option quad32 =
if aesni_enabled then Some (Vale.AES.AES_s.inv_mix_columns_LE src) else None
val ins_AESNI_imc : instr_dep [out opXmm] [opXmm] PreserveFlags eval_AESNI_imc
let eval_AESNI_keygen_assist (imm:nat8) (src:quad32) : option quad32 =
if aesni_enabled then
Some (Mkfour
(Vale.AES.AES_s.sub_word src.lo1)
(ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.lo1)) imm)
(Vale.AES.AES_s.sub_word src.hi3)
(ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.hi3)) imm))
else None
val ins_AESNI_keygen_assist (imm:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_AESNI_keygen_assist imm)
let eval_SHA256_rnds2 (src1 src2 wk:quad32) : option quad32 =
if sha_enabled then Some (sha256_rnds2_spec src1 src2 wk) else None
val ins_SHA256_rnds2 :
instr_dep [inOut opXmm] [opXmm; oneXmm (OReg 0)] PreserveFlags eval_SHA256_rnds2
let eval_SHA256_msg1 (src1 src2:quad32) : option quad32 =
if sha_enabled then Some (sha256_msg1_spec src1 src2) else None
val ins_SHA256_msg1 : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_SHA256_msg1
let eval_SHA256_msg2 (src1 src2:quad32) : option quad32 =
if sha_enabled then Some (sha256_msg2_spec src1 src2) else None
val ins_SHA256_msg2 : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_SHA256_msg2
let eval_Ghost : option unit = Some ()
val ins_Ghost : instr_dep [] [] PreserveFlags eval_Ghost | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instructions_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.Pervasives.Native.option Prims.unit | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.Native.Some",
"Prims.unit"
] | [] | false | false | false | true | false | let eval_Comment:option unit =
| Some () | false |
Vale.X64.Instructions_s.fsti | Vale.X64.Instructions_s.eval_Pclmulqdq | val eval_Pclmulqdq (imm: int) (src1 src2: quad32) : option quad32 | val eval_Pclmulqdq (imm: int) (src1 src2: quad32) : option quad32 | let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
let Mkfour a0 a1 a2 a3 = src1 in
let Mkfour b0 b1 b2 b3 = src2 in
let f x0 x1 y0 y1 =
let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in
let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y)
in
if pclmulqdq_enabled then
match imm with
| 0 -> Some (f a0 a1 b0 b1)
| 1 -> Some (f a2 a3 b0 b1)
| 16 -> Some (f a0 a1 b2 b3)
| 17 -> Some (f a2 a3 b2 b3)
| _ -> None
else None | {
"file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 305,
"start_col": 0,
"start_line": 290
} | module Vale.X64.Instructions_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.CPU_Features_s
open Vale.X64.CryptoInstructions_s
open FStar.Seq.Base
let eval_Mov64 (src:nat64) : option nat64 = Some src
val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64
let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None
val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64
let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst)
val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64
let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst)
val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64
let eval_Add64 (dst src:nat64) : option (bool & nat64) =
let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64)
val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64
let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64)
val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64
let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_carry then 1 else 0) in
Some (sum >= pow2_64, sum % pow2_64)
val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64
let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_flag then 1 else 0) in
if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None
val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
let eval_Sub64 (dst src:nat64) : option (bool & nat64) =
let diff = dst - src in Some (diff < 0, diff % pow2_64)
val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64
let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let diff = dst - (src + (if old_carry then 1 else 0)) in
Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags)
val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64
let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) =
Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src)
val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64
let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) =
let hi = FStar.UInt.mul_div #64 rdx src in
let lo = FStar.UInt.mul_mod #64 rdx src in
if bmi2_enabled then Some (hi, lo) else None
val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64
let eval_IMul64 (dst src:nat64) : option nat64 =
Some (FStar.UInt.mul_mod #64 dst src)
val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64
let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src)
val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64
let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) =
Some (Vale.Def.Types_s.ixor dst src, (false, false))
val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64
let eval_Shr64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None
val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64
let eval_Shl64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None
val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64
let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) =
Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx)))
val ins_Cpuid :
instr_dep
[inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)]
[] PreserveFlags eval_Cpuid
// The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled.
// We underspecify XGETBV here to only support fetching XCR0, which
// is supported on any processor supporting the XGETBV instruction
let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) =
if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None
val ins_Xgetbv :
instr_dep
[out (one64Reg rRax); out (one64Reg rRdx)]
[one64Reg rRcx] PreserveFlags eval_Xgetbv
let check_avx (#a:Type0) (x:option a) : option a =
if avx_enabled then x else None
let check_sse2 (#a:Type0) (x:option a) : option a =
if sse2_enabled then x else None
let check_ssse3 (#a:Type0) (x:option a) : option a =
if ssse3_enabled then x else None
let check_sse4_1 (#a:Type0) (x:option a) : option a =
if sse4_1_enabled then x else None
let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src)
val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu
let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src))
val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor
let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2))
val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor
let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src))
val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand
let eval_Paddd_raw (src1 src2:quad32) : option quad32 =
Some (Mkfour
((src1.lo0 + src2.lo0) % pow2_32)
((src1.lo1 + src2.lo1) % pow2_32)
((src1.hi2 + src2.hi2) % pow2_32)
((src1.hi3 + src2.hi3) % pow2_32))
let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2)
val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd
let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2)
val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd
let eval_Pslld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None)
val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt)
let eval_Psrld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None)
val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt)
let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 (
if 0 <= amt && amt < 16 then
let src_bytes = le_quad32_to_bytes dst in
let zero_pad = Seq.create amt 0 in
let remaining_bytes = slice src_bytes amt (length src_bytes) in
Some (le_bytes_to_quad32 (append zero_pad remaining_bytes))
else None)
val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt)
let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if amount = 4 then
Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0)
else if amount = 8 then
Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1)
else None
let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_ssse3 (eval_Palignr_raw amount src1 src2)
val ins_Palignr (amount:nat8) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount)
let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_avx (eval_Palignr_raw amount src1 src2)
val ins_VPalignr (amount:nat8) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount)
let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 =
if 0 <= permutation && permutation < 4 then
Some (Mkfour
(if permutation % 2 = 0 then src1.lo0 else src1.hi2)
(if permutation % 2 = 0 then src1.lo1 else src1.hi3)
(if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2)
(if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3))
else None
let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_sse2 (eval_Shufpd_raw permutation src1 src2)
val ins_Shufpd (permutation:int) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation)
let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Shufpd_raw permutation src1 src2)
val ins_VShufpd (permutation:int) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation)
let is_full_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x04050607 &&
q.hi3 = 0x00010203
let is_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x00010203 &&
q.lo1 = 0x04050607 &&
q.hi2 = 0x08090A0B &&
q.hi3 = 0x0C0D0E0F
let is_high_dup_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let is_lower_upper_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x04050607 &&
q.lo1 = 0x00010203 &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let eval_Pshufb_raw (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if is_full_byte_reversal_mask src2 then
Some (reverse_bytes_quad32 src1)
else if is_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3))
else if is_high_dup_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else if is_lower_upper_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else None
let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2)
val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb
let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2)
val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb
let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 (
let bits:bits_of_byte = byte_to_twobits permutation in
Some (Mkfour
(select_word src bits.lo0)
(select_word src bits.lo1)
(select_word src bits.hi2)
(select_word src bits.hi3)))
val ins_Pshufd (permutation:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation)
let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 (
let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in
Some (Mkfour
(eq_result (src.lo0 = dst.lo0))
(eq_result (src.lo1 = dst.lo1))
(eq_result (src.hi2 = dst.hi2))
(eq_result (src.hi3 = dst.hi3))))
val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd
let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 (
let src_two = four_to_two_two src in
Some (two_to_nat 32 (two_select src_two (index % 2))))
val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index)
let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4)))
val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index)
let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat64_def dst src (index % 2)))
val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index)
let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the two very special cases we need
if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2)
else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1)
else None
let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src)
val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count)
let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the one very special case we need
if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0)
else None
let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src)
val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instructions_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | imm: Prims.int -> src1: Vale.X64.Machine_s.quad32 -> src2: Vale.X64.Machine_s.quad32
-> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32 | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Vale.X64.Machine_s.quad32",
"Vale.Def.Types_s.nat32",
"Vale.X64.CPU_Features_s.pclmulqdq_enabled",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option",
"Prims.bool",
"Vale.Def.Words_s.nat32",
"Vale.Def.Types_s.quad32",
"Vale.Math.Poly2.Bits_s.to_quad32",
"Vale.Math.Poly2_s.mul",
"Vale.Math.Poly2_s.poly",
"Vale.Math.Poly2.Bits_s.of_double32",
"Vale.Def.Words_s.Mktwo"
] | [] | false | false | false | true | false | let eval_Pclmulqdq (imm: int) (src1 src2: quad32) : option quad32 =
| let Mkfour a0 a1 a2 a3 = src1 in
let Mkfour b0 b1 b2 b3 = src2 in
let f x0 x1 y0 y1 =
let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in
let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y)
in
if pclmulqdq_enabled
then
match imm with
| 0 -> Some (f a0 a1 b0 b1)
| 1 -> Some (f a2 a3 b0 b1)
| 16 -> Some (f a0 a1 b2 b3)
| 17 -> Some (f a2 a3 b2 b3)
| _ -> None
else None | false |
Vale.X64.Instructions_s.fsti | Vale.X64.Instructions_s.eval_AESNI_imc | val eval_AESNI_imc (src: quad32) : option quad32 | val eval_AESNI_imc (src: quad32) : option quad32 | let eval_AESNI_imc (src:quad32) : option quad32 =
if aesni_enabled then Some (Vale.AES.AES_s.inv_mix_columns_LE src) else None | {
"file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 78,
"end_line": 343,
"start_col": 0,
"start_line": 342
} | module Vale.X64.Instructions_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.CPU_Features_s
open Vale.X64.CryptoInstructions_s
open FStar.Seq.Base
let eval_Mov64 (src:nat64) : option nat64 = Some src
val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64
let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None
val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64
let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst)
val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64
let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst)
val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64
let eval_Add64 (dst src:nat64) : option (bool & nat64) =
let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64)
val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64
let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64)
val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64
let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_carry then 1 else 0) in
Some (sum >= pow2_64, sum % pow2_64)
val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64
let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_flag then 1 else 0) in
if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None
val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
let eval_Sub64 (dst src:nat64) : option (bool & nat64) =
let diff = dst - src in Some (diff < 0, diff % pow2_64)
val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64
let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let diff = dst - (src + (if old_carry then 1 else 0)) in
Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags)
val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64
let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) =
Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src)
val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64
let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) =
let hi = FStar.UInt.mul_div #64 rdx src in
let lo = FStar.UInt.mul_mod #64 rdx src in
if bmi2_enabled then Some (hi, lo) else None
val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64
let eval_IMul64 (dst src:nat64) : option nat64 =
Some (FStar.UInt.mul_mod #64 dst src)
val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64
let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src)
val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64
let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) =
Some (Vale.Def.Types_s.ixor dst src, (false, false))
val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64
let eval_Shr64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None
val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64
let eval_Shl64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None
val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64
let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) =
Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx)))
val ins_Cpuid :
instr_dep
[inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)]
[] PreserveFlags eval_Cpuid
// The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled.
// We underspecify XGETBV here to only support fetching XCR0, which
// is supported on any processor supporting the XGETBV instruction
let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) =
if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None
val ins_Xgetbv :
instr_dep
[out (one64Reg rRax); out (one64Reg rRdx)]
[one64Reg rRcx] PreserveFlags eval_Xgetbv
let check_avx (#a:Type0) (x:option a) : option a =
if avx_enabled then x else None
let check_sse2 (#a:Type0) (x:option a) : option a =
if sse2_enabled then x else None
let check_ssse3 (#a:Type0) (x:option a) : option a =
if ssse3_enabled then x else None
let check_sse4_1 (#a:Type0) (x:option a) : option a =
if sse4_1_enabled then x else None
let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src)
val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu
let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src))
val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor
let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2))
val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor
let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src))
val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand
let eval_Paddd_raw (src1 src2:quad32) : option quad32 =
Some (Mkfour
((src1.lo0 + src2.lo0) % pow2_32)
((src1.lo1 + src2.lo1) % pow2_32)
((src1.hi2 + src2.hi2) % pow2_32)
((src1.hi3 + src2.hi3) % pow2_32))
let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2)
val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd
let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2)
val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd
let eval_Pslld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None)
val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt)
let eval_Psrld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None)
val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt)
let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 (
if 0 <= amt && amt < 16 then
let src_bytes = le_quad32_to_bytes dst in
let zero_pad = Seq.create amt 0 in
let remaining_bytes = slice src_bytes amt (length src_bytes) in
Some (le_bytes_to_quad32 (append zero_pad remaining_bytes))
else None)
val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt)
let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if amount = 4 then
Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0)
else if amount = 8 then
Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1)
else None
let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_ssse3 (eval_Palignr_raw amount src1 src2)
val ins_Palignr (amount:nat8) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount)
let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_avx (eval_Palignr_raw amount src1 src2)
val ins_VPalignr (amount:nat8) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount)
let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 =
if 0 <= permutation && permutation < 4 then
Some (Mkfour
(if permutation % 2 = 0 then src1.lo0 else src1.hi2)
(if permutation % 2 = 0 then src1.lo1 else src1.hi3)
(if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2)
(if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3))
else None
let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_sse2 (eval_Shufpd_raw permutation src1 src2)
val ins_Shufpd (permutation:int) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation)
let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Shufpd_raw permutation src1 src2)
val ins_VShufpd (permutation:int) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation)
let is_full_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x04050607 &&
q.hi3 = 0x00010203
let is_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x00010203 &&
q.lo1 = 0x04050607 &&
q.hi2 = 0x08090A0B &&
q.hi3 = 0x0C0D0E0F
let is_high_dup_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let is_lower_upper_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x04050607 &&
q.lo1 = 0x00010203 &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let eval_Pshufb_raw (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if is_full_byte_reversal_mask src2 then
Some (reverse_bytes_quad32 src1)
else if is_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3))
else if is_high_dup_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else if is_lower_upper_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else None
let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2)
val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb
let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2)
val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb
let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 (
let bits:bits_of_byte = byte_to_twobits permutation in
Some (Mkfour
(select_word src bits.lo0)
(select_word src bits.lo1)
(select_word src bits.hi2)
(select_word src bits.hi3)))
val ins_Pshufd (permutation:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation)
let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 (
let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in
Some (Mkfour
(eq_result (src.lo0 = dst.lo0))
(eq_result (src.lo1 = dst.lo1))
(eq_result (src.hi2 = dst.hi2))
(eq_result (src.hi3 = dst.hi3))))
val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd
let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 (
let src_two = four_to_two_two src in
Some (two_to_nat 32 (two_select src_two (index % 2))))
val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index)
let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4)))
val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index)
let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat64_def dst src (index % 2)))
val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index)
let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the two very special cases we need
if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2)
else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1)
else None
let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src)
val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count)
let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the one very special case we need
if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0)
else None
let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src)
val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count)
let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
let Mkfour a0 a1 a2 a3 = src1 in
let Mkfour b0 b1 b2 b3 = src2 in
let f x0 x1 y0 y1 =
let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in
let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y)
in
if pclmulqdq_enabled then
match imm with
| 0 -> Some (f a0 a1 b0 b1)
| 1 -> Some (f a2 a3 b0 b1)
| 16 -> Some (f a0 a1 b2 b3)
| 17 -> Some (f a2 a3 b2 b3)
| _ -> None
else None
val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm)
let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Pclmulqdq imm src1 src2)
val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm)
let eval_AESNI_enc (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2)
else None
val ins_AESNI_enc : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc
let eval_VAESNI_enc (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc src1 src2)
val ins_VAESNI_enc : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc
let eval_AESNI_enc_last (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1)) src2)
else None
val ins_AESNI_enc_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc_last
let eval_VAESNI_enc_last (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc_last src1 src2)
val ins_VAESNI_enc_last : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc_last
let eval_AESNI_dec (dst src:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.inv_mix_columns_LE (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst))) src)
else None
val ins_AESNI_dec : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec
let eval_AESNI_dec_last (dst src:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst)) src)
else None
val ins_AESNI_dec_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec_last | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instructions_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | src: Vale.X64.Machine_s.quad32 -> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32 | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Machine_s.quad32",
"Vale.X64.CPU_Features_s.aesni_enabled",
"FStar.Pervasives.Native.Some",
"Vale.AES.AES_s.inv_mix_columns_LE",
"Prims.bool",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | true | false | let eval_AESNI_imc (src: quad32) : option quad32 =
| if aesni_enabled then Some (Vale.AES.AES_s.inv_mix_columns_LE src) else None | false |
Vale.X64.Instructions_s.fsti | Vale.X64.Instructions_s.eval_Prefetchnta | val eval_Prefetchnta: nat64 -> option unit | val eval_Prefetchnta: nat64 -> option unit | let eval_Prefetchnta (_:nat64) : option unit = Some () | {
"file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 54,
"end_line": 385,
"start_col": 0,
"start_line": 385
} | module Vale.X64.Instructions_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.CPU_Features_s
open Vale.X64.CryptoInstructions_s
open FStar.Seq.Base
let eval_Mov64 (src:nat64) : option nat64 = Some src
val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64
let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None
val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64
let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst)
val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64
let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst)
val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64
let eval_Add64 (dst src:nat64) : option (bool & nat64) =
let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64)
val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64
let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64)
val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64
let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_carry then 1 else 0) in
Some (sum >= pow2_64, sum % pow2_64)
val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64
let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_flag then 1 else 0) in
if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None
val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
let eval_Sub64 (dst src:nat64) : option (bool & nat64) =
let diff = dst - src in Some (diff < 0, diff % pow2_64)
val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64
let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let diff = dst - (src + (if old_carry then 1 else 0)) in
Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags)
val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64
let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) =
Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src)
val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64
let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) =
let hi = FStar.UInt.mul_div #64 rdx src in
let lo = FStar.UInt.mul_mod #64 rdx src in
if bmi2_enabled then Some (hi, lo) else None
val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64
let eval_IMul64 (dst src:nat64) : option nat64 =
Some (FStar.UInt.mul_mod #64 dst src)
val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64
let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src)
val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64
let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) =
Some (Vale.Def.Types_s.ixor dst src, (false, false))
val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64
let eval_Shr64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None
val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64
let eval_Shl64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None
val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64
let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) =
Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx)))
val ins_Cpuid :
instr_dep
[inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)]
[] PreserveFlags eval_Cpuid
// The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled.
// We underspecify XGETBV here to only support fetching XCR0, which
// is supported on any processor supporting the XGETBV instruction
let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) =
if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None
val ins_Xgetbv :
instr_dep
[out (one64Reg rRax); out (one64Reg rRdx)]
[one64Reg rRcx] PreserveFlags eval_Xgetbv
let check_avx (#a:Type0) (x:option a) : option a =
if avx_enabled then x else None
let check_sse2 (#a:Type0) (x:option a) : option a =
if sse2_enabled then x else None
let check_ssse3 (#a:Type0) (x:option a) : option a =
if ssse3_enabled then x else None
let check_sse4_1 (#a:Type0) (x:option a) : option a =
if sse4_1_enabled then x else None
let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src)
val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu
let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src))
val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor
let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2))
val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor
let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src))
val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand
let eval_Paddd_raw (src1 src2:quad32) : option quad32 =
Some (Mkfour
((src1.lo0 + src2.lo0) % pow2_32)
((src1.lo1 + src2.lo1) % pow2_32)
((src1.hi2 + src2.hi2) % pow2_32)
((src1.hi3 + src2.hi3) % pow2_32))
let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2)
val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd
let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2)
val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd
let eval_Pslld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None)
val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt)
let eval_Psrld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None)
val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt)
let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 (
if 0 <= amt && amt < 16 then
let src_bytes = le_quad32_to_bytes dst in
let zero_pad = Seq.create amt 0 in
let remaining_bytes = slice src_bytes amt (length src_bytes) in
Some (le_bytes_to_quad32 (append zero_pad remaining_bytes))
else None)
val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt)
let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if amount = 4 then
Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0)
else if amount = 8 then
Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1)
else None
let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_ssse3 (eval_Palignr_raw amount src1 src2)
val ins_Palignr (amount:nat8) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount)
let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_avx (eval_Palignr_raw amount src1 src2)
val ins_VPalignr (amount:nat8) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount)
let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 =
if 0 <= permutation && permutation < 4 then
Some (Mkfour
(if permutation % 2 = 0 then src1.lo0 else src1.hi2)
(if permutation % 2 = 0 then src1.lo1 else src1.hi3)
(if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2)
(if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3))
else None
let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_sse2 (eval_Shufpd_raw permutation src1 src2)
val ins_Shufpd (permutation:int) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation)
let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Shufpd_raw permutation src1 src2)
val ins_VShufpd (permutation:int) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation)
let is_full_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x04050607 &&
q.hi3 = 0x00010203
let is_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x00010203 &&
q.lo1 = 0x04050607 &&
q.hi2 = 0x08090A0B &&
q.hi3 = 0x0C0D0E0F
let is_high_dup_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let is_lower_upper_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x04050607 &&
q.lo1 = 0x00010203 &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let eval_Pshufb_raw (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if is_full_byte_reversal_mask src2 then
Some (reverse_bytes_quad32 src1)
else if is_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3))
else if is_high_dup_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else if is_lower_upper_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else None
let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2)
val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb
let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2)
val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb
let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 (
let bits:bits_of_byte = byte_to_twobits permutation in
Some (Mkfour
(select_word src bits.lo0)
(select_word src bits.lo1)
(select_word src bits.hi2)
(select_word src bits.hi3)))
val ins_Pshufd (permutation:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation)
let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 (
let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in
Some (Mkfour
(eq_result (src.lo0 = dst.lo0))
(eq_result (src.lo1 = dst.lo1))
(eq_result (src.hi2 = dst.hi2))
(eq_result (src.hi3 = dst.hi3))))
val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd
let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 (
let src_two = four_to_two_two src in
Some (two_to_nat 32 (two_select src_two (index % 2))))
val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index)
let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4)))
val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index)
let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat64_def dst src (index % 2)))
val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index)
let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the two very special cases we need
if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2)
else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1)
else None
let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src)
val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count)
let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the one very special case we need
if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0)
else None
let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src)
val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count)
let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
let Mkfour a0 a1 a2 a3 = src1 in
let Mkfour b0 b1 b2 b3 = src2 in
let f x0 x1 y0 y1 =
let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in
let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y)
in
if pclmulqdq_enabled then
match imm with
| 0 -> Some (f a0 a1 b0 b1)
| 1 -> Some (f a2 a3 b0 b1)
| 16 -> Some (f a0 a1 b2 b3)
| 17 -> Some (f a2 a3 b2 b3)
| _ -> None
else None
val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm)
let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Pclmulqdq imm src1 src2)
val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm)
let eval_AESNI_enc (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2)
else None
val ins_AESNI_enc : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc
let eval_VAESNI_enc (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc src1 src2)
val ins_VAESNI_enc : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc
let eval_AESNI_enc_last (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1)) src2)
else None
val ins_AESNI_enc_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc_last
let eval_VAESNI_enc_last (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc_last src1 src2)
val ins_VAESNI_enc_last : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc_last
let eval_AESNI_dec (dst src:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.inv_mix_columns_LE (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst))) src)
else None
val ins_AESNI_dec : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec
let eval_AESNI_dec_last (dst src:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst)) src)
else None
val ins_AESNI_dec_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec_last
let eval_AESNI_imc (src:quad32) : option quad32 =
if aesni_enabled then Some (Vale.AES.AES_s.inv_mix_columns_LE src) else None
val ins_AESNI_imc : instr_dep [out opXmm] [opXmm] PreserveFlags eval_AESNI_imc
let eval_AESNI_keygen_assist (imm:nat8) (src:quad32) : option quad32 =
if aesni_enabled then
Some (Mkfour
(Vale.AES.AES_s.sub_word src.lo1)
(ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.lo1)) imm)
(Vale.AES.AES_s.sub_word src.hi3)
(ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.hi3)) imm))
else None
val ins_AESNI_keygen_assist (imm:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_AESNI_keygen_assist imm)
let eval_SHA256_rnds2 (src1 src2 wk:quad32) : option quad32 =
if sha_enabled then Some (sha256_rnds2_spec src1 src2 wk) else None
val ins_SHA256_rnds2 :
instr_dep [inOut opXmm] [opXmm; oneXmm (OReg 0)] PreserveFlags eval_SHA256_rnds2
let eval_SHA256_msg1 (src1 src2:quad32) : option quad32 =
if sha_enabled then Some (sha256_msg1_spec src1 src2) else None
val ins_SHA256_msg1 : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_SHA256_msg1
let eval_SHA256_msg2 (src1 src2:quad32) : option quad32 =
if sha_enabled then Some (sha256_msg2_spec src1 src2) else None
val ins_SHA256_msg2 : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_SHA256_msg2
let eval_Ghost : option unit = Some ()
val ins_Ghost : instr_dep [] [] PreserveFlags eval_Ghost
let eval_Comment : option unit = Some ()
val ins_Comment (_:string) : instr_dep [] [] PreserveFlags eval_Comment
let eval_LargeComment : option unit = Some ()
val ins_LargeComment (_:string) : instr_dep [] [] PreserveFlags eval_LargeComment
let eval_Newline : option unit = Some ()
val ins_Newline : instr_dep [] [] PreserveFlags eval_Newline
let eval_Space : option unit = Some ()
val ins_Space (_:nat) : instr_dep [] [] PreserveFlags eval_Space | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instructions_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Vale.X64.Machine_s.nat64 -> FStar.Pervasives.Native.option Prims.unit | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Machine_s.nat64",
"FStar.Pervasives.Native.Some",
"Prims.unit",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | true | false | let eval_Prefetchnta (_: nat64) : option unit =
| Some () | false |
Vale.X64.Instructions_s.fsti | Vale.X64.Instructions_s.eval_SHA256_msg1 | val eval_SHA256_msg1 (src1 src2: quad32) : option quad32 | val eval_SHA256_msg1 (src1 src2: quad32) : option quad32 | let eval_SHA256_msg1 (src1 src2:quad32) : option quad32 =
if sha_enabled then Some (sha256_msg1_spec src1 src2) else None | {
"file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 65,
"end_line": 363,
"start_col": 0,
"start_line": 362
} | module Vale.X64.Instructions_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.CPU_Features_s
open Vale.X64.CryptoInstructions_s
open FStar.Seq.Base
let eval_Mov64 (src:nat64) : option nat64 = Some src
val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64
let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None
val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64
let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst)
val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64
let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst)
val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64
let eval_Add64 (dst src:nat64) : option (bool & nat64) =
let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64)
val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64
let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64)
val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64
let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_carry then 1 else 0) in
Some (sum >= pow2_64, sum % pow2_64)
val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64
let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_flag then 1 else 0) in
if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None
val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
let eval_Sub64 (dst src:nat64) : option (bool & nat64) =
let diff = dst - src in Some (diff < 0, diff % pow2_64)
val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64
let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let diff = dst - (src + (if old_carry then 1 else 0)) in
Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags)
val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64
let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) =
Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src)
val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64
let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) =
let hi = FStar.UInt.mul_div #64 rdx src in
let lo = FStar.UInt.mul_mod #64 rdx src in
if bmi2_enabled then Some (hi, lo) else None
val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64
let eval_IMul64 (dst src:nat64) : option nat64 =
Some (FStar.UInt.mul_mod #64 dst src)
val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64
let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src)
val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64
let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) =
Some (Vale.Def.Types_s.ixor dst src, (false, false))
val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64
let eval_Shr64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None
val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64
let eval_Shl64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None
val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64
let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) =
Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx)))
val ins_Cpuid :
instr_dep
[inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)]
[] PreserveFlags eval_Cpuid
// The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled.
// We underspecify XGETBV here to only support fetching XCR0, which
// is supported on any processor supporting the XGETBV instruction
let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) =
if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None
val ins_Xgetbv :
instr_dep
[out (one64Reg rRax); out (one64Reg rRdx)]
[one64Reg rRcx] PreserveFlags eval_Xgetbv
let check_avx (#a:Type0) (x:option a) : option a =
if avx_enabled then x else None
let check_sse2 (#a:Type0) (x:option a) : option a =
if sse2_enabled then x else None
let check_ssse3 (#a:Type0) (x:option a) : option a =
if ssse3_enabled then x else None
let check_sse4_1 (#a:Type0) (x:option a) : option a =
if sse4_1_enabled then x else None
let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src)
val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu
let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src))
val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor
let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2))
val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor
let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src))
val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand
let eval_Paddd_raw (src1 src2:quad32) : option quad32 =
Some (Mkfour
((src1.lo0 + src2.lo0) % pow2_32)
((src1.lo1 + src2.lo1) % pow2_32)
((src1.hi2 + src2.hi2) % pow2_32)
((src1.hi3 + src2.hi3) % pow2_32))
let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2)
val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd
let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2)
val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd
let eval_Pslld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None)
val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt)
let eval_Psrld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None)
val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt)
let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 (
if 0 <= amt && amt < 16 then
let src_bytes = le_quad32_to_bytes dst in
let zero_pad = Seq.create amt 0 in
let remaining_bytes = slice src_bytes amt (length src_bytes) in
Some (le_bytes_to_quad32 (append zero_pad remaining_bytes))
else None)
val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt)
let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if amount = 4 then
Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0)
else if amount = 8 then
Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1)
else None
let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_ssse3 (eval_Palignr_raw amount src1 src2)
val ins_Palignr (amount:nat8) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount)
let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_avx (eval_Palignr_raw amount src1 src2)
val ins_VPalignr (amount:nat8) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount)
let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 =
if 0 <= permutation && permutation < 4 then
Some (Mkfour
(if permutation % 2 = 0 then src1.lo0 else src1.hi2)
(if permutation % 2 = 0 then src1.lo1 else src1.hi3)
(if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2)
(if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3))
else None
let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_sse2 (eval_Shufpd_raw permutation src1 src2)
val ins_Shufpd (permutation:int) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation)
let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Shufpd_raw permutation src1 src2)
val ins_VShufpd (permutation:int) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation)
let is_full_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x04050607 &&
q.hi3 = 0x00010203
let is_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x00010203 &&
q.lo1 = 0x04050607 &&
q.hi2 = 0x08090A0B &&
q.hi3 = 0x0C0D0E0F
let is_high_dup_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let is_lower_upper_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x04050607 &&
q.lo1 = 0x00010203 &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let eval_Pshufb_raw (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if is_full_byte_reversal_mask src2 then
Some (reverse_bytes_quad32 src1)
else if is_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3))
else if is_high_dup_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else if is_lower_upper_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else None
let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2)
val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb
let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2)
val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb
let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 (
let bits:bits_of_byte = byte_to_twobits permutation in
Some (Mkfour
(select_word src bits.lo0)
(select_word src bits.lo1)
(select_word src bits.hi2)
(select_word src bits.hi3)))
val ins_Pshufd (permutation:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation)
let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 (
let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in
Some (Mkfour
(eq_result (src.lo0 = dst.lo0))
(eq_result (src.lo1 = dst.lo1))
(eq_result (src.hi2 = dst.hi2))
(eq_result (src.hi3 = dst.hi3))))
val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd
let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 (
let src_two = four_to_two_two src in
Some (two_to_nat 32 (two_select src_two (index % 2))))
val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index)
let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4)))
val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index)
let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat64_def dst src (index % 2)))
val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index)
let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the two very special cases we need
if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2)
else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1)
else None
let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src)
val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count)
let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the one very special case we need
if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0)
else None
let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src)
val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count)
let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
let Mkfour a0 a1 a2 a3 = src1 in
let Mkfour b0 b1 b2 b3 = src2 in
let f x0 x1 y0 y1 =
let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in
let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y)
in
if pclmulqdq_enabled then
match imm with
| 0 -> Some (f a0 a1 b0 b1)
| 1 -> Some (f a2 a3 b0 b1)
| 16 -> Some (f a0 a1 b2 b3)
| 17 -> Some (f a2 a3 b2 b3)
| _ -> None
else None
val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm)
let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Pclmulqdq imm src1 src2)
val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm)
let eval_AESNI_enc (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2)
else None
val ins_AESNI_enc : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc
let eval_VAESNI_enc (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc src1 src2)
val ins_VAESNI_enc : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc
let eval_AESNI_enc_last (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1)) src2)
else None
val ins_AESNI_enc_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc_last
let eval_VAESNI_enc_last (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc_last src1 src2)
val ins_VAESNI_enc_last : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc_last
let eval_AESNI_dec (dst src:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.inv_mix_columns_LE (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst))) src)
else None
val ins_AESNI_dec : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec
let eval_AESNI_dec_last (dst src:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst)) src)
else None
val ins_AESNI_dec_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec_last
let eval_AESNI_imc (src:quad32) : option quad32 =
if aesni_enabled then Some (Vale.AES.AES_s.inv_mix_columns_LE src) else None
val ins_AESNI_imc : instr_dep [out opXmm] [opXmm] PreserveFlags eval_AESNI_imc
let eval_AESNI_keygen_assist (imm:nat8) (src:quad32) : option quad32 =
if aesni_enabled then
Some (Mkfour
(Vale.AES.AES_s.sub_word src.lo1)
(ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.lo1)) imm)
(Vale.AES.AES_s.sub_word src.hi3)
(ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.hi3)) imm))
else None
val ins_AESNI_keygen_assist (imm:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_AESNI_keygen_assist imm)
let eval_SHA256_rnds2 (src1 src2 wk:quad32) : option quad32 =
if sha_enabled then Some (sha256_rnds2_spec src1 src2 wk) else None
val ins_SHA256_rnds2 :
instr_dep [inOut opXmm] [opXmm; oneXmm (OReg 0)] PreserveFlags eval_SHA256_rnds2 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instructions_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | src1: Vale.X64.Machine_s.quad32 -> src2: Vale.X64.Machine_s.quad32
-> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32 | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Machine_s.quad32",
"Vale.X64.CPU_Features_s.sha_enabled",
"FStar.Pervasives.Native.Some",
"Vale.X64.CryptoInstructions_s.sha256_msg1_spec",
"Prims.bool",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | true | false | let eval_SHA256_msg1 (src1 src2: quad32) : option quad32 =
| if sha_enabled then Some (sha256_msg1_spec src1 src2) else None | false |
Vale.X64.Instructions_s.fsti | Vale.X64.Instructions_s.eval_AESNI_dec | val eval_AESNI_dec (dst src: quad32) : option quad32 | val eval_AESNI_dec (dst src: quad32) : option quad32 | let eval_AESNI_dec (dst src:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.inv_mix_columns_LE (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst))) src)
else None | {
"file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 333,
"start_col": 0,
"start_line": 330
} | module Vale.X64.Instructions_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.CPU_Features_s
open Vale.X64.CryptoInstructions_s
open FStar.Seq.Base
let eval_Mov64 (src:nat64) : option nat64 = Some src
val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64
let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None
val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64
let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst)
val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64
let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst)
val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64
let eval_Add64 (dst src:nat64) : option (bool & nat64) =
let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64)
val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64
let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64)
val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64
let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_carry then 1 else 0) in
Some (sum >= pow2_64, sum % pow2_64)
val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64
let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_flag then 1 else 0) in
if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None
val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
let eval_Sub64 (dst src:nat64) : option (bool & nat64) =
let diff = dst - src in Some (diff < 0, diff % pow2_64)
val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64
let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let diff = dst - (src + (if old_carry then 1 else 0)) in
Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags)
val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64
let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) =
Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src)
val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64
let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) =
let hi = FStar.UInt.mul_div #64 rdx src in
let lo = FStar.UInt.mul_mod #64 rdx src in
if bmi2_enabled then Some (hi, lo) else None
val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64
let eval_IMul64 (dst src:nat64) : option nat64 =
Some (FStar.UInt.mul_mod #64 dst src)
val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64
let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src)
val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64
let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) =
Some (Vale.Def.Types_s.ixor dst src, (false, false))
val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64
let eval_Shr64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None
val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64
let eval_Shl64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None
val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64
let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) =
Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx)))
val ins_Cpuid :
instr_dep
[inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)]
[] PreserveFlags eval_Cpuid
// The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled.
// We underspecify XGETBV here to only support fetching XCR0, which
// is supported on any processor supporting the XGETBV instruction
let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) =
if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None
val ins_Xgetbv :
instr_dep
[out (one64Reg rRax); out (one64Reg rRdx)]
[one64Reg rRcx] PreserveFlags eval_Xgetbv
let check_avx (#a:Type0) (x:option a) : option a =
if avx_enabled then x else None
let check_sse2 (#a:Type0) (x:option a) : option a =
if sse2_enabled then x else None
let check_ssse3 (#a:Type0) (x:option a) : option a =
if ssse3_enabled then x else None
let check_sse4_1 (#a:Type0) (x:option a) : option a =
if sse4_1_enabled then x else None
let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src)
val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu
let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src))
val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor
let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2))
val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor
let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src))
val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand
let eval_Paddd_raw (src1 src2:quad32) : option quad32 =
Some (Mkfour
((src1.lo0 + src2.lo0) % pow2_32)
((src1.lo1 + src2.lo1) % pow2_32)
((src1.hi2 + src2.hi2) % pow2_32)
((src1.hi3 + src2.hi3) % pow2_32))
let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2)
val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd
let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2)
val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd
let eval_Pslld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None)
val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt)
let eval_Psrld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None)
val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt)
let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 (
if 0 <= amt && amt < 16 then
let src_bytes = le_quad32_to_bytes dst in
let zero_pad = Seq.create amt 0 in
let remaining_bytes = slice src_bytes amt (length src_bytes) in
Some (le_bytes_to_quad32 (append zero_pad remaining_bytes))
else None)
val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt)
let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if amount = 4 then
Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0)
else if amount = 8 then
Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1)
else None
let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_ssse3 (eval_Palignr_raw amount src1 src2)
val ins_Palignr (amount:nat8) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount)
let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_avx (eval_Palignr_raw amount src1 src2)
val ins_VPalignr (amount:nat8) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount)
let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 =
if 0 <= permutation && permutation < 4 then
Some (Mkfour
(if permutation % 2 = 0 then src1.lo0 else src1.hi2)
(if permutation % 2 = 0 then src1.lo1 else src1.hi3)
(if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2)
(if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3))
else None
let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_sse2 (eval_Shufpd_raw permutation src1 src2)
val ins_Shufpd (permutation:int) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation)
let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Shufpd_raw permutation src1 src2)
val ins_VShufpd (permutation:int) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation)
let is_full_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x04050607 &&
q.hi3 = 0x00010203
let is_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x00010203 &&
q.lo1 = 0x04050607 &&
q.hi2 = 0x08090A0B &&
q.hi3 = 0x0C0D0E0F
let is_high_dup_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let is_lower_upper_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x04050607 &&
q.lo1 = 0x00010203 &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let eval_Pshufb_raw (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if is_full_byte_reversal_mask src2 then
Some (reverse_bytes_quad32 src1)
else if is_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3))
else if is_high_dup_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else if is_lower_upper_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else None
let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2)
val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb
let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2)
val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb
let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 (
let bits:bits_of_byte = byte_to_twobits permutation in
Some (Mkfour
(select_word src bits.lo0)
(select_word src bits.lo1)
(select_word src bits.hi2)
(select_word src bits.hi3)))
val ins_Pshufd (permutation:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation)
let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 (
let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in
Some (Mkfour
(eq_result (src.lo0 = dst.lo0))
(eq_result (src.lo1 = dst.lo1))
(eq_result (src.hi2 = dst.hi2))
(eq_result (src.hi3 = dst.hi3))))
val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd
let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 (
let src_two = four_to_two_two src in
Some (two_to_nat 32 (two_select src_two (index % 2))))
val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index)
let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4)))
val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index)
let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat64_def dst src (index % 2)))
val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index)
let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the two very special cases we need
if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2)
else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1)
else None
let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src)
val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count)
let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the one very special case we need
if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0)
else None
let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src)
val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count)
let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
let Mkfour a0 a1 a2 a3 = src1 in
let Mkfour b0 b1 b2 b3 = src2 in
let f x0 x1 y0 y1 =
let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in
let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y)
in
if pclmulqdq_enabled then
match imm with
| 0 -> Some (f a0 a1 b0 b1)
| 1 -> Some (f a2 a3 b0 b1)
| 16 -> Some (f a0 a1 b2 b3)
| 17 -> Some (f a2 a3 b2 b3)
| _ -> None
else None
val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm)
let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Pclmulqdq imm src1 src2)
val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm)
let eval_AESNI_enc (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2)
else None
val ins_AESNI_enc : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc
let eval_VAESNI_enc (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc src1 src2)
val ins_VAESNI_enc : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc
let eval_AESNI_enc_last (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1)) src2)
else None
val ins_AESNI_enc_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc_last
let eval_VAESNI_enc_last (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc_last src1 src2)
val ins_VAESNI_enc_last : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc_last | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instructions_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | dst: Vale.X64.Machine_s.quad32 -> src: Vale.X64.Machine_s.quad32
-> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32 | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Machine_s.quad32",
"Vale.X64.CPU_Features_s.aesni_enabled",
"FStar.Pervasives.Native.Some",
"Vale.Def.Types_s.quad32_xor",
"Vale.AES.AES_s.inv_mix_columns_LE",
"Vale.AES.AES_common_s.inv_sub_bytes",
"Vale.AES.AES_s.inv_shift_rows_LE",
"Prims.bool",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | true | false | let eval_AESNI_dec (dst src: quad32) : option quad32 =
| if aesni_enabled
then
Some
(quad32_xor (Vale.AES.AES_s.inv_mix_columns_LE (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE
dst)))
src)
else None | false |
Vale.X64.Instructions_s.fsti | Vale.X64.Instructions_s.eval_LargeComment | val eval_LargeComment:option unit | val eval_LargeComment:option unit | let eval_LargeComment : option unit = Some () | {
"file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 45,
"end_line": 376,
"start_col": 0,
"start_line": 376
} | module Vale.X64.Instructions_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.CPU_Features_s
open Vale.X64.CryptoInstructions_s
open FStar.Seq.Base
let eval_Mov64 (src:nat64) : option nat64 = Some src
val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64
let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None
val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64
let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst)
val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64
let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst)
val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64
let eval_Add64 (dst src:nat64) : option (bool & nat64) =
let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64)
val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64
let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64)
val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64
let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_carry then 1 else 0) in
Some (sum >= pow2_64, sum % pow2_64)
val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64
let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_flag then 1 else 0) in
if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None
val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
let eval_Sub64 (dst src:nat64) : option (bool & nat64) =
let diff = dst - src in Some (diff < 0, diff % pow2_64)
val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64
let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let diff = dst - (src + (if old_carry then 1 else 0)) in
Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags)
val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64
let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) =
Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src)
val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64
let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) =
let hi = FStar.UInt.mul_div #64 rdx src in
let lo = FStar.UInt.mul_mod #64 rdx src in
if bmi2_enabled then Some (hi, lo) else None
val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64
let eval_IMul64 (dst src:nat64) : option nat64 =
Some (FStar.UInt.mul_mod #64 dst src)
val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64
let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src)
val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64
let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) =
Some (Vale.Def.Types_s.ixor dst src, (false, false))
val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64
let eval_Shr64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None
val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64
let eval_Shl64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None
val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64
let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) =
Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx)))
val ins_Cpuid :
instr_dep
[inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)]
[] PreserveFlags eval_Cpuid
// The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled.
// We underspecify XGETBV here to only support fetching XCR0, which
// is supported on any processor supporting the XGETBV instruction
let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) =
if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None
val ins_Xgetbv :
instr_dep
[out (one64Reg rRax); out (one64Reg rRdx)]
[one64Reg rRcx] PreserveFlags eval_Xgetbv
let check_avx (#a:Type0) (x:option a) : option a =
if avx_enabled then x else None
let check_sse2 (#a:Type0) (x:option a) : option a =
if sse2_enabled then x else None
let check_ssse3 (#a:Type0) (x:option a) : option a =
if ssse3_enabled then x else None
let check_sse4_1 (#a:Type0) (x:option a) : option a =
if sse4_1_enabled then x else None
let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src)
val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu
let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src))
val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor
let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2))
val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor
let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src))
val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand
let eval_Paddd_raw (src1 src2:quad32) : option quad32 =
Some (Mkfour
((src1.lo0 + src2.lo0) % pow2_32)
((src1.lo1 + src2.lo1) % pow2_32)
((src1.hi2 + src2.hi2) % pow2_32)
((src1.hi3 + src2.hi3) % pow2_32))
let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2)
val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd
let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2)
val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd
let eval_Pslld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None)
val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt)
let eval_Psrld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None)
val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt)
let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 (
if 0 <= amt && amt < 16 then
let src_bytes = le_quad32_to_bytes dst in
let zero_pad = Seq.create amt 0 in
let remaining_bytes = slice src_bytes amt (length src_bytes) in
Some (le_bytes_to_quad32 (append zero_pad remaining_bytes))
else None)
val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt)
let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if amount = 4 then
Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0)
else if amount = 8 then
Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1)
else None
let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_ssse3 (eval_Palignr_raw amount src1 src2)
val ins_Palignr (amount:nat8) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount)
let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_avx (eval_Palignr_raw amount src1 src2)
val ins_VPalignr (amount:nat8) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount)
let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 =
if 0 <= permutation && permutation < 4 then
Some (Mkfour
(if permutation % 2 = 0 then src1.lo0 else src1.hi2)
(if permutation % 2 = 0 then src1.lo1 else src1.hi3)
(if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2)
(if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3))
else None
let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_sse2 (eval_Shufpd_raw permutation src1 src2)
val ins_Shufpd (permutation:int) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation)
let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Shufpd_raw permutation src1 src2)
val ins_VShufpd (permutation:int) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation)
let is_full_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x04050607 &&
q.hi3 = 0x00010203
let is_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x00010203 &&
q.lo1 = 0x04050607 &&
q.hi2 = 0x08090A0B &&
q.hi3 = 0x0C0D0E0F
let is_high_dup_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let is_lower_upper_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x04050607 &&
q.lo1 = 0x00010203 &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let eval_Pshufb_raw (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if is_full_byte_reversal_mask src2 then
Some (reverse_bytes_quad32 src1)
else if is_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3))
else if is_high_dup_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else if is_lower_upper_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else None
let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2)
val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb
let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2)
val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb
let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 (
let bits:bits_of_byte = byte_to_twobits permutation in
Some (Mkfour
(select_word src bits.lo0)
(select_word src bits.lo1)
(select_word src bits.hi2)
(select_word src bits.hi3)))
val ins_Pshufd (permutation:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation)
let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 (
let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in
Some (Mkfour
(eq_result (src.lo0 = dst.lo0))
(eq_result (src.lo1 = dst.lo1))
(eq_result (src.hi2 = dst.hi2))
(eq_result (src.hi3 = dst.hi3))))
val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd
let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 (
let src_two = four_to_two_two src in
Some (two_to_nat 32 (two_select src_two (index % 2))))
val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index)
let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4)))
val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index)
let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat64_def dst src (index % 2)))
val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index)
let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the two very special cases we need
if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2)
else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1)
else None
let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src)
val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count)
let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the one very special case we need
if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0)
else None
let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src)
val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count)
let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
let Mkfour a0 a1 a2 a3 = src1 in
let Mkfour b0 b1 b2 b3 = src2 in
let f x0 x1 y0 y1 =
let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in
let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y)
in
if pclmulqdq_enabled then
match imm with
| 0 -> Some (f a0 a1 b0 b1)
| 1 -> Some (f a2 a3 b0 b1)
| 16 -> Some (f a0 a1 b2 b3)
| 17 -> Some (f a2 a3 b2 b3)
| _ -> None
else None
val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm)
let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Pclmulqdq imm src1 src2)
val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm)
let eval_AESNI_enc (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2)
else None
val ins_AESNI_enc : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc
let eval_VAESNI_enc (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc src1 src2)
val ins_VAESNI_enc : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc
let eval_AESNI_enc_last (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1)) src2)
else None
val ins_AESNI_enc_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc_last
let eval_VAESNI_enc_last (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc_last src1 src2)
val ins_VAESNI_enc_last : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc_last
let eval_AESNI_dec (dst src:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.inv_mix_columns_LE (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst))) src)
else None
val ins_AESNI_dec : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec
let eval_AESNI_dec_last (dst src:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst)) src)
else None
val ins_AESNI_dec_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec_last
let eval_AESNI_imc (src:quad32) : option quad32 =
if aesni_enabled then Some (Vale.AES.AES_s.inv_mix_columns_LE src) else None
val ins_AESNI_imc : instr_dep [out opXmm] [opXmm] PreserveFlags eval_AESNI_imc
let eval_AESNI_keygen_assist (imm:nat8) (src:quad32) : option quad32 =
if aesni_enabled then
Some (Mkfour
(Vale.AES.AES_s.sub_word src.lo1)
(ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.lo1)) imm)
(Vale.AES.AES_s.sub_word src.hi3)
(ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.hi3)) imm))
else None
val ins_AESNI_keygen_assist (imm:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_AESNI_keygen_assist imm)
let eval_SHA256_rnds2 (src1 src2 wk:quad32) : option quad32 =
if sha_enabled then Some (sha256_rnds2_spec src1 src2 wk) else None
val ins_SHA256_rnds2 :
instr_dep [inOut opXmm] [opXmm; oneXmm (OReg 0)] PreserveFlags eval_SHA256_rnds2
let eval_SHA256_msg1 (src1 src2:quad32) : option quad32 =
if sha_enabled then Some (sha256_msg1_spec src1 src2) else None
val ins_SHA256_msg1 : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_SHA256_msg1
let eval_SHA256_msg2 (src1 src2:quad32) : option quad32 =
if sha_enabled then Some (sha256_msg2_spec src1 src2) else None
val ins_SHA256_msg2 : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_SHA256_msg2
let eval_Ghost : option unit = Some ()
val ins_Ghost : instr_dep [] [] PreserveFlags eval_Ghost
let eval_Comment : option unit = Some ()
val ins_Comment (_:string) : instr_dep [] [] PreserveFlags eval_Comment | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instructions_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.Pervasives.Native.option Prims.unit | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.Native.Some",
"Prims.unit"
] | [] | false | false | false | true | false | let eval_LargeComment:option unit =
| Some () | false |
Vale.X64.Instructions_s.fsti | Vale.X64.Instructions_s.eval_SHA256_rnds2 | val eval_SHA256_rnds2 (src1 src2 wk: quad32) : option quad32 | val eval_SHA256_rnds2 (src1 src2 wk: quad32) : option quad32 | let eval_SHA256_rnds2 (src1 src2 wk:quad32) : option quad32 =
if sha_enabled then Some (sha256_rnds2_spec src1 src2 wk) else None | {
"file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 69,
"end_line": 358,
"start_col": 0,
"start_line": 357
} | module Vale.X64.Instructions_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.CPU_Features_s
open Vale.X64.CryptoInstructions_s
open FStar.Seq.Base
let eval_Mov64 (src:nat64) : option nat64 = Some src
val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64
let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None
val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64
let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst)
val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64
let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst)
val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64
let eval_Add64 (dst src:nat64) : option (bool & nat64) =
let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64)
val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64
let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64)
val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64
let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_carry then 1 else 0) in
Some (sum >= pow2_64, sum % pow2_64)
val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64
let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_flag then 1 else 0) in
if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None
val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
let eval_Sub64 (dst src:nat64) : option (bool & nat64) =
let diff = dst - src in Some (diff < 0, diff % pow2_64)
val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64
let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let diff = dst - (src + (if old_carry then 1 else 0)) in
Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags)
val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64
let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) =
Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src)
val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64
let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) =
let hi = FStar.UInt.mul_div #64 rdx src in
let lo = FStar.UInt.mul_mod #64 rdx src in
if bmi2_enabled then Some (hi, lo) else None
val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64
let eval_IMul64 (dst src:nat64) : option nat64 =
Some (FStar.UInt.mul_mod #64 dst src)
val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64
let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src)
val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64
let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) =
Some (Vale.Def.Types_s.ixor dst src, (false, false))
val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64
let eval_Shr64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None
val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64
let eval_Shl64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None
val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64
let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) =
Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx)))
val ins_Cpuid :
instr_dep
[inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)]
[] PreserveFlags eval_Cpuid
// The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled.
// We underspecify XGETBV here to only support fetching XCR0, which
// is supported on any processor supporting the XGETBV instruction
let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) =
if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None
val ins_Xgetbv :
instr_dep
[out (one64Reg rRax); out (one64Reg rRdx)]
[one64Reg rRcx] PreserveFlags eval_Xgetbv
let check_avx (#a:Type0) (x:option a) : option a =
if avx_enabled then x else None
let check_sse2 (#a:Type0) (x:option a) : option a =
if sse2_enabled then x else None
let check_ssse3 (#a:Type0) (x:option a) : option a =
if ssse3_enabled then x else None
let check_sse4_1 (#a:Type0) (x:option a) : option a =
if sse4_1_enabled then x else None
let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src)
val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu
let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src))
val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor
let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2))
val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor
let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src))
val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand
let eval_Paddd_raw (src1 src2:quad32) : option quad32 =
Some (Mkfour
((src1.lo0 + src2.lo0) % pow2_32)
((src1.lo1 + src2.lo1) % pow2_32)
((src1.hi2 + src2.hi2) % pow2_32)
((src1.hi3 + src2.hi3) % pow2_32))
let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2)
val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd
let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2)
val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd
let eval_Pslld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None)
val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt)
let eval_Psrld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None)
val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt)
let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 (
if 0 <= amt && amt < 16 then
let src_bytes = le_quad32_to_bytes dst in
let zero_pad = Seq.create amt 0 in
let remaining_bytes = slice src_bytes amt (length src_bytes) in
Some (le_bytes_to_quad32 (append zero_pad remaining_bytes))
else None)
val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt)
let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if amount = 4 then
Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0)
else if amount = 8 then
Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1)
else None
let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_ssse3 (eval_Palignr_raw amount src1 src2)
val ins_Palignr (amount:nat8) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount)
let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_avx (eval_Palignr_raw amount src1 src2)
val ins_VPalignr (amount:nat8) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount)
let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 =
if 0 <= permutation && permutation < 4 then
Some (Mkfour
(if permutation % 2 = 0 then src1.lo0 else src1.hi2)
(if permutation % 2 = 0 then src1.lo1 else src1.hi3)
(if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2)
(if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3))
else None
let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_sse2 (eval_Shufpd_raw permutation src1 src2)
val ins_Shufpd (permutation:int) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation)
let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Shufpd_raw permutation src1 src2)
val ins_VShufpd (permutation:int) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation)
let is_full_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x04050607 &&
q.hi3 = 0x00010203
let is_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x00010203 &&
q.lo1 = 0x04050607 &&
q.hi2 = 0x08090A0B &&
q.hi3 = 0x0C0D0E0F
let is_high_dup_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let is_lower_upper_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x04050607 &&
q.lo1 = 0x00010203 &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let eval_Pshufb_raw (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if is_full_byte_reversal_mask src2 then
Some (reverse_bytes_quad32 src1)
else if is_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3))
else if is_high_dup_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else if is_lower_upper_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else None
let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2)
val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb
let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2)
val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb
let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 (
let bits:bits_of_byte = byte_to_twobits permutation in
Some (Mkfour
(select_word src bits.lo0)
(select_word src bits.lo1)
(select_word src bits.hi2)
(select_word src bits.hi3)))
val ins_Pshufd (permutation:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation)
let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 (
let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in
Some (Mkfour
(eq_result (src.lo0 = dst.lo0))
(eq_result (src.lo1 = dst.lo1))
(eq_result (src.hi2 = dst.hi2))
(eq_result (src.hi3 = dst.hi3))))
val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd
let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 (
let src_two = four_to_two_two src in
Some (two_to_nat 32 (two_select src_two (index % 2))))
val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index)
let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4)))
val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index)
let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat64_def dst src (index % 2)))
val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index)
let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the two very special cases we need
if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2)
else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1)
else None
let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src)
val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count)
let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the one very special case we need
if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0)
else None
let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src)
val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count)
let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
let Mkfour a0 a1 a2 a3 = src1 in
let Mkfour b0 b1 b2 b3 = src2 in
let f x0 x1 y0 y1 =
let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in
let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y)
in
if pclmulqdq_enabled then
match imm with
| 0 -> Some (f a0 a1 b0 b1)
| 1 -> Some (f a2 a3 b0 b1)
| 16 -> Some (f a0 a1 b2 b3)
| 17 -> Some (f a2 a3 b2 b3)
| _ -> None
else None
val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm)
let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Pclmulqdq imm src1 src2)
val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm)
let eval_AESNI_enc (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2)
else None
val ins_AESNI_enc : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc
let eval_VAESNI_enc (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc src1 src2)
val ins_VAESNI_enc : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc
let eval_AESNI_enc_last (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1)) src2)
else None
val ins_AESNI_enc_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc_last
let eval_VAESNI_enc_last (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc_last src1 src2)
val ins_VAESNI_enc_last : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc_last
let eval_AESNI_dec (dst src:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.inv_mix_columns_LE (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst))) src)
else None
val ins_AESNI_dec : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec
let eval_AESNI_dec_last (dst src:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst)) src)
else None
val ins_AESNI_dec_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec_last
let eval_AESNI_imc (src:quad32) : option quad32 =
if aesni_enabled then Some (Vale.AES.AES_s.inv_mix_columns_LE src) else None
val ins_AESNI_imc : instr_dep [out opXmm] [opXmm] PreserveFlags eval_AESNI_imc
let eval_AESNI_keygen_assist (imm:nat8) (src:quad32) : option quad32 =
if aesni_enabled then
Some (Mkfour
(Vale.AES.AES_s.sub_word src.lo1)
(ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.lo1)) imm)
(Vale.AES.AES_s.sub_word src.hi3)
(ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.hi3)) imm))
else None
val ins_AESNI_keygen_assist (imm:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_AESNI_keygen_assist imm) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instructions_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | src1: Vale.X64.Machine_s.quad32 -> src2: Vale.X64.Machine_s.quad32 -> wk: Vale.X64.Machine_s.quad32
-> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32 | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Machine_s.quad32",
"Vale.X64.CPU_Features_s.sha_enabled",
"FStar.Pervasives.Native.Some",
"Vale.X64.CryptoInstructions_s.sha256_rnds2_spec",
"Prims.bool",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | true | false | let eval_SHA256_rnds2 (src1 src2 wk: quad32) : option quad32 =
| if sha_enabled then Some (sha256_rnds2_spec src1 src2 wk) else None | false |
Vale.X64.Instructions_s.fsti | Vale.X64.Instructions_s.eval_Ghost | val eval_Ghost:option unit | val eval_Ghost:option unit | let eval_Ghost : option unit = Some () | {
"file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 38,
"end_line": 370,
"start_col": 0,
"start_line": 370
} | module Vale.X64.Instructions_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.CPU_Features_s
open Vale.X64.CryptoInstructions_s
open FStar.Seq.Base
let eval_Mov64 (src:nat64) : option nat64 = Some src
val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64
let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None
val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64
let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst)
val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64
let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst)
val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64
let eval_Add64 (dst src:nat64) : option (bool & nat64) =
let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64)
val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64
let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64)
val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64
let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_carry then 1 else 0) in
Some (sum >= pow2_64, sum % pow2_64)
val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64
let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_flag then 1 else 0) in
if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None
val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
let eval_Sub64 (dst src:nat64) : option (bool & nat64) =
let diff = dst - src in Some (diff < 0, diff % pow2_64)
val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64
let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let diff = dst - (src + (if old_carry then 1 else 0)) in
Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags)
val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64
let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) =
Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src)
val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64
let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) =
let hi = FStar.UInt.mul_div #64 rdx src in
let lo = FStar.UInt.mul_mod #64 rdx src in
if bmi2_enabled then Some (hi, lo) else None
val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64
let eval_IMul64 (dst src:nat64) : option nat64 =
Some (FStar.UInt.mul_mod #64 dst src)
val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64
let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src)
val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64
let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) =
Some (Vale.Def.Types_s.ixor dst src, (false, false))
val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64
let eval_Shr64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None
val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64
let eval_Shl64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None
val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64
let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) =
Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx)))
val ins_Cpuid :
instr_dep
[inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)]
[] PreserveFlags eval_Cpuid
// The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled.
// We underspecify XGETBV here to only support fetching XCR0, which
// is supported on any processor supporting the XGETBV instruction
let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) =
if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None
val ins_Xgetbv :
instr_dep
[out (one64Reg rRax); out (one64Reg rRdx)]
[one64Reg rRcx] PreserveFlags eval_Xgetbv
let check_avx (#a:Type0) (x:option a) : option a =
if avx_enabled then x else None
let check_sse2 (#a:Type0) (x:option a) : option a =
if sse2_enabled then x else None
let check_ssse3 (#a:Type0) (x:option a) : option a =
if ssse3_enabled then x else None
let check_sse4_1 (#a:Type0) (x:option a) : option a =
if sse4_1_enabled then x else None
let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src)
val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu
let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src))
val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor
let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2))
val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor
let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src))
val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand
let eval_Paddd_raw (src1 src2:quad32) : option quad32 =
Some (Mkfour
((src1.lo0 + src2.lo0) % pow2_32)
((src1.lo1 + src2.lo1) % pow2_32)
((src1.hi2 + src2.hi2) % pow2_32)
((src1.hi3 + src2.hi3) % pow2_32))
let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2)
val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd
let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2)
val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd
let eval_Pslld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None)
val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt)
let eval_Psrld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None)
val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt)
let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 (
if 0 <= amt && amt < 16 then
let src_bytes = le_quad32_to_bytes dst in
let zero_pad = Seq.create amt 0 in
let remaining_bytes = slice src_bytes amt (length src_bytes) in
Some (le_bytes_to_quad32 (append zero_pad remaining_bytes))
else None)
val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt)
let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if amount = 4 then
Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0)
else if amount = 8 then
Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1)
else None
let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_ssse3 (eval_Palignr_raw amount src1 src2)
val ins_Palignr (amount:nat8) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount)
let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_avx (eval_Palignr_raw amount src1 src2)
val ins_VPalignr (amount:nat8) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount)
let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 =
if 0 <= permutation && permutation < 4 then
Some (Mkfour
(if permutation % 2 = 0 then src1.lo0 else src1.hi2)
(if permutation % 2 = 0 then src1.lo1 else src1.hi3)
(if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2)
(if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3))
else None
let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_sse2 (eval_Shufpd_raw permutation src1 src2)
val ins_Shufpd (permutation:int) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation)
let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Shufpd_raw permutation src1 src2)
val ins_VShufpd (permutation:int) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation)
let is_full_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x04050607 &&
q.hi3 = 0x00010203
let is_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x00010203 &&
q.lo1 = 0x04050607 &&
q.hi2 = 0x08090A0B &&
q.hi3 = 0x0C0D0E0F
let is_high_dup_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let is_lower_upper_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x04050607 &&
q.lo1 = 0x00010203 &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let eval_Pshufb_raw (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if is_full_byte_reversal_mask src2 then
Some (reverse_bytes_quad32 src1)
else if is_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3))
else if is_high_dup_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else if is_lower_upper_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else None
let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2)
val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb
let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2)
val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb
let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 (
let bits:bits_of_byte = byte_to_twobits permutation in
Some (Mkfour
(select_word src bits.lo0)
(select_word src bits.lo1)
(select_word src bits.hi2)
(select_word src bits.hi3)))
val ins_Pshufd (permutation:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation)
let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 (
let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in
Some (Mkfour
(eq_result (src.lo0 = dst.lo0))
(eq_result (src.lo1 = dst.lo1))
(eq_result (src.hi2 = dst.hi2))
(eq_result (src.hi3 = dst.hi3))))
val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd
let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 (
let src_two = four_to_two_two src in
Some (two_to_nat 32 (two_select src_two (index % 2))))
val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index)
let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4)))
val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index)
let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat64_def dst src (index % 2)))
val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index)
let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the two very special cases we need
if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2)
else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1)
else None
let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src)
val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count)
let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the one very special case we need
if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0)
else None
let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src)
val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count)
let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
let Mkfour a0 a1 a2 a3 = src1 in
let Mkfour b0 b1 b2 b3 = src2 in
let f x0 x1 y0 y1 =
let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in
let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y)
in
if pclmulqdq_enabled then
match imm with
| 0 -> Some (f a0 a1 b0 b1)
| 1 -> Some (f a2 a3 b0 b1)
| 16 -> Some (f a0 a1 b2 b3)
| 17 -> Some (f a2 a3 b2 b3)
| _ -> None
else None
val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm)
let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Pclmulqdq imm src1 src2)
val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm)
let eval_AESNI_enc (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2)
else None
val ins_AESNI_enc : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc
let eval_VAESNI_enc (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc src1 src2)
val ins_VAESNI_enc : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc
let eval_AESNI_enc_last (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1)) src2)
else None
val ins_AESNI_enc_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc_last
let eval_VAESNI_enc_last (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc_last src1 src2)
val ins_VAESNI_enc_last : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc_last
let eval_AESNI_dec (dst src:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.inv_mix_columns_LE (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst))) src)
else None
val ins_AESNI_dec : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec
let eval_AESNI_dec_last (dst src:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst)) src)
else None
val ins_AESNI_dec_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec_last
let eval_AESNI_imc (src:quad32) : option quad32 =
if aesni_enabled then Some (Vale.AES.AES_s.inv_mix_columns_LE src) else None
val ins_AESNI_imc : instr_dep [out opXmm] [opXmm] PreserveFlags eval_AESNI_imc
let eval_AESNI_keygen_assist (imm:nat8) (src:quad32) : option quad32 =
if aesni_enabled then
Some (Mkfour
(Vale.AES.AES_s.sub_word src.lo1)
(ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.lo1)) imm)
(Vale.AES.AES_s.sub_word src.hi3)
(ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.hi3)) imm))
else None
val ins_AESNI_keygen_assist (imm:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_AESNI_keygen_assist imm)
let eval_SHA256_rnds2 (src1 src2 wk:quad32) : option quad32 =
if sha_enabled then Some (sha256_rnds2_spec src1 src2 wk) else None
val ins_SHA256_rnds2 :
instr_dep [inOut opXmm] [opXmm; oneXmm (OReg 0)] PreserveFlags eval_SHA256_rnds2
let eval_SHA256_msg1 (src1 src2:quad32) : option quad32 =
if sha_enabled then Some (sha256_msg1_spec src1 src2) else None
val ins_SHA256_msg1 : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_SHA256_msg1
let eval_SHA256_msg2 (src1 src2:quad32) : option quad32 =
if sha_enabled then Some (sha256_msg2_spec src1 src2) else None
val ins_SHA256_msg2 : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_SHA256_msg2 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instructions_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.Pervasives.Native.option Prims.unit | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.Native.Some",
"Prims.unit"
] | [] | false | false | false | true | false | let eval_Ghost:option unit =
| Some () | false |
Vale.X64.Instructions_s.fsti | Vale.X64.Instructions_s.eval_VAESNI_enc_last | val eval_VAESNI_enc_last (src1 src2: quad32) : option quad32 | val eval_VAESNI_enc_last (src1 src2: quad32) : option quad32 | let eval_VAESNI_enc_last (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc_last src1 src2) | {
"file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 103,
"end_line": 327,
"start_col": 0,
"start_line": 327
} | module Vale.X64.Instructions_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.CPU_Features_s
open Vale.X64.CryptoInstructions_s
open FStar.Seq.Base
let eval_Mov64 (src:nat64) : option nat64 = Some src
val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64
let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None
val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64
let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst)
val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64
let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst)
val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64
let eval_Add64 (dst src:nat64) : option (bool & nat64) =
let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64)
val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64
let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64)
val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64
let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_carry then 1 else 0) in
Some (sum >= pow2_64, sum % pow2_64)
val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64
let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_flag then 1 else 0) in
if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None
val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
let eval_Sub64 (dst src:nat64) : option (bool & nat64) =
let diff = dst - src in Some (diff < 0, diff % pow2_64)
val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64
let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let diff = dst - (src + (if old_carry then 1 else 0)) in
Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags)
val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64
let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) =
Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src)
val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64
let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) =
let hi = FStar.UInt.mul_div #64 rdx src in
let lo = FStar.UInt.mul_mod #64 rdx src in
if bmi2_enabled then Some (hi, lo) else None
val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64
let eval_IMul64 (dst src:nat64) : option nat64 =
Some (FStar.UInt.mul_mod #64 dst src)
val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64
let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src)
val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64
let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) =
Some (Vale.Def.Types_s.ixor dst src, (false, false))
val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64
let eval_Shr64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None
val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64
let eval_Shl64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None
val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64
let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) =
Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx)))
val ins_Cpuid :
instr_dep
[inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)]
[] PreserveFlags eval_Cpuid
// The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled.
// We underspecify XGETBV here to only support fetching XCR0, which
// is supported on any processor supporting the XGETBV instruction
let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) =
if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None
val ins_Xgetbv :
instr_dep
[out (one64Reg rRax); out (one64Reg rRdx)]
[one64Reg rRcx] PreserveFlags eval_Xgetbv
let check_avx (#a:Type0) (x:option a) : option a =
if avx_enabled then x else None
let check_sse2 (#a:Type0) (x:option a) : option a =
if sse2_enabled then x else None
let check_ssse3 (#a:Type0) (x:option a) : option a =
if ssse3_enabled then x else None
let check_sse4_1 (#a:Type0) (x:option a) : option a =
if sse4_1_enabled then x else None
let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src)
val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu
let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src))
val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor
let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2))
val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor
let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src))
val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand
let eval_Paddd_raw (src1 src2:quad32) : option quad32 =
Some (Mkfour
((src1.lo0 + src2.lo0) % pow2_32)
((src1.lo1 + src2.lo1) % pow2_32)
((src1.hi2 + src2.hi2) % pow2_32)
((src1.hi3 + src2.hi3) % pow2_32))
let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2)
val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd
let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2)
val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd
let eval_Pslld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None)
val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt)
let eval_Psrld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None)
val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt)
let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 (
if 0 <= amt && amt < 16 then
let src_bytes = le_quad32_to_bytes dst in
let zero_pad = Seq.create amt 0 in
let remaining_bytes = slice src_bytes amt (length src_bytes) in
Some (le_bytes_to_quad32 (append zero_pad remaining_bytes))
else None)
val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt)
let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if amount = 4 then
Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0)
else if amount = 8 then
Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1)
else None
let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_ssse3 (eval_Palignr_raw amount src1 src2)
val ins_Palignr (amount:nat8) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount)
let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_avx (eval_Palignr_raw amount src1 src2)
val ins_VPalignr (amount:nat8) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount)
let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 =
if 0 <= permutation && permutation < 4 then
Some (Mkfour
(if permutation % 2 = 0 then src1.lo0 else src1.hi2)
(if permutation % 2 = 0 then src1.lo1 else src1.hi3)
(if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2)
(if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3))
else None
let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_sse2 (eval_Shufpd_raw permutation src1 src2)
val ins_Shufpd (permutation:int) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation)
let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Shufpd_raw permutation src1 src2)
val ins_VShufpd (permutation:int) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation)
let is_full_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x04050607 &&
q.hi3 = 0x00010203
let is_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x00010203 &&
q.lo1 = 0x04050607 &&
q.hi2 = 0x08090A0B &&
q.hi3 = 0x0C0D0E0F
let is_high_dup_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let is_lower_upper_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x04050607 &&
q.lo1 = 0x00010203 &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let eval_Pshufb_raw (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if is_full_byte_reversal_mask src2 then
Some (reverse_bytes_quad32 src1)
else if is_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3))
else if is_high_dup_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else if is_lower_upper_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else None
let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2)
val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb
let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2)
val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb
let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 (
let bits:bits_of_byte = byte_to_twobits permutation in
Some (Mkfour
(select_word src bits.lo0)
(select_word src bits.lo1)
(select_word src bits.hi2)
(select_word src bits.hi3)))
val ins_Pshufd (permutation:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation)
let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 (
let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in
Some (Mkfour
(eq_result (src.lo0 = dst.lo0))
(eq_result (src.lo1 = dst.lo1))
(eq_result (src.hi2 = dst.hi2))
(eq_result (src.hi3 = dst.hi3))))
val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd
let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 (
let src_two = four_to_two_two src in
Some (two_to_nat 32 (two_select src_two (index % 2))))
val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index)
let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4)))
val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index)
let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat64_def dst src (index % 2)))
val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index)
let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the two very special cases we need
if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2)
else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1)
else None
let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src)
val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count)
let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the one very special case we need
if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0)
else None
let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src)
val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count)
let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
let Mkfour a0 a1 a2 a3 = src1 in
let Mkfour b0 b1 b2 b3 = src2 in
let f x0 x1 y0 y1 =
let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in
let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y)
in
if pclmulqdq_enabled then
match imm with
| 0 -> Some (f a0 a1 b0 b1)
| 1 -> Some (f a2 a3 b0 b1)
| 16 -> Some (f a0 a1 b2 b3)
| 17 -> Some (f a2 a3 b2 b3)
| _ -> None
else None
val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm)
let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Pclmulqdq imm src1 src2)
val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm)
let eval_AESNI_enc (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2)
else None
val ins_AESNI_enc : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc
let eval_VAESNI_enc (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc src1 src2)
val ins_VAESNI_enc : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc
let eval_AESNI_enc_last (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1)) src2)
else None
val ins_AESNI_enc_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc_last | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instructions_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | src1: Vale.X64.Machine_s.quad32 -> src2: Vale.X64.Machine_s.quad32
-> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32 | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Machine_s.quad32",
"Vale.X64.Instructions_s.check_avx",
"Vale.X64.Instructions_s.eval_AESNI_enc_last",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | true | false | let eval_VAESNI_enc_last (src1 src2: quad32) : option quad32 =
| check_avx (eval_AESNI_enc_last src1 src2) | false |
Vale.X64.Instructions_s.fsti | Vale.X64.Instructions_s.eval_VPsrldq | val eval_VPsrldq (count: nat8) (src: quad32) : option quad32 | val eval_VPsrldq (count: nat8) (src: quad32) : option quad32 | let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src) | {
"file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 100,
"end_line": 287,
"start_col": 0,
"start_line": 287
} | module Vale.X64.Instructions_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.CPU_Features_s
open Vale.X64.CryptoInstructions_s
open FStar.Seq.Base
let eval_Mov64 (src:nat64) : option nat64 = Some src
val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64
let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None
val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64
let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst)
val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64
let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst)
val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64
let eval_Add64 (dst src:nat64) : option (bool & nat64) =
let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64)
val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64
let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64)
val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64
let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_carry then 1 else 0) in
Some (sum >= pow2_64, sum % pow2_64)
val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64
let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_flag then 1 else 0) in
if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None
val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
let eval_Sub64 (dst src:nat64) : option (bool & nat64) =
let diff = dst - src in Some (diff < 0, diff % pow2_64)
val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64
let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let diff = dst - (src + (if old_carry then 1 else 0)) in
Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags)
val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64
let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) =
Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src)
val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64
let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) =
let hi = FStar.UInt.mul_div #64 rdx src in
let lo = FStar.UInt.mul_mod #64 rdx src in
if bmi2_enabled then Some (hi, lo) else None
val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64
let eval_IMul64 (dst src:nat64) : option nat64 =
Some (FStar.UInt.mul_mod #64 dst src)
val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64
let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src)
val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64
let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) =
Some (Vale.Def.Types_s.ixor dst src, (false, false))
val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64
let eval_Shr64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None
val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64
let eval_Shl64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None
val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64
let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) =
Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx)))
val ins_Cpuid :
instr_dep
[inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)]
[] PreserveFlags eval_Cpuid
// The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled.
// We underspecify XGETBV here to only support fetching XCR0, which
// is supported on any processor supporting the XGETBV instruction
let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) =
if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None
val ins_Xgetbv :
instr_dep
[out (one64Reg rRax); out (one64Reg rRdx)]
[one64Reg rRcx] PreserveFlags eval_Xgetbv
let check_avx (#a:Type0) (x:option a) : option a =
if avx_enabled then x else None
let check_sse2 (#a:Type0) (x:option a) : option a =
if sse2_enabled then x else None
let check_ssse3 (#a:Type0) (x:option a) : option a =
if ssse3_enabled then x else None
let check_sse4_1 (#a:Type0) (x:option a) : option a =
if sse4_1_enabled then x else None
let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src)
val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu
let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src))
val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor
let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2))
val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor
let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src))
val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand
let eval_Paddd_raw (src1 src2:quad32) : option quad32 =
Some (Mkfour
((src1.lo0 + src2.lo0) % pow2_32)
((src1.lo1 + src2.lo1) % pow2_32)
((src1.hi2 + src2.hi2) % pow2_32)
((src1.hi3 + src2.hi3) % pow2_32))
let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2)
val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd
let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2)
val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd
let eval_Pslld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None)
val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt)
let eval_Psrld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None)
val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt)
let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 (
if 0 <= amt && amt < 16 then
let src_bytes = le_quad32_to_bytes dst in
let zero_pad = Seq.create amt 0 in
let remaining_bytes = slice src_bytes amt (length src_bytes) in
Some (le_bytes_to_quad32 (append zero_pad remaining_bytes))
else None)
val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt)
let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if amount = 4 then
Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0)
else if amount = 8 then
Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1)
else None
let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_ssse3 (eval_Palignr_raw amount src1 src2)
val ins_Palignr (amount:nat8) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount)
let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_avx (eval_Palignr_raw amount src1 src2)
val ins_VPalignr (amount:nat8) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount)
let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 =
if 0 <= permutation && permutation < 4 then
Some (Mkfour
(if permutation % 2 = 0 then src1.lo0 else src1.hi2)
(if permutation % 2 = 0 then src1.lo1 else src1.hi3)
(if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2)
(if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3))
else None
let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_sse2 (eval_Shufpd_raw permutation src1 src2)
val ins_Shufpd (permutation:int) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation)
let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Shufpd_raw permutation src1 src2)
val ins_VShufpd (permutation:int) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation)
let is_full_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x04050607 &&
q.hi3 = 0x00010203
let is_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x00010203 &&
q.lo1 = 0x04050607 &&
q.hi2 = 0x08090A0B &&
q.hi3 = 0x0C0D0E0F
let is_high_dup_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let is_lower_upper_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x04050607 &&
q.lo1 = 0x00010203 &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let eval_Pshufb_raw (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if is_full_byte_reversal_mask src2 then
Some (reverse_bytes_quad32 src1)
else if is_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3))
else if is_high_dup_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else if is_lower_upper_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else None
let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2)
val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb
let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2)
val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb
let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 (
let bits:bits_of_byte = byte_to_twobits permutation in
Some (Mkfour
(select_word src bits.lo0)
(select_word src bits.lo1)
(select_word src bits.hi2)
(select_word src bits.hi3)))
val ins_Pshufd (permutation:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation)
let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 (
let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in
Some (Mkfour
(eq_result (src.lo0 = dst.lo0))
(eq_result (src.lo1 = dst.lo1))
(eq_result (src.hi2 = dst.hi2))
(eq_result (src.hi3 = dst.hi3))))
val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd
let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 (
let src_two = four_to_two_two src in
Some (two_to_nat 32 (two_select src_two (index % 2))))
val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index)
let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4)))
val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index)
let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat64_def dst src (index % 2)))
val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index)
let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the two very special cases we need
if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2)
else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1)
else None
let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src)
val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count)
let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the one very special case we need
if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instructions_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | count: Vale.Def.Types_s.nat8 -> src: Vale.X64.Machine_s.quad32
-> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32 | Prims.Tot | [
"total"
] | [] | [
"Vale.Def.Types_s.nat8",
"Vale.X64.Machine_s.quad32",
"Vale.X64.Instructions_s.check_avx",
"Vale.X64.Instructions_s.eval_Psrldq_8_raw",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | true | false | let eval_VPsrldq (count: nat8) (src: quad32) : option quad32 =
| check_avx (eval_Psrldq_8_raw count src) | false |
Vale.X64.Instructions_s.fsti | Vale.X64.Instructions_s.eval_SHA256_msg2 | val eval_SHA256_msg2 (src1 src2: quad32) : option quad32 | val eval_SHA256_msg2 (src1 src2: quad32) : option quad32 | let eval_SHA256_msg2 (src1 src2:quad32) : option quad32 =
if sha_enabled then Some (sha256_msg2_spec src1 src2) else None | {
"file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 65,
"end_line": 367,
"start_col": 0,
"start_line": 366
} | module Vale.X64.Instructions_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.CPU_Features_s
open Vale.X64.CryptoInstructions_s
open FStar.Seq.Base
let eval_Mov64 (src:nat64) : option nat64 = Some src
val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64
let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None
val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64
let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst)
val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64
let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst)
val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64
let eval_Add64 (dst src:nat64) : option (bool & nat64) =
let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64)
val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64
let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64)
val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64
let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_carry then 1 else 0) in
Some (sum >= pow2_64, sum % pow2_64)
val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64
let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_flag then 1 else 0) in
if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None
val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
let eval_Sub64 (dst src:nat64) : option (bool & nat64) =
let diff = dst - src in Some (diff < 0, diff % pow2_64)
val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64
let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let diff = dst - (src + (if old_carry then 1 else 0)) in
Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags)
val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64
let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) =
Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src)
val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64
let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) =
let hi = FStar.UInt.mul_div #64 rdx src in
let lo = FStar.UInt.mul_mod #64 rdx src in
if bmi2_enabled then Some (hi, lo) else None
val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64
let eval_IMul64 (dst src:nat64) : option nat64 =
Some (FStar.UInt.mul_mod #64 dst src)
val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64
let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src)
val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64
let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) =
Some (Vale.Def.Types_s.ixor dst src, (false, false))
val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64
let eval_Shr64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None
val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64
let eval_Shl64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None
val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64
let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) =
Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx)))
val ins_Cpuid :
instr_dep
[inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)]
[] PreserveFlags eval_Cpuid
// The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled.
// We underspecify XGETBV here to only support fetching XCR0, which
// is supported on any processor supporting the XGETBV instruction
let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) =
if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None
val ins_Xgetbv :
instr_dep
[out (one64Reg rRax); out (one64Reg rRdx)]
[one64Reg rRcx] PreserveFlags eval_Xgetbv
let check_avx (#a:Type0) (x:option a) : option a =
if avx_enabled then x else None
let check_sse2 (#a:Type0) (x:option a) : option a =
if sse2_enabled then x else None
let check_ssse3 (#a:Type0) (x:option a) : option a =
if ssse3_enabled then x else None
let check_sse4_1 (#a:Type0) (x:option a) : option a =
if sse4_1_enabled then x else None
let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src)
val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu
let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src))
val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor
let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2))
val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor
let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src))
val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand
let eval_Paddd_raw (src1 src2:quad32) : option quad32 =
Some (Mkfour
((src1.lo0 + src2.lo0) % pow2_32)
((src1.lo1 + src2.lo1) % pow2_32)
((src1.hi2 + src2.hi2) % pow2_32)
((src1.hi3 + src2.hi3) % pow2_32))
let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2)
val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd
let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2)
val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd
let eval_Pslld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None)
val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt)
let eval_Psrld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None)
val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt)
let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 (
if 0 <= amt && amt < 16 then
let src_bytes = le_quad32_to_bytes dst in
let zero_pad = Seq.create amt 0 in
let remaining_bytes = slice src_bytes amt (length src_bytes) in
Some (le_bytes_to_quad32 (append zero_pad remaining_bytes))
else None)
val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt)
let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if amount = 4 then
Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0)
else if amount = 8 then
Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1)
else None
let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_ssse3 (eval_Palignr_raw amount src1 src2)
val ins_Palignr (amount:nat8) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount)
let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_avx (eval_Palignr_raw amount src1 src2)
val ins_VPalignr (amount:nat8) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount)
let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 =
if 0 <= permutation && permutation < 4 then
Some (Mkfour
(if permutation % 2 = 0 then src1.lo0 else src1.hi2)
(if permutation % 2 = 0 then src1.lo1 else src1.hi3)
(if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2)
(if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3))
else None
let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_sse2 (eval_Shufpd_raw permutation src1 src2)
val ins_Shufpd (permutation:int) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation)
let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Shufpd_raw permutation src1 src2)
val ins_VShufpd (permutation:int) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation)
let is_full_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x04050607 &&
q.hi3 = 0x00010203
let is_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x00010203 &&
q.lo1 = 0x04050607 &&
q.hi2 = 0x08090A0B &&
q.hi3 = 0x0C0D0E0F
let is_high_dup_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let is_lower_upper_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x04050607 &&
q.lo1 = 0x00010203 &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let eval_Pshufb_raw (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if is_full_byte_reversal_mask src2 then
Some (reverse_bytes_quad32 src1)
else if is_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3))
else if is_high_dup_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else if is_lower_upper_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else None
let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2)
val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb
let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2)
val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb
let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 (
let bits:bits_of_byte = byte_to_twobits permutation in
Some (Mkfour
(select_word src bits.lo0)
(select_word src bits.lo1)
(select_word src bits.hi2)
(select_word src bits.hi3)))
val ins_Pshufd (permutation:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation)
let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 (
let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in
Some (Mkfour
(eq_result (src.lo0 = dst.lo0))
(eq_result (src.lo1 = dst.lo1))
(eq_result (src.hi2 = dst.hi2))
(eq_result (src.hi3 = dst.hi3))))
val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd
let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 (
let src_two = four_to_two_two src in
Some (two_to_nat 32 (two_select src_two (index % 2))))
val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index)
let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4)))
val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index)
let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat64_def dst src (index % 2)))
val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index)
let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the two very special cases we need
if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2)
else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1)
else None
let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src)
val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count)
let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the one very special case we need
if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0)
else None
let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src)
val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count)
let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
let Mkfour a0 a1 a2 a3 = src1 in
let Mkfour b0 b1 b2 b3 = src2 in
let f x0 x1 y0 y1 =
let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in
let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y)
in
if pclmulqdq_enabled then
match imm with
| 0 -> Some (f a0 a1 b0 b1)
| 1 -> Some (f a2 a3 b0 b1)
| 16 -> Some (f a0 a1 b2 b3)
| 17 -> Some (f a2 a3 b2 b3)
| _ -> None
else None
val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm)
let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Pclmulqdq imm src1 src2)
val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm)
let eval_AESNI_enc (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2)
else None
val ins_AESNI_enc : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc
let eval_VAESNI_enc (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc src1 src2)
val ins_VAESNI_enc : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc
let eval_AESNI_enc_last (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1)) src2)
else None
val ins_AESNI_enc_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc_last
let eval_VAESNI_enc_last (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc_last src1 src2)
val ins_VAESNI_enc_last : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc_last
let eval_AESNI_dec (dst src:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.inv_mix_columns_LE (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst))) src)
else None
val ins_AESNI_dec : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec
let eval_AESNI_dec_last (dst src:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst)) src)
else None
val ins_AESNI_dec_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec_last
let eval_AESNI_imc (src:quad32) : option quad32 =
if aesni_enabled then Some (Vale.AES.AES_s.inv_mix_columns_LE src) else None
val ins_AESNI_imc : instr_dep [out opXmm] [opXmm] PreserveFlags eval_AESNI_imc
let eval_AESNI_keygen_assist (imm:nat8) (src:quad32) : option quad32 =
if aesni_enabled then
Some (Mkfour
(Vale.AES.AES_s.sub_word src.lo1)
(ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.lo1)) imm)
(Vale.AES.AES_s.sub_word src.hi3)
(ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.hi3)) imm))
else None
val ins_AESNI_keygen_assist (imm:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_AESNI_keygen_assist imm)
let eval_SHA256_rnds2 (src1 src2 wk:quad32) : option quad32 =
if sha_enabled then Some (sha256_rnds2_spec src1 src2 wk) else None
val ins_SHA256_rnds2 :
instr_dep [inOut opXmm] [opXmm; oneXmm (OReg 0)] PreserveFlags eval_SHA256_rnds2
let eval_SHA256_msg1 (src1 src2:quad32) : option quad32 =
if sha_enabled then Some (sha256_msg1_spec src1 src2) else None
val ins_SHA256_msg1 : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_SHA256_msg1 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instructions_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | src1: Vale.X64.Machine_s.quad32 -> src2: Vale.X64.Machine_s.quad32
-> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32 | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Machine_s.quad32",
"Vale.X64.CPU_Features_s.sha_enabled",
"FStar.Pervasives.Native.Some",
"Vale.X64.CryptoInstructions_s.sha256_msg2_spec",
"Prims.bool",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | true | false | let eval_SHA256_msg2 (src1 src2: quad32) : option quad32 =
| if sha_enabled then Some (sha256_msg2_spec src1 src2) else None | false |
Vale.X64.Instructions_s.fsti | Vale.X64.Instructions_s.eval_Newline | val eval_Newline:option unit | val eval_Newline:option unit | let eval_Newline : option unit = Some () | {
"file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 40,
"end_line": 379,
"start_col": 0,
"start_line": 379
} | module Vale.X64.Instructions_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.CPU_Features_s
open Vale.X64.CryptoInstructions_s
open FStar.Seq.Base
let eval_Mov64 (src:nat64) : option nat64 = Some src
val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64
let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None
val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64
let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst)
val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64
let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst)
val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64
let eval_Add64 (dst src:nat64) : option (bool & nat64) =
let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64)
val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64
let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64)
val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64
let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_carry then 1 else 0) in
Some (sum >= pow2_64, sum % pow2_64)
val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64
let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_flag then 1 else 0) in
if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None
val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
let eval_Sub64 (dst src:nat64) : option (bool & nat64) =
let diff = dst - src in Some (diff < 0, diff % pow2_64)
val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64
let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let diff = dst - (src + (if old_carry then 1 else 0)) in
Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags)
val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64
let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) =
Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src)
val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64
let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) =
let hi = FStar.UInt.mul_div #64 rdx src in
let lo = FStar.UInt.mul_mod #64 rdx src in
if bmi2_enabled then Some (hi, lo) else None
val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64
let eval_IMul64 (dst src:nat64) : option nat64 =
Some (FStar.UInt.mul_mod #64 dst src)
val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64
let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src)
val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64
let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) =
Some (Vale.Def.Types_s.ixor dst src, (false, false))
val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64
let eval_Shr64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None
val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64
let eval_Shl64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None
val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64
let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) =
Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx)))
val ins_Cpuid :
instr_dep
[inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)]
[] PreserveFlags eval_Cpuid
// The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled.
// We underspecify XGETBV here to only support fetching XCR0, which
// is supported on any processor supporting the XGETBV instruction
let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) =
if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None
val ins_Xgetbv :
instr_dep
[out (one64Reg rRax); out (one64Reg rRdx)]
[one64Reg rRcx] PreserveFlags eval_Xgetbv
let check_avx (#a:Type0) (x:option a) : option a =
if avx_enabled then x else None
let check_sse2 (#a:Type0) (x:option a) : option a =
if sse2_enabled then x else None
let check_ssse3 (#a:Type0) (x:option a) : option a =
if ssse3_enabled then x else None
let check_sse4_1 (#a:Type0) (x:option a) : option a =
if sse4_1_enabled then x else None
let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src)
val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu
let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src))
val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor
let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2))
val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor
let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src))
val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand
let eval_Paddd_raw (src1 src2:quad32) : option quad32 =
Some (Mkfour
((src1.lo0 + src2.lo0) % pow2_32)
((src1.lo1 + src2.lo1) % pow2_32)
((src1.hi2 + src2.hi2) % pow2_32)
((src1.hi3 + src2.hi3) % pow2_32))
let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2)
val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd
let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2)
val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd
let eval_Pslld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None)
val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt)
let eval_Psrld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None)
val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt)
let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 (
if 0 <= amt && amt < 16 then
let src_bytes = le_quad32_to_bytes dst in
let zero_pad = Seq.create amt 0 in
let remaining_bytes = slice src_bytes amt (length src_bytes) in
Some (le_bytes_to_quad32 (append zero_pad remaining_bytes))
else None)
val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt)
let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if amount = 4 then
Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0)
else if amount = 8 then
Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1)
else None
let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_ssse3 (eval_Palignr_raw amount src1 src2)
val ins_Palignr (amount:nat8) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount)
let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_avx (eval_Palignr_raw amount src1 src2)
val ins_VPalignr (amount:nat8) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount)
let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 =
if 0 <= permutation && permutation < 4 then
Some (Mkfour
(if permutation % 2 = 0 then src1.lo0 else src1.hi2)
(if permutation % 2 = 0 then src1.lo1 else src1.hi3)
(if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2)
(if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3))
else None
let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_sse2 (eval_Shufpd_raw permutation src1 src2)
val ins_Shufpd (permutation:int) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation)
let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Shufpd_raw permutation src1 src2)
val ins_VShufpd (permutation:int) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation)
let is_full_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x04050607 &&
q.hi3 = 0x00010203
let is_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x00010203 &&
q.lo1 = 0x04050607 &&
q.hi2 = 0x08090A0B &&
q.hi3 = 0x0C0D0E0F
let is_high_dup_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let is_lower_upper_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x04050607 &&
q.lo1 = 0x00010203 &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let eval_Pshufb_raw (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if is_full_byte_reversal_mask src2 then
Some (reverse_bytes_quad32 src1)
else if is_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3))
else if is_high_dup_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else if is_lower_upper_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else None
let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2)
val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb
let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2)
val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb
let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 (
let bits:bits_of_byte = byte_to_twobits permutation in
Some (Mkfour
(select_word src bits.lo0)
(select_word src bits.lo1)
(select_word src bits.hi2)
(select_word src bits.hi3)))
val ins_Pshufd (permutation:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation)
let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 (
let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in
Some (Mkfour
(eq_result (src.lo0 = dst.lo0))
(eq_result (src.lo1 = dst.lo1))
(eq_result (src.hi2 = dst.hi2))
(eq_result (src.hi3 = dst.hi3))))
val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd
let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 (
let src_two = four_to_two_two src in
Some (two_to_nat 32 (two_select src_two (index % 2))))
val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index)
let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4)))
val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index)
let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat64_def dst src (index % 2)))
val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index)
let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the two very special cases we need
if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2)
else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1)
else None
let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src)
val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count)
let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the one very special case we need
if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0)
else None
let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src)
val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count)
let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
let Mkfour a0 a1 a2 a3 = src1 in
let Mkfour b0 b1 b2 b3 = src2 in
let f x0 x1 y0 y1 =
let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in
let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y)
in
if pclmulqdq_enabled then
match imm with
| 0 -> Some (f a0 a1 b0 b1)
| 1 -> Some (f a2 a3 b0 b1)
| 16 -> Some (f a0 a1 b2 b3)
| 17 -> Some (f a2 a3 b2 b3)
| _ -> None
else None
val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm)
let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Pclmulqdq imm src1 src2)
val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm)
let eval_AESNI_enc (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2)
else None
val ins_AESNI_enc : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc
let eval_VAESNI_enc (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc src1 src2)
val ins_VAESNI_enc : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc
let eval_AESNI_enc_last (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1)) src2)
else None
val ins_AESNI_enc_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc_last
let eval_VAESNI_enc_last (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc_last src1 src2)
val ins_VAESNI_enc_last : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc_last
let eval_AESNI_dec (dst src:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.inv_mix_columns_LE (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst))) src)
else None
val ins_AESNI_dec : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec
let eval_AESNI_dec_last (dst src:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst)) src)
else None
val ins_AESNI_dec_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec_last
let eval_AESNI_imc (src:quad32) : option quad32 =
if aesni_enabled then Some (Vale.AES.AES_s.inv_mix_columns_LE src) else None
val ins_AESNI_imc : instr_dep [out opXmm] [opXmm] PreserveFlags eval_AESNI_imc
let eval_AESNI_keygen_assist (imm:nat8) (src:quad32) : option quad32 =
if aesni_enabled then
Some (Mkfour
(Vale.AES.AES_s.sub_word src.lo1)
(ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.lo1)) imm)
(Vale.AES.AES_s.sub_word src.hi3)
(ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.hi3)) imm))
else None
val ins_AESNI_keygen_assist (imm:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_AESNI_keygen_assist imm)
let eval_SHA256_rnds2 (src1 src2 wk:quad32) : option quad32 =
if sha_enabled then Some (sha256_rnds2_spec src1 src2 wk) else None
val ins_SHA256_rnds2 :
instr_dep [inOut opXmm] [opXmm; oneXmm (OReg 0)] PreserveFlags eval_SHA256_rnds2
let eval_SHA256_msg1 (src1 src2:quad32) : option quad32 =
if sha_enabled then Some (sha256_msg1_spec src1 src2) else None
val ins_SHA256_msg1 : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_SHA256_msg1
let eval_SHA256_msg2 (src1 src2:quad32) : option quad32 =
if sha_enabled then Some (sha256_msg2_spec src1 src2) else None
val ins_SHA256_msg2 : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_SHA256_msg2
let eval_Ghost : option unit = Some ()
val ins_Ghost : instr_dep [] [] PreserveFlags eval_Ghost
let eval_Comment : option unit = Some ()
val ins_Comment (_:string) : instr_dep [] [] PreserveFlags eval_Comment
let eval_LargeComment : option unit = Some ()
val ins_LargeComment (_:string) : instr_dep [] [] PreserveFlags eval_LargeComment | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instructions_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.Pervasives.Native.option Prims.unit | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.Native.Some",
"Prims.unit"
] | [] | false | false | false | true | false | let eval_Newline:option unit =
| Some () | false |
Vale.X64.Instructions_s.fsti | Vale.X64.Instructions_s.eval_AESNI_enc_last | val eval_AESNI_enc_last (src1 src2: quad32) : option quad32 | val eval_AESNI_enc_last (src1 src2: quad32) : option quad32 | let eval_AESNI_enc_last (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1)) src2)
else None | {
"file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 324,
"start_col": 0,
"start_line": 321
} | module Vale.X64.Instructions_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.CPU_Features_s
open Vale.X64.CryptoInstructions_s
open FStar.Seq.Base
let eval_Mov64 (src:nat64) : option nat64 = Some src
val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64
let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None
val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64
let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst)
val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64
let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst)
val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64
let eval_Add64 (dst src:nat64) : option (bool & nat64) =
let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64)
val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64
let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64)
val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64
let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_carry then 1 else 0) in
Some (sum >= pow2_64, sum % pow2_64)
val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64
let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_flag then 1 else 0) in
if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None
val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
let eval_Sub64 (dst src:nat64) : option (bool & nat64) =
let diff = dst - src in Some (diff < 0, diff % pow2_64)
val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64
let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let diff = dst - (src + (if old_carry then 1 else 0)) in
Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags)
val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64
let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) =
Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src)
val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64
let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) =
let hi = FStar.UInt.mul_div #64 rdx src in
let lo = FStar.UInt.mul_mod #64 rdx src in
if bmi2_enabled then Some (hi, lo) else None
val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64
let eval_IMul64 (dst src:nat64) : option nat64 =
Some (FStar.UInt.mul_mod #64 dst src)
val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64
let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src)
val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64
let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) =
Some (Vale.Def.Types_s.ixor dst src, (false, false))
val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64
let eval_Shr64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None
val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64
let eval_Shl64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None
val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64
let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) =
Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx)))
val ins_Cpuid :
instr_dep
[inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)]
[] PreserveFlags eval_Cpuid
// The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled.
// We underspecify XGETBV here to only support fetching XCR0, which
// is supported on any processor supporting the XGETBV instruction
let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) =
if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None
val ins_Xgetbv :
instr_dep
[out (one64Reg rRax); out (one64Reg rRdx)]
[one64Reg rRcx] PreserveFlags eval_Xgetbv
let check_avx (#a:Type0) (x:option a) : option a =
if avx_enabled then x else None
let check_sse2 (#a:Type0) (x:option a) : option a =
if sse2_enabled then x else None
let check_ssse3 (#a:Type0) (x:option a) : option a =
if ssse3_enabled then x else None
let check_sse4_1 (#a:Type0) (x:option a) : option a =
if sse4_1_enabled then x else None
let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src)
val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu
let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src))
val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor
let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2))
val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor
let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src))
val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand
let eval_Paddd_raw (src1 src2:quad32) : option quad32 =
Some (Mkfour
((src1.lo0 + src2.lo0) % pow2_32)
((src1.lo1 + src2.lo1) % pow2_32)
((src1.hi2 + src2.hi2) % pow2_32)
((src1.hi3 + src2.hi3) % pow2_32))
let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2)
val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd
let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2)
val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd
let eval_Pslld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None)
val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt)
let eval_Psrld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None)
val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt)
let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 (
if 0 <= amt && amt < 16 then
let src_bytes = le_quad32_to_bytes dst in
let zero_pad = Seq.create amt 0 in
let remaining_bytes = slice src_bytes amt (length src_bytes) in
Some (le_bytes_to_quad32 (append zero_pad remaining_bytes))
else None)
val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt)
let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if amount = 4 then
Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0)
else if amount = 8 then
Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1)
else None
let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_ssse3 (eval_Palignr_raw amount src1 src2)
val ins_Palignr (amount:nat8) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount)
let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_avx (eval_Palignr_raw amount src1 src2)
val ins_VPalignr (amount:nat8) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount)
let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 =
if 0 <= permutation && permutation < 4 then
Some (Mkfour
(if permutation % 2 = 0 then src1.lo0 else src1.hi2)
(if permutation % 2 = 0 then src1.lo1 else src1.hi3)
(if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2)
(if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3))
else None
let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_sse2 (eval_Shufpd_raw permutation src1 src2)
val ins_Shufpd (permutation:int) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation)
let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Shufpd_raw permutation src1 src2)
val ins_VShufpd (permutation:int) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation)
let is_full_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x04050607 &&
q.hi3 = 0x00010203
let is_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x00010203 &&
q.lo1 = 0x04050607 &&
q.hi2 = 0x08090A0B &&
q.hi3 = 0x0C0D0E0F
let is_high_dup_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let is_lower_upper_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x04050607 &&
q.lo1 = 0x00010203 &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let eval_Pshufb_raw (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if is_full_byte_reversal_mask src2 then
Some (reverse_bytes_quad32 src1)
else if is_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3))
else if is_high_dup_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else if is_lower_upper_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else None
let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2)
val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb
let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2)
val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb
let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 (
let bits:bits_of_byte = byte_to_twobits permutation in
Some (Mkfour
(select_word src bits.lo0)
(select_word src bits.lo1)
(select_word src bits.hi2)
(select_word src bits.hi3)))
val ins_Pshufd (permutation:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation)
let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 (
let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in
Some (Mkfour
(eq_result (src.lo0 = dst.lo0))
(eq_result (src.lo1 = dst.lo1))
(eq_result (src.hi2 = dst.hi2))
(eq_result (src.hi3 = dst.hi3))))
val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd
let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 (
let src_two = four_to_two_two src in
Some (two_to_nat 32 (two_select src_two (index % 2))))
val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index)
let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4)))
val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index)
let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat64_def dst src (index % 2)))
val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index)
let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the two very special cases we need
if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2)
else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1)
else None
let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src)
val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count)
let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the one very special case we need
if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0)
else None
let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src)
val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count)
let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
let Mkfour a0 a1 a2 a3 = src1 in
let Mkfour b0 b1 b2 b3 = src2 in
let f x0 x1 y0 y1 =
let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in
let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y)
in
if pclmulqdq_enabled then
match imm with
| 0 -> Some (f a0 a1 b0 b1)
| 1 -> Some (f a2 a3 b0 b1)
| 16 -> Some (f a0 a1 b2 b3)
| 17 -> Some (f a2 a3 b2 b3)
| _ -> None
else None
val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm)
let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Pclmulqdq imm src1 src2)
val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm)
let eval_AESNI_enc (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2)
else None
val ins_AESNI_enc : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc
let eval_VAESNI_enc (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc src1 src2)
val ins_VAESNI_enc : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instructions_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | src1: Vale.X64.Machine_s.quad32 -> src2: Vale.X64.Machine_s.quad32
-> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32 | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Machine_s.quad32",
"Vale.X64.CPU_Features_s.aesni_enabled",
"FStar.Pervasives.Native.Some",
"Vale.Def.Types_s.quad32_xor",
"Vale.AES.AES_common_s.sub_bytes",
"Vale.AES.AES_s.shift_rows_LE",
"Prims.bool",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | true | false | let eval_AESNI_enc_last (src1 src2: quad32) : option quad32 =
| if aesni_enabled
then Some (quad32_xor (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1)) src2)
else None | false |
Vale.X64.Instructions_s.fsti | Vale.X64.Instructions_s.eval_Space | val eval_Space:option unit | val eval_Space:option unit | let eval_Space : option unit = Some () | {
"file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 38,
"end_line": 382,
"start_col": 0,
"start_line": 382
} | module Vale.X64.Instructions_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.CPU_Features_s
open Vale.X64.CryptoInstructions_s
open FStar.Seq.Base
let eval_Mov64 (src:nat64) : option nat64 = Some src
val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64
let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None
val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64
let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst)
val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64
let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst)
val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64
let eval_Add64 (dst src:nat64) : option (bool & nat64) =
let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64)
val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64
let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64)
val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64
let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_carry then 1 else 0) in
Some (sum >= pow2_64, sum % pow2_64)
val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64
let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_flag then 1 else 0) in
if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None
val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
let eval_Sub64 (dst src:nat64) : option (bool & nat64) =
let diff = dst - src in Some (diff < 0, diff % pow2_64)
val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64
let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let diff = dst - (src + (if old_carry then 1 else 0)) in
Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags)
val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64
let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) =
Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src)
val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64
let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) =
let hi = FStar.UInt.mul_div #64 rdx src in
let lo = FStar.UInt.mul_mod #64 rdx src in
if bmi2_enabled then Some (hi, lo) else None
val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64
let eval_IMul64 (dst src:nat64) : option nat64 =
Some (FStar.UInt.mul_mod #64 dst src)
val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64
let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src)
val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64
let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) =
Some (Vale.Def.Types_s.ixor dst src, (false, false))
val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64
let eval_Shr64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None
val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64
let eval_Shl64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None
val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64
let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) =
Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx)))
val ins_Cpuid :
instr_dep
[inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)]
[] PreserveFlags eval_Cpuid
// The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled.
// We underspecify XGETBV here to only support fetching XCR0, which
// is supported on any processor supporting the XGETBV instruction
let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) =
if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None
val ins_Xgetbv :
instr_dep
[out (one64Reg rRax); out (one64Reg rRdx)]
[one64Reg rRcx] PreserveFlags eval_Xgetbv
let check_avx (#a:Type0) (x:option a) : option a =
if avx_enabled then x else None
let check_sse2 (#a:Type0) (x:option a) : option a =
if sse2_enabled then x else None
let check_ssse3 (#a:Type0) (x:option a) : option a =
if ssse3_enabled then x else None
let check_sse4_1 (#a:Type0) (x:option a) : option a =
if sse4_1_enabled then x else None
let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src)
val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu
let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src))
val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor
let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2))
val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor
let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src))
val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand
let eval_Paddd_raw (src1 src2:quad32) : option quad32 =
Some (Mkfour
((src1.lo0 + src2.lo0) % pow2_32)
((src1.lo1 + src2.lo1) % pow2_32)
((src1.hi2 + src2.hi2) % pow2_32)
((src1.hi3 + src2.hi3) % pow2_32))
let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2)
val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd
let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2)
val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd
let eval_Pslld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None)
val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt)
let eval_Psrld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None)
val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt)
let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 (
if 0 <= amt && amt < 16 then
let src_bytes = le_quad32_to_bytes dst in
let zero_pad = Seq.create amt 0 in
let remaining_bytes = slice src_bytes amt (length src_bytes) in
Some (le_bytes_to_quad32 (append zero_pad remaining_bytes))
else None)
val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt)
let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if amount = 4 then
Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0)
else if amount = 8 then
Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1)
else None
let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_ssse3 (eval_Palignr_raw amount src1 src2)
val ins_Palignr (amount:nat8) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount)
let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_avx (eval_Palignr_raw amount src1 src2)
val ins_VPalignr (amount:nat8) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount)
let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 =
if 0 <= permutation && permutation < 4 then
Some (Mkfour
(if permutation % 2 = 0 then src1.lo0 else src1.hi2)
(if permutation % 2 = 0 then src1.lo1 else src1.hi3)
(if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2)
(if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3))
else None
let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_sse2 (eval_Shufpd_raw permutation src1 src2)
val ins_Shufpd (permutation:int) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation)
let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Shufpd_raw permutation src1 src2)
val ins_VShufpd (permutation:int) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation)
let is_full_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x04050607 &&
q.hi3 = 0x00010203
let is_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x00010203 &&
q.lo1 = 0x04050607 &&
q.hi2 = 0x08090A0B &&
q.hi3 = 0x0C0D0E0F
let is_high_dup_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let is_lower_upper_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x04050607 &&
q.lo1 = 0x00010203 &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let eval_Pshufb_raw (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if is_full_byte_reversal_mask src2 then
Some (reverse_bytes_quad32 src1)
else if is_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3))
else if is_high_dup_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else if is_lower_upper_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else None
let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2)
val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb
let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2)
val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb
let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 (
let bits:bits_of_byte = byte_to_twobits permutation in
Some (Mkfour
(select_word src bits.lo0)
(select_word src bits.lo1)
(select_word src bits.hi2)
(select_word src bits.hi3)))
val ins_Pshufd (permutation:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation)
let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 (
let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in
Some (Mkfour
(eq_result (src.lo0 = dst.lo0))
(eq_result (src.lo1 = dst.lo1))
(eq_result (src.hi2 = dst.hi2))
(eq_result (src.hi3 = dst.hi3))))
val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd
let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 (
let src_two = four_to_two_two src in
Some (two_to_nat 32 (two_select src_two (index % 2))))
val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index)
let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4)))
val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index)
let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat64_def dst src (index % 2)))
val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index)
let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the two very special cases we need
if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2)
else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1)
else None
let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src)
val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count)
let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the one very special case we need
if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0)
else None
let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src)
val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count)
let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
let Mkfour a0 a1 a2 a3 = src1 in
let Mkfour b0 b1 b2 b3 = src2 in
let f x0 x1 y0 y1 =
let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in
let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y)
in
if pclmulqdq_enabled then
match imm with
| 0 -> Some (f a0 a1 b0 b1)
| 1 -> Some (f a2 a3 b0 b1)
| 16 -> Some (f a0 a1 b2 b3)
| 17 -> Some (f a2 a3 b2 b3)
| _ -> None
else None
val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm)
let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Pclmulqdq imm src1 src2)
val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm)
let eval_AESNI_enc (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2)
else None
val ins_AESNI_enc : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc
let eval_VAESNI_enc (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc src1 src2)
val ins_VAESNI_enc : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc
let eval_AESNI_enc_last (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1)) src2)
else None
val ins_AESNI_enc_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc_last
let eval_VAESNI_enc_last (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc_last src1 src2)
val ins_VAESNI_enc_last : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc_last
let eval_AESNI_dec (dst src:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.inv_mix_columns_LE (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst))) src)
else None
val ins_AESNI_dec : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec
let eval_AESNI_dec_last (dst src:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst)) src)
else None
val ins_AESNI_dec_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec_last
let eval_AESNI_imc (src:quad32) : option quad32 =
if aesni_enabled then Some (Vale.AES.AES_s.inv_mix_columns_LE src) else None
val ins_AESNI_imc : instr_dep [out opXmm] [opXmm] PreserveFlags eval_AESNI_imc
let eval_AESNI_keygen_assist (imm:nat8) (src:quad32) : option quad32 =
if aesni_enabled then
Some (Mkfour
(Vale.AES.AES_s.sub_word src.lo1)
(ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.lo1)) imm)
(Vale.AES.AES_s.sub_word src.hi3)
(ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.hi3)) imm))
else None
val ins_AESNI_keygen_assist (imm:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_AESNI_keygen_assist imm)
let eval_SHA256_rnds2 (src1 src2 wk:quad32) : option quad32 =
if sha_enabled then Some (sha256_rnds2_spec src1 src2 wk) else None
val ins_SHA256_rnds2 :
instr_dep [inOut opXmm] [opXmm; oneXmm (OReg 0)] PreserveFlags eval_SHA256_rnds2
let eval_SHA256_msg1 (src1 src2:quad32) : option quad32 =
if sha_enabled then Some (sha256_msg1_spec src1 src2) else None
val ins_SHA256_msg1 : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_SHA256_msg1
let eval_SHA256_msg2 (src1 src2:quad32) : option quad32 =
if sha_enabled then Some (sha256_msg2_spec src1 src2) else None
val ins_SHA256_msg2 : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_SHA256_msg2
let eval_Ghost : option unit = Some ()
val ins_Ghost : instr_dep [] [] PreserveFlags eval_Ghost
let eval_Comment : option unit = Some ()
val ins_Comment (_:string) : instr_dep [] [] PreserveFlags eval_Comment
let eval_LargeComment : option unit = Some ()
val ins_LargeComment (_:string) : instr_dep [] [] PreserveFlags eval_LargeComment
let eval_Newline : option unit = Some ()
val ins_Newline : instr_dep [] [] PreserveFlags eval_Newline | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instructions_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.Pervasives.Native.option Prims.unit | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.Native.Some",
"Prims.unit"
] | [] | false | false | false | true | false | let eval_Space:option unit =
| Some () | false |
Spec.Box.fst | Spec.Box.size_publickey | val size_publickey : Prims.int | let size_publickey = 32 | {
"file_name": "specs/Spec.Box.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 23,
"end_line": 13,
"start_col": 0,
"start_line": 13
} | module Spec.Box
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.SecretBox
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" | {
"checked_file": "/",
"dependencies": [
"Spec.SecretBox.fst.checked",
"Spec.Salsa20.fst.checked",
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Box.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.SecretBox",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.int | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | true | false | let size_publickey =
| 32 | false |
|
Spec.Box.fst | Spec.Box.size_secretkey | val size_secretkey : Prims.int | let size_secretkey = 32 | {
"file_name": "specs/Spec.Box.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 23,
"end_line": 14,
"start_col": 0,
"start_line": 14
} | module Spec.Box
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.SecretBox
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
(* Constants *) | {
"checked_file": "/",
"dependencies": [
"Spec.SecretBox.fst.checked",
"Spec.Salsa20.fst.checked",
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Box.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.SecretBox",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.int | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | true | false | let size_secretkey =
| 32 | false |
|
Vale.X64.Instructions_s.fsti | Vale.X64.Instructions_s.eval_Psrldq | val eval_Psrldq (amt: int) (dst: quad32) : option quad32 | val eval_Psrldq (amt: int) (dst: quad32) : option quad32 | let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 (
if 0 <= amt && amt < 16 then
let src_bytes = le_quad32_to_bytes dst in
let zero_pad = Seq.create amt 0 in
let remaining_bytes = slice src_bytes amt (length src_bytes) in
Some (le_bytes_to_quad32 (append zero_pad remaining_bytes))
else None) | {
"file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 12,
"end_line": 149,
"start_col": 0,
"start_line": 143
} | module Vale.X64.Instructions_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.CPU_Features_s
open Vale.X64.CryptoInstructions_s
open FStar.Seq.Base
let eval_Mov64 (src:nat64) : option nat64 = Some src
val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64
let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None
val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64
let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst)
val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64
let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst)
val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64
let eval_Add64 (dst src:nat64) : option (bool & nat64) =
let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64)
val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64
let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64)
val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64
let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_carry then 1 else 0) in
Some (sum >= pow2_64, sum % pow2_64)
val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64
let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_flag then 1 else 0) in
if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None
val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
let eval_Sub64 (dst src:nat64) : option (bool & nat64) =
let diff = dst - src in Some (diff < 0, diff % pow2_64)
val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64
let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let diff = dst - (src + (if old_carry then 1 else 0)) in
Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags)
val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64
let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) =
Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src)
val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64
let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) =
let hi = FStar.UInt.mul_div #64 rdx src in
let lo = FStar.UInt.mul_mod #64 rdx src in
if bmi2_enabled then Some (hi, lo) else None
val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64
let eval_IMul64 (dst src:nat64) : option nat64 =
Some (FStar.UInt.mul_mod #64 dst src)
val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64
let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src)
val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64
let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) =
Some (Vale.Def.Types_s.ixor dst src, (false, false))
val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64
let eval_Shr64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None
val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64
let eval_Shl64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None
val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64
let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) =
Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx)))
val ins_Cpuid :
instr_dep
[inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)]
[] PreserveFlags eval_Cpuid
// The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled.
// We underspecify XGETBV here to only support fetching XCR0, which
// is supported on any processor supporting the XGETBV instruction
let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) =
if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None
val ins_Xgetbv :
instr_dep
[out (one64Reg rRax); out (one64Reg rRdx)]
[one64Reg rRcx] PreserveFlags eval_Xgetbv
let check_avx (#a:Type0) (x:option a) : option a =
if avx_enabled then x else None
let check_sse2 (#a:Type0) (x:option a) : option a =
if sse2_enabled then x else None
let check_ssse3 (#a:Type0) (x:option a) : option a =
if ssse3_enabled then x else None
let check_sse4_1 (#a:Type0) (x:option a) : option a =
if sse4_1_enabled then x else None
let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src)
val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu
let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src))
val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor
let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2))
val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor
let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src))
val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand
let eval_Paddd_raw (src1 src2:quad32) : option quad32 =
Some (Mkfour
((src1.lo0 + src2.lo0) % pow2_32)
((src1.lo1 + src2.lo1) % pow2_32)
((src1.hi2 + src2.hi2) % pow2_32)
((src1.hi3 + src2.hi3) % pow2_32))
let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2)
val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd
let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2)
val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd
let eval_Pslld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None)
val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt)
let eval_Psrld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None)
val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instructions_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | amt: Prims.int -> dst: Vale.X64.Machine_s.quad32
-> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32 | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Vale.X64.Machine_s.quad32",
"Vale.X64.Instructions_s.check_sse2",
"Prims.op_AmpAmp",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"FStar.Pervasives.Native.Some",
"Vale.Def.Types_s.le_bytes_to_quad32",
"FStar.Seq.Base.append",
"Vale.Def.Types_s.nat8",
"FStar.Seq.Base.seq",
"Vale.Def.Words_s.nat8",
"FStar.Seq.Base.slice",
"FStar.Seq.Base.length",
"FStar.Seq.Base.create",
"Vale.Def.Types_s.le_quad32_to_bytes",
"Prims.bool",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | true | false | let eval_Psrldq (amt: int) (dst: quad32) : option quad32 =
| check_sse2 (if 0 <= amt && amt < 16
then
let src_bytes = le_quad32_to_bytes dst in
let zero_pad = Seq.create amt 0 in
let remaining_bytes = slice src_bytes amt (length src_bytes) in
Some (le_bytes_to_quad32 (append zero_pad remaining_bytes))
else None) | false |
Vale.AES.X64.GCMdecryptOpt.fst | Vale.AES.X64.GCMdecryptOpt.va_quick_Gcm_blocks | val va_quick_Gcm_blocks
(alg: algorithm)
(offset: int)
(auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b scratch_b: buffer128)
(key: (seq nat32))
(round_keys: (seq quad32))
(keys_b hkeys_b: buffer128)
: (va_quickCode unit (va_code_Gcm_blocks alg offset)) | val va_quick_Gcm_blocks
(alg: algorithm)
(offset: int)
(auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b scratch_b: buffer128)
(key: (seq nat32))
(round_keys: (seq quad32))
(keys_b hkeys_b: buffer128)
: (va_quickCode unit (va_code_Gcm_blocks alg offset)) | let va_quick_Gcm_blocks (alg:algorithm) (offset:int) (auth_b:buffer128) (abytes_b:buffer128)
(in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128) (out128_b:buffer128)
(inout_b:buffer128) (iv_b:buffer128) (scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit (va_code_Gcm_blocks alg
offset)) =
(va_QProc (va_code_Gcm_blocks alg offset) ([va_Mod_flags; va_Mod_mem_heaplet 6;
va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1;
va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10;
va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm
3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64
rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64
rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64
rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_Gcm_blocks alg offset auth_b
abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b scratch_b key round_keys keys_b
hkeys_b) (va_wpProof_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b)) | {
"file_name": "obj/Vale.AES.X64.GCMdecryptOpt.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 67,
"end_line": 1352,
"start_col": 0,
"start_line": 1337
} | module Vale.AES.X64.GCMdecryptOpt
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open FStar.Seq
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_s
open Vale.AES.GCTR_s
open Vale.AES.GCTR
open Vale.AES.GCM
open Vale.AES.GHash_s
open Vale.AES.GHash
open Vale.AES.GCM_s
open Vale.AES.X64.AES
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.Poly1305.Math
open Vale.AES.GCM_helpers
open Vale.AES.X64.GHash
open Vale.AES.X64.GCTR
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.X64.Stack_i
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.InsBasic
open Vale.X64.InsMem
open Vale.X64.InsVector
open Vale.X64.InsStack
open Vale.X64.InsAes
open Vale.X64.QuickCode
open Vale.X64.QuickCodes
open Vale.AES.X64.GF128_Mul
open Vale.X64.Stack
open Vale.X64.CPU_Features_s
open Vale.Math.Poly2.Bits_s
open Vale.AES.X64.AESopt
open Vale.AES.X64.AESGCM
open Vale.AES.X64.AESopt2
open Vale.Lib.Meta
open Vale.AES.X64.GCMencryptOpt
open Vale.AES.OptPublic
open Vale.Lib.Basic
#reset-options "--z3rlimit 20 --max_ifuel 0"
//-- Gcm_extra_bytes
val va_code_Gcm_extra_bytes : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_extra_bytes alg =
(va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0)
(va_op_reg_opr64_reg64 rRax) 0 Secret) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 10)
(va_op_xmm_xmm 0)) (va_CCons (va_code_Ghash_extra_bytes ()) (va_CCons (va_code_Mov128
(va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_CCons (va_code_Pshufb (va_op_xmm_xmm 0)
(va_op_xmm_xmm 9)) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons (va_code_Pxor
(va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_CCons (va_code_Store128_buffer
(va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret)
(va_CNil ()))))))))))
val va_codegen_success_Gcm_extra_bytes : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_extra_bytes alg =
(va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0)
(va_op_reg_opr64_reg64 rRax) 0 Secret) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm
10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Ghash_extra_bytes ()) (va_pbool_and
(va_codegen_success_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_pbool_and
(va_codegen_success_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and
(va_codegen_success_AESEncryptBlock alg) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm
10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Store128_buffer
(va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret)
(va_ttrue ())))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_extra_bytes (va_mods:va_mods_t) (alg:algorithm) (inout_b:buffer128) (key:(seq
nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat)
(old_hash:quad32) (completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit
(va_code_Gcm_extra_bytes alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (len:(va_int_range
1 1)) = 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 188 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRax) 0 Secret inout_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 189 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (fun (va_s:va_state) _ -> let
(hash_input:quad32) = va_get_xmm 0 va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 193 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_extra_bytes hkeys_b total_bytes old_hash h_LE completed_quads) (fun
(va_s:va_state) _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 194 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.equal #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s)
inout_b) (FStar.Seq.Base.create #quad32 1 hash_input)) (let (snap:(FStar.Seq.Base.seq
Vale.X64.Decls.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 198 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 199 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 200 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AESEncryptBlock alg (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 11 va_s)) key
round_keys keys_b) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 201 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.AES_s.aes_encrypt_LE_reveal ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 204 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 205 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax)
(va_op_xmm_xmm 10) 0 Secret inout_b 0) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 207 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.gctr_partial_reveal ()) (va_QEmpty (()))))))))))))))
val va_lemma_Gcm_extra_bytes : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
inout_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> total_bytes:nat -> old_hash:quad32 -> completed_quads:(seq quad32) ->
h_LE:quad32
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_extra_bytes alg) va_s0 /\ va_get_ok va_s0 /\ (let
(len:(va_int_range 1 1)) = 1 in sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b
inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b inout_b /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax va_s0) inout_b
len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys
keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0
va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32
(Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length
#quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply`
FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes
`op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16
`op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
(Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads =
FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0)
inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes =
Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) /\ va_state_eq va_sM
(va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM (va_update_ok va_sM
(va_update_mem va_sM va_s0))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_extra_bytes va_b0 va_s0 alg inout_b key round_keys keys_b hkeys_b total_bytes
old_hash completed_quads h_LE =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_extra_bytes va_mods alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_extra_bytes alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 121 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (len:(va_int_range 1 1)) = 1 in label va_range1
"***** POSTCONDITION NOT MET AT line 174 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 177 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg len (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0)) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 180 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let raw_quads = FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 181 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 182 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 183 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let input_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 186 column 59 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(l_and (FStar.Seq.Base.length #Vale.Def.Types_s.quad32 input_quads > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE old_hash input_quads)))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm
7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32)
(completed_quads:(seq quad32)) (h_LE:quad32) (va_s0:va_state) (va_k:(va_state -> unit -> Type0))
: Type0 =
(va_get_ok va_s0 /\ (let (len:(va_int_range 1 1)) = 1 in sse_enabled /\
Vale.X64.Decls.buffers_disjoint128 keys_b inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b
inout_b /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax
va_s0) inout_b len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys
keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0
va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32
(Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length
#quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply`
FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes
`op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16
`op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
(Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes) /\ (forall
(va_x_mem:vale_heap) (va_x_rcx:nat64) (va_x_r11:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32)
(va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32)
(va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm10:quad32) (va_x_heap5:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 5
va_x_heap5 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7
(va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3
(va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR11
va_x_r11 (va_upd_reg64 rRcx va_x_rcx (va_upd_mem va_x_mem va_s0)))))))))))))) in va_get_ok
va_sM /\ (let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads =
FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0)
inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes =
Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) ==> va_k va_sM (())))
val va_wpProof_Gcm_extra_bytes : alg:algorithm -> inout_b:buffer128 -> key:(seq nat32) ->
round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> total_bytes:nat ->
old_hash:quad32 -> completed_quads:(seq quad32) -> h_LE: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_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_extra_bytes alg) ([va_Mod_flags;
va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5;
va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11;
va_Mod_reg64 rRcx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash
completed_quads h_LE va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_extra_bytes (va_code_Gcm_extra_bytes alg) va_s0 alg inout_b key
round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10
va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm
7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32)
(completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit (va_code_Gcm_extra_bytes alg)) =
(va_QProc (va_code_Gcm_extra_bytes alg) ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10;
va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm
2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem])
(va_wp_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash
completed_quads h_LE) (va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE))
//--
//-- Gcm_blocks128
val va_code_Gcm_blocks128 : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks128 alg =
(va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi))
(va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_CCons
(va_code_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_CCons
(va_code_Ghash_buffer ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdi)
(va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx)
(va_op_opr64_reg64 rR12)) (va_CCons (va_code_Gctr_blocks128 alg) (va_CNil ())))))))))
val va_codegen_success_Gcm_blocks128 : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks128 alg =
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi))
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx))
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax))
(va_pbool_and (va_codegen_success_Ghash_buffer ()) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_pbool_and
(va_codegen_success_Gctr_blocks128 alg) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks128 (va_mods:va_mods_t) (alg:algorithm) (in_b:buffer128) (out_b:buffer128)
(key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32)
: (va_quickCode unit (va_code_Gcm_blocks128 alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 274 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 275 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 276 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 277 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_buffer hkeys_b in_b h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_old_s))) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 278 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 279 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 280 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gctr_blocks128 alg in_b out_b key round_keys keys_b) (va_QEmpty (()))))))))))
val va_lemma_Gcm_blocks128 : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> in_b:buffer128 ->
out_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> h_LE:quad32
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks128 alg) va_s0 /\ va_get_ok va_s0 /\
(sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b out_b /\
Vale.X64.Decls.buffers_disjoint128 hkeys_b out_b /\ (Vale.X64.Decls.buffers_disjoint128 in_b
out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16
`op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply`
va_get_reg64 rRdx va_s0 < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b)
(Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx
va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\
va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8
va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0)
(va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM ==
va_get_xmm 8 va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b ==
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ (va_get_reg64 rRdx va_s0 > 0 ==>
l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==> FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b)))) /\ va_state_eq va_sM (va_update_flags va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 10 va_sM (va_update_xmm 11 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rR10 va_sM
(va_update_reg64 rR11 va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRbx va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_blocks128 va_b0 va_s0 alg in_b out_b key round_keys keys_b hkeys_b h_LE =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11;
va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm
2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks128 va_mods alg in_b out_b key round_keys keys_b hkeys_b h_LE in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks128 alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 210 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 255 column 53 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 261 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 262 column 45 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0) (va_get_reg64 rRdx
va_s0)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 265 column 93 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM == va_get_xmm 8 va_s0)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b == Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) out_b)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 267 column 131 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRdx va_s0 > 0 ==> l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==>
FStar.Seq.Base.length #Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm
8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2;
va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_blocks128 (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32) (va_s0:va_state)
(va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b out_b /\
Vale.X64.Decls.buffers_disjoint128 hkeys_b out_b /\ (Vale.X64.Decls.buffers_disjoint128 in_b
out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16
`op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply`
va_get_reg64 rRdx va_s0 < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b)
(Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx
va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\
va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8
va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret) /\ (forall (va_x_mem:vale_heap) (va_x_rbx:nat64) (va_x_rdi:nat64) (va_x_r11:nat64)
(va_x_r10:nat64) (va_x_rdx:nat64) (va_x_r12:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32)
(va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32)
(va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm11:quad32) (va_x_xmm10:quad32)
(va_x_heap1:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 11 va_x_xmm11
(va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5
(va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1
(va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64
rR10 va_x_r10 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRbx
va_x_rbx (va_upd_mem va_x_mem va_s0))))))))))))))))))) in va_get_ok va_sM /\
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0)
(va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM ==
va_get_xmm 8 va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b ==
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ (va_get_reg64 rRdx va_s0 > 0 ==>
l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==> FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b)))) ==> va_k va_sM (())))
val va_wpProof_Gcm_blocks128 : alg:algorithm -> in_b:buffer128 -> out_b:buffer128 -> key:(seq
nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> h_LE: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_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b
h_LE va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks128 alg) ([va_Mod_flags;
va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6;
va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0;
va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10; va_Mod_reg64 rR11; va_Mod_reg64 rRdi;
va_Mod_reg64 rRbx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_blocks128 (va_code_Gcm_blocks128 alg) va_s0 alg in_b out_b key
round_keys keys_b hkeys_b h_LE in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 1 va_sM (va_update_xmm 10
va_sM (va_update_xmm 11 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6
va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2
va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR12 va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rRdi va_sM (va_update_reg64 rRbx va_sM (va_update_ok va_sM (va_update_mem
va_sM va_s0))))))))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm
8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2;
va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_blocks128 (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32) : (va_quickCode
unit (va_code_Gcm_blocks128 alg)) =
(va_QProc (va_code_Gcm_blocks128 alg) ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10;
va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm
3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64
rR10; va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_mem])
(va_wp_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE)
(va_wpProof_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE))
//--
//-- Gcm_blocks
#push-options "--z3rlimit 1000"
val va_code_Gcm_blocks : alg:algorithm -> offset:int -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks alg offset =
(va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx))
(va_CCons (va_code_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9) (va_const_opr64
32)) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRsp)
(offset + 0)) (va_CCons (va_code_Gcm_blocks_auth ()) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8)) (va_CCons
(va_code_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp) (offset + 16))
(va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp)
(offset + 24)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13))
(va_CCons (va_code_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64
rR8) 0 Public) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_reg_opr64_reg64 rRbp) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_Load_one_lsb
(va_op_xmm_xmm 10)) (va_CCons (va_code_VPaddd (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)
(va_op_xmm_xmm 10)) (va_CCons (va_code_AES_GCM_decrypt_6mult alg) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11) (va_op_reg_opr64_reg64
rRbp) 32 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx))
(va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp)
(offset + 32)) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRdi)
(va_op_reg_opr64_reg64 rRsp) (offset + 40)) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 48)) (va_CCons
(va_code_Mov64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRdx)) (va_CCons
(va_code_InitPshufbMask (va_op_xmm_xmm 9) (va_op_reg_opr64_reg64 rR12)) (va_CCons
(va_code_Pshufb (va_op_xmm_xmm 11) (va_op_xmm_xmm 9)) (va_CCons (va_code_Gcm_blocks128 alg)
(va_CCons (va_code_Stack_lemma ()) (va_CCons (va_code_Add64 (va_op_dst_opr64_reg64 rR14)
(va_opr_code_Stack (va_op_reg64_reg64 rRsp) (offset + 24) Public)) (va_CCons (va_code_IMul64
(va_op_dst_opr64_reg64 rR14) (va_const_opr64 16)) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rR13) (va_op_reg_opr64_reg64 rRsp) (offset + 64)) (va_CCons (va_IfElse
(va_cmp_gt (va_op_cmp_reg64 rR13) (va_op_cmp_reg64 rR14)) (va_Block (va_CCons
(va_code_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 56))
(va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR13)) (va_CCons
(va_code_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 15)) (va_CCons
(va_code_Gcm_extra_bytes alg) (va_CCons (va_Block (va_CNil ())) (va_CNil ()))))))) (va_Block
(va_CNil ()))) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15))
(va_CCons (va_code_Gcm_make_length_quad ()) (va_CCons (va_code_Ghash_register ()) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRbp) 0 Secret) (va_CCons (va_code_Gctr_register alg) (va_CCons (va_Block (va_CNil ()))
(va_CNil ()))))))))))))))))))))))))))))))))))))
val va_codegen_success_Gcm_blocks : alg:algorithm -> offset:int -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks alg offset =
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx))
(va_pbool_and (va_codegen_success_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9)
(va_const_opr64 32)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64
rRbx) (va_op_reg_opr64_reg64 rRsp) (offset + 0)) (va_pbool_and
(va_codegen_success_Gcm_blocks_auth ()) (va_pbool_and (va_codegen_success_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8)) (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp)
(offset + 16)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRdx)
(va_op_reg_opr64_reg64 rRsp) (offset + 24)) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13)) (va_pbool_and (va_codegen_success_Mov128
(va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_Load128_buffer
(va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rR8) 0 Public)
(va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_reg_opr64_reg64 rRbp) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and
(va_codegen_success_Load_one_lsb (va_op_xmm_xmm 10)) (va_pbool_and (va_codegen_success_VPaddd
(va_op_xmm_xmm 1) (va_op_xmm_xmm 1) (va_op_xmm_xmm 10)) (va_pbool_and
(va_codegen_success_AES_GCM_decrypt_6mult alg) (va_pbool_and (va_codegen_success_Load128_buffer
(va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11) (va_op_reg_opr64_reg64 rRbp) 32 Secret)
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx))
(va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRax)
(va_op_reg_opr64_reg64 rRsp) (offset + 32)) (va_pbool_and (va_codegen_success_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 40)) (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp)
(offset + 48)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR14)
(va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_InitPshufbMask (va_op_xmm_xmm 9)
(va_op_reg_opr64_reg64 rR12)) (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 11)
(va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_Gcm_blocks128 alg) (va_pbool_and
(va_codegen_success_Stack_lemma ()) (va_pbool_and (va_codegen_success_Add64
(va_op_dst_opr64_reg64 rR14) (va_opr_code_Stack (va_op_reg64_reg64 rRsp) (offset + 24) Public))
(va_pbool_and (va_codegen_success_IMul64 (va_op_dst_opr64_reg64 rR14) (va_const_opr64 16))
(va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rR13)
(va_op_reg_opr64_reg64 rRsp) (offset + 64)) (va_pbool_and (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp)
(offset + 56)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR10)
(va_op_opr64_reg64 rR13)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rR10)
(va_const_opr64 15)) (va_codegen_success_Gcm_extra_bytes alg)))) (va_pbool_and
(va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15)) (va_pbool_and
(va_codegen_success_Gcm_make_length_quad ()) (va_pbool_and (va_codegen_success_Ghash_register
()) (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRbp) 0 Secret) (va_pbool_and
(va_codegen_success_Gctr_register alg) (va_ttrue ()))))))))))))))))))))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks (va_mods:va_mods_t) (alg:algorithm) (offset:int) (auth_b:buffer128)
(abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128)
(out128_b:buffer128) (inout_b:buffer128) (iv_b:buffer128) (scratch_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit
(va_code_Gcm_blocks alg offset)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 0) (va_get_stack va_s) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 8) (va_get_stack va_s) in let
(out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 16) (va_get_stack va_s) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 24) (va_get_stack va_s) in let
(in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 32) (va_get_stack va_s) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 40) (va_get_stack va_s) in let
(len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset
+ 48) (va_get_stack va_s) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 56) (va_get_stack va_s) in let
(plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s
+ offset + 64) (va_get_stack va_s) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_old_s)) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 463 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 464 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9) (va_const_opr64 32))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 465 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRsp) (offset + 0))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 466 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks_auth auth_b abytes_b hkeys_b h_LE) (fun (va_s:va_state)
(auth_quad_seq:(seq quad32)) -> let (y_0:quad32) = Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 0 0 0 0 in let (y_auth_bytes:quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 473 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 474 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp) (offset + 16))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 475 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 24))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 476 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 477 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (fun (va_s:va_state) _ -> let
(iv_BE:Vale.X64.Decls.quad32) = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2
va_old_s) in let (ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32
iv_BE 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 483 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64
rR8) 0 Public iv_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 485 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_reg_opr64_reg64 rRbp)
(va_op_xmm_xmm 1) 0 Secret scratch_b 0) (fun (va_s:va_state) _ -> let (j0:quad32) = va_get_xmm
1 va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 487 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load_one_lsb (va_op_xmm_xmm 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 489 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_VPaddd (va_op_xmm_xmm 1) (va_op_xmm_xmm 1) (va_op_xmm_xmm 10)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 491 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AES_GCM_decrypt_6mult alg h_LE iv_b in128x6_b out128x6_b scratch_b key round_keys
keys_b hkeys_b) (fun (va_s:va_state) _ -> let (y_cipher128x6:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in let (auth_in:(seq quad32)) =
auth_quad_seq in let (va_arg138:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) =
Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b in let
(va_arg137:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg136:Vale.Def.Types_s.quad32) = y_auth_bytes in let (va_arg135:Vale.Def.Types_s.quad32) =
y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 494 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_ghash_incremental0_append h_LE va_arg135 va_arg136
y_cipher128x6 va_arg137 va_arg138) (let auth_in = FStar.Seq.Base.append #quad32 auth_in
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 498 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11)
(va_op_reg_opr64_reg64 rRbp) 32 Secret scratch_b 2) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 499 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 500 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 32))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 501 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 40))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 502 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 48))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 503 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 504 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_InitPshufbMask (va_op_xmm_xmm 9) (va_op_reg_opr64_reg64 rR12)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 505 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pshufb (va_op_xmm_xmm 11) (va_op_xmm_xmm 9)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 506 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks128 alg in128_b out128_b key round_keys keys_b hkeys_b h_LE) (fun
(va_s:va_state) _ -> let (y_cipher128:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in let (va_arg134:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b in let
(va_arg133:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg132:Vale.Def.Types_s.quad32) = y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 508 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_ghash_incremental0_append h_LE va_arg132 y_cipher128x6
y_cipher128 va_arg133 va_arg134) (let auth_in = FStar.Seq.Base.append #quad32 auth_in
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 512 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Stack_lemma (va_op_reg64_reg64 rRsp) (offset + 24) Public) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 512 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Add64 (va_op_dst_opr64_reg64 rR14) (va_opr_code_Stack (va_op_reg64_reg64 rRsp)
(offset + 24) Public)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 513 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_IMul64 (va_op_dst_opr64_reg64 rR14) (va_const_opr64 16)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 514 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rR13) (va_op_reg_opr64_reg64 rRsp) (offset + 64))
(fun (va_s:va_state) _ -> let (y_inout:Vale.Def.Types_s.quad32) = y_cipher128 in let
(plain_byte_seq:(seq quad32)) = empty_seq_quad32 in let (cipher_byte_seq:(seq quad32)) =
empty_seq_quad32 in let (va_arg131:Vale.Def.Types_s.quad32) = va_get_xmm 11 va_s in let
(va_arg130:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in let
(va_arg129:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = cipher_byte_seq in let
(va_arg128:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = plain_byte_seq in let
(va_arg127:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 519 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.gctr_partial_opaque_init va_arg127 va_arg128 va_arg129 va_arg130
va_arg131) (let (total_bytes:(va_int_at_least 0)) = FStar.Seq.Base.length #quad32 auth_quad_seq
`op_Multiply` 16 + plain_num_bytes in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 523 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_qIf va_mods (Cmp_gt (va_op_cmp_reg64 rR13) (va_op_cmp_reg64 rR14)) (qblock va_mods (fun
(va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 525 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 56))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 526 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR13)) (fun (va_s:va_state) _
-> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 527 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.Poly1305.Math.lemma_poly_bits64 ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 528 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 15)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 532 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes y_0 auth_in
h_LE) (fun (va_s:va_state) _ -> let y_inout = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm
8 va_s) in let (raw_auth_quads:(FStar.Seq.Base.seq quad32)) = FStar.Seq.Base.append #quad32
auth_in (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b) in va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 536 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun a_1906 (s_1907:(FStar.Seq.Base.seq a_1906)) (i_1908:Prims.nat) (j_1909:Prims.nat) -> let
(j_1869:Prims.nat) = j_1909 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1908
j_1869) (Prims.op_LessThanOrEqual j_1869 (FStar.Seq.Base.length #a_1906 s_1907))))
Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 total_bytes)
(fun _ -> let (auth_input_bytes:(FStar.Seq.Base.seq Vale.Def.Types_s.nat8)) =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
raw_auth_quads) 0 total_bytes in let (padded_auth_bytes:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in let auth_in =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes in let plain_byte_seq =
Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b in let cipher_byte_seq =
Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b in va_QEmpty ((auth_in,
cipher_byte_seq, plain_byte_seq, y_inout)))))))))) (qblock va_mods (fun (va_s:va_state) ->
va_QEmpty ((auth_in, cipher_byte_seq, plain_byte_seq, y_inout))))) (fun (va_s:va_state) va_g ->
let ((auth_in:(seq quad32)), (cipher_byte_seq:(seq quad32)), (plain_byte_seq:(seq quad32)),
(y_inout:Vale.Def.Types_s.quad32)) = va_g in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 547 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 548 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_make_length_quad ()) (fun (va_s:va_state) _ -> let
(length_quad32:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 0
va_s) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 551 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_register hkeys_b h_LE y_inout) (fun (va_s:va_state) _ -> let
(y_final:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s)
in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 554 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRbp) 0 Secret scratch_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 557 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gctr_register alg key round_keys keys_b) (fun (va_s:va_state) _ -> let
(va_arg126:Vale.Def.Types_s.quad32) = va_get_xmm 8 va_s in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 560 column 40 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.Arch.Types.le_seq_quad32_to_bytes_of_singleton va_arg126)
(va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 561 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun (icb_BE_677:Vale.Def.Types_s.quad32) (plain_LE_678:Vale.Def.Types_s.quad32)
(alg_679:Vale.AES.AES_common_s.algorithm) (key_680:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32))
(i_681:Prims.int) -> Vale.AES.AES_s.is_aes_key_LE alg_679 key_680) j0 y_final alg key 0) (fun _
-> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 561 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 8 va_s == Vale.AES.GCTR_s.gctr_encrypt_block j0 y_final alg key 0) (let
(plain128:(FStar.Seq.Base.seq Vale.X64.Decls.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in let
(cipher128:(FStar.Seq.Base.seq Vale.X64.Decls.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) in128_b) in va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 566 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.length #quad32 plain_byte_seq == 0 ==> FStar.Seq.Base.equal
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 plain128 plain_byte_seq)
plain128) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 567 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.length #quad32 cipher_byte_seq == 0 ==> FStar.Seq.Base.equal
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 cipher128 cipher_byte_seq)
cipher128) (let (va_arg125:Vale.Def.Types_s.quad32) = Vale.AES.GCTR.inc32lite ctr_BE_2 len128x6
in let (va_arg124:Vale.Def.Types_s.quad32) = ctr_BE_2 in let (va_arg123:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) = key in let (va_arg122:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32))
= Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b in let
(va_arg121:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) in128_b in let (va_arg120:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) out128x6_b in let
(va_arg119:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_old_s) in128x6_b in let (va_arg118:Prims.nat) = len128 in let
(va_arg117:Prims.nat) = len128x6 in let (va_arg116:Vale.AES.AES_common_s.algorithm) = alg in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 569 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.lemma_gctr_partial_append va_arg116 va_arg117 va_arg118
va_arg119 va_arg120 va_arg121 va_arg122 va_arg123 va_arg124 va_arg125) (let
(va_arg115:Vale.Def.Types_s.quad32) = Vale.AES.GCTR.inc32lite (Vale.AES.GCTR.inc32lite ctr_BE_2
len128x6) len128 in let (va_arg114:Vale.Def.Types_s.quad32) = ctr_BE_2 in let
(va_arg113:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in let
(va_arg112:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = cipher_byte_seq in let
(va_arg111:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = plain_byte_seq in let
(va_arg110:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b) in let
(va_arg109:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in let (va_arg108:Prims.nat) =
FStar.Seq.Base.length #quad32 plain_byte_seq in let (va_arg107:Prims.nat) = len128x6 + len128
in let (va_arg106:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 575 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.lemma_gctr_partial_append va_arg106 va_arg107 va_arg108
va_arg109 va_arg110 va_arg111 va_arg112 va_arg113 va_arg114 va_arg115) (let
(va_arg105:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg104:Vale.Def.Types_s.quad32) = y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 583 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_hash_append2 h_LE va_arg104 y_inout y_final va_arg105
length_quad32) (let auth_in = FStar.Seq.Base.append #quad32 auth_in (FStar.Seq.Base.create
#Vale.Def.Types_s.quad32 1 length_quad32) in let (va_arg103:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = auth_in in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 585 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.ghash_incremental_to_ghash h_LE va_arg103) (va_QEmpty
(()))))))))))))))))))))))))))))))))))))))))))))))))
val va_lemma_Gcm_blocks : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> offset:int ->
auth_b:buffer128 -> abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 ->
in128_b:buffer128 -> out128_b:buffer128 -> inout_b:buffer128 -> iv_b:buffer128 ->
scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks alg offset) va_s0 /\ va_get_ok va_s0 /\
(let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in sse_enabled /\ movbe_enabled /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp
va_s0 + offset + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet
1 va_s0) (va_get_reg64 rRdi va_s0) auth_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2
va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6
va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) in128_ptr in128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1
va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) inout_ptr inout_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0) hkeys_b 8
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet
1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b
(va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer128
scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) /\
Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32
/\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let
(ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in let
(plain_in:(seq quad32)) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) then FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) else FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in let (cipher_out:(seq quad32)) = (if (plain_num_bytes
> (len128x6 + len128) `op_Multiply` 128 `op_Division` 8) then FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) else
FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM)
out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b)) in let
(cipher_bound:nat) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128 `op_Division`
8) then (len128x6 + len128 + 1) else (len128x6 + len128)) in Vale.AES.GCTR.gctr_partial alg
cipher_bound plain_in cipher_out key ctr_BE_2 /\ (let (length_quad:quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) (8
`op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply` plain_num_bytes) 0) in let
(raw_auth_quads:(seq quad32)) = (if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) then FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b) else Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0)
auth_b) in let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64 rRsi va_s0) in let
(padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in let
(auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes in let
(raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 (FStar.Seq.Base.append #quad32
auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in let (total_bytes:nat) =
FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 + plain_num_bytes in let
(raw_quad_seq:(seq quad32)) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) then (let (ab:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32 raw_quad_seq
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let (pb:(seq
nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32 pb) else
raw_quad_seq) in let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 raw_quad_seq
(FStar.Seq.Base.create #quad32 1 length_quad) in va_get_xmm 8 va_sM ==
Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE h_LE auth_quad_seq) alg
key 0))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM
(va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm
13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm
9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM
(va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM
(va_update_reg64 rRbp va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0)))))))))))))))))))))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_blocks va_b0 va_s0 alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5;
va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14;
va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12;
va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp;
va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx;
va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks va_mods alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks alg offset) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 283 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
let (h_LE:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.X64.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 0 va_s0)) in label va_range1
"***** POSTCONDITION NOT MET AT line 396 column 56 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 397 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 398 column 57 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 399 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 400 column 58 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet
6 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 403 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(plain_num_bytes < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 404 column 38 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRsi va_s0 < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 406 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 408 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (ctr_BE_1:quad32) = iv_BE in label va_range1
"***** POSTCONDITION NOT MET AT line 409 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in label va_range1
"***** POSTCONDITION NOT MET AT line 412 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (plain_in:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in label va_range1
"***** POSTCONDITION NOT MET AT line 421 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (cipher_out:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_sM) out128_b)) in label va_range1
"***** POSTCONDITION NOT MET AT line 430 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (cipher_bound:nat) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> len128x6 + len128 + 1) (fun _ -> len128x6 + len128) in label
va_range1
"***** POSTCONDITION NOT MET AT line 434 column 77 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg cipher_bound plain_in cipher_out key ctr_BE_2) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 438 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (length_quad:quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 0 0 0 0) (8 `op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply`
plain_num_bytes) 0) in label va_range1
"***** POSTCONDITION NOT MET AT line 440 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_auth_quads:(seq quad32)) = va_if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b)) (fun _ -> Vale.X64.Decls.s128 (va_get_mem_heaplet 1
va_s0) auth_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 444 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64 rRsi va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 445 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in label
va_range1
"***** POSTCONDITION NOT MET AT line 446 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes
in label va_range1
"***** POSTCONDITION NOT MET AT line 448 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 (FStar.Seq.Base.append #quad32
auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 452 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (total_bytes:nat) = FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 +
plain_num_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 453 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_quad_seq:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply`
128 `op_Division` 8) (fun _ -> let (ab:(seq nat8)) = FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32
raw_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let
(pb:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32
pb) (fun _ -> raw_quad_seq) in label va_range1
"***** POSTCONDITION NOT MET AT line 460 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 raw_quad_seq
(FStar.Seq.Base.create #quad32 1 length_quad) in label va_range1
"***** POSTCONDITION NOT MET AT line 461 column 106 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 8 va_sM == Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE
h_LE auth_quad_seq) alg key 0)))))))))))))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_blocks (alg:algorithm) (offset:int) (auth_b:buffer128) (abytes_b:buffer128)
(in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128) (out128_b:buffer128)
(inout_b:buffer128) (iv_b:buffer128) (scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
let (h_LE:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.X64.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 0 va_s0)) in sse_enabled /\
movbe_enabled /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0)
(va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet
1 va_s0) (va_get_reg64 rRdi va_s0) auth_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2
va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6
va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) in128_ptr in128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1
va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) inout_ptr inout_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0) hkeys_b 8
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)))) /\ (forall (va_x_mem:vale_heap)
(va_x_rax:nat64) (va_x_rbx:nat64) (va_x_rcx:nat64) (va_x_rdx:nat64) (va_x_rdi:nat64)
(va_x_rsi:nat64) (va_x_rbp:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64)
(va_x_r11:nat64) (va_x_r12:nat64) (va_x_r13:nat64) (va_x_r14:nat64) (va_x_r15:nat64)
(va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32)
(va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm9:quad32)
(va_x_xmm10:quad32) (va_x_xmm11:quad32) (va_x_xmm12:quad32) (va_x_xmm13:quad32)
(va_x_xmm14:quad32) (va_x_xmm15:quad32) (va_x_heap1:vale_heap) (va_x_heap2:vale_heap)
(va_x_heap3:vale_heap) (va_x_heap5:vale_heap) (va_x_heap6:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 6
va_x_heap6 (va_upd_mem_heaplet 5 va_x_heap5 (va_upd_mem_heaplet 3 va_x_heap3
(va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 15 va_x_xmm15
(va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12 (va_upd_xmm 11
va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (va_upd_xmm 8 va_x_xmm8
(va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4
(va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0
(va_upd_reg64 rR15 va_x_r15 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13
(va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10
(va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRbp va_x_rbp (va_upd_reg64
rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRcx
va_x_rcx (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem
va_s0))))))))))))))))))))))))))))))))))))) in va_get_ok va_sM /\ (let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet
1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b
(va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer128
scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) /\
Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32
/\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let
(ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in let
(plain_in:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in let (cipher_out:(seq quad32)) = va_if
(plain_num_bytes > (len128x6 + len128) `op_Multiply` 128 `op_Division` 8) (fun _ ->
FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_sM) out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM)
inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) in let (cipher_bound:nat) = va_if (plain_num_bytes > (len128x6 + len128)
`op_Multiply` 128 `op_Division` 8) (fun _ -> len128x6 + len128 + 1) (fun _ -> len128x6 +
len128) in Vale.AES.GCTR.gctr_partial alg cipher_bound plain_in cipher_out key ctr_BE_2 /\ (let
(length_quad:quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) (8
`op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply` plain_num_bytes) 0) in let
(raw_auth_quads:(seq quad32)) = va_if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b)) (fun _ -> Vale.X64.Decls.s128 (va_get_mem_heaplet 1
va_s0) auth_b) in let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64
rRsi va_s0) in let (padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits
auth_input_bytes in let (auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32
padded_auth_bytes in let (raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32
(FStar.Seq.Base.append #quad32 auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0)
in128x6_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in let (total_bytes:nat)
= FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 + plain_num_bytes in let
(raw_quad_seq:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> let (ab:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32 raw_quad_seq
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let (pb:(seq
nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32 pb) (fun
_ -> raw_quad_seq) in let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32
raw_quad_seq (FStar.Seq.Base.create #quad32 1 length_quad) in va_get_xmm 8 va_sM ==
Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE h_LE auth_quad_seq) alg
key 0))) ==> va_k va_sM (())))
val va_wpProof_Gcm_blocks : alg:algorithm -> offset:int -> auth_b:buffer128 -> abytes_b:buffer128
-> in128x6_b:buffer128 -> out128x6_b:buffer128 -> in128_b:buffer128 -> out128_b:buffer128 ->
inout_b:buffer128 -> iv_b:buffer128 -> scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq
quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit ->
Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b
in128_b out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks alg offset) ([va_Mod_flags;
va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2;
va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm
11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5;
va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15;
va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10;
va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi;
va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) va_s0
va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b
iv_b scratch_b key round_keys keys_b hkeys_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_blocks (va_code_Gcm_blocks alg offset) va_s0 alg offset auth_b
abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b scratch_b key round_keys keys_b
hkeys_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM
(va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm
13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm
9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM
(va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM
(va_update_reg64 rRbp va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))))))))))))))))))))))))))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Stack.fsti.checked",
"Vale.X64.QuickCodes.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.InsVector.fsti.checked",
"Vale.X64.InsStack.fsti.checked",
"Vale.X64.InsMem.fsti.checked",
"Vale.X64.InsBasic.fsti.checked",
"Vale.X64.InsAes.fsti.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Lib.Meta.fsti.checked",
"Vale.Lib.Basic.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_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",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.X64.GHash.fsti.checked",
"Vale.AES.X64.GF128_Mul.fsti.checked",
"Vale.AES.X64.GCTR.fsti.checked",
"Vale.AES.X64.GCMencryptOpt.fsti.checked",
"Vale.AES.X64.AESopt2.fsti.checked",
"Vale.AES.X64.AESopt.fsti.checked",
"Vale.AES.X64.AESGCM.fsti.checked",
"Vale.AES.X64.AES.fsti.checked",
"Vale.AES.OptPublic.fsti.checked",
"Vale.AES.GHash_s.fst.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_s.fst.checked",
"Vale.AES.GCTR.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"Vale.AES.GCM.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_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.X64.GCMdecryptOpt.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Lib.Basic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"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.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_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": "Vale.Def.Types_s",
"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": "FStar.Seq",
"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.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"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.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_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": "Vale.Def.Types_s",
"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": "FStar.Seq",
"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.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 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": 1000,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
alg: Vale.AES.AES_common_s.algorithm ->
offset: Prims.int ->
auth_b: Vale.X64.Memory.buffer128 ->
abytes_b: Vale.X64.Memory.buffer128 ->
in128x6_b: Vale.X64.Memory.buffer128 ->
out128x6_b: Vale.X64.Memory.buffer128 ->
in128_b: Vale.X64.Memory.buffer128 ->
out128_b: Vale.X64.Memory.buffer128 ->
inout_b: Vale.X64.Memory.buffer128 ->
iv_b: Vale.X64.Memory.buffer128 ->
scratch_b: Vale.X64.Memory.buffer128 ->
key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 ->
round_keys: FStar.Seq.Base.seq Vale.X64.Decls.quad32 ->
keys_b: Vale.X64.Memory.buffer128 ->
hkeys_b: Vale.X64.Memory.buffer128
-> Vale.X64.QuickCode.va_quickCode Prims.unit
(Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_blocks alg offset) | Prims.Tot | [
"total"
] | [] | [
"Vale.AES.AES_common_s.algorithm",
"Prims.int",
"Vale.X64.Memory.buffer128",
"FStar.Seq.Base.seq",
"Vale.X64.Memory.nat32",
"Vale.X64.Decls.quad32",
"Vale.X64.QuickCode.va_QProc",
"Prims.unit",
"Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_blocks",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_Mod_flags",
"Vale.X64.QuickCode.va_Mod_mem_heaplet",
"Vale.X64.QuickCode.va_Mod_xmm",
"Vale.X64.QuickCode.va_Mod_reg64",
"Vale.X64.Machine_s.rR15",
"Vale.X64.Machine_s.rR14",
"Vale.X64.Machine_s.rR13",
"Vale.X64.Machine_s.rR12",
"Vale.X64.Machine_s.rR11",
"Vale.X64.Machine_s.rR10",
"Vale.X64.Machine_s.rR9",
"Vale.X64.Machine_s.rR8",
"Vale.X64.Machine_s.rRbp",
"Vale.X64.Machine_s.rRsi",
"Vale.X64.Machine_s.rRdi",
"Vale.X64.Machine_s.rRdx",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.Machine_s.rRax",
"Vale.X64.QuickCode.va_Mod_mem",
"Prims.Nil",
"Vale.AES.X64.GCMdecryptOpt.va_wp_Gcm_blocks",
"Vale.AES.X64.GCMdecryptOpt.va_wpProof_Gcm_blocks",
"Vale.X64.QuickCode.va_quickCode"
] | [] | false | false | false | false | false | let va_quick_Gcm_blocks
(alg: algorithm)
(offset: int)
(auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b scratch_b: buffer128)
(key: (seq nat32))
(round_keys: (seq quad32))
(keys_b hkeys_b: buffer128)
: (va_quickCode unit (va_code_Gcm_blocks alg offset)) =
| (va_QProc (va_code_Gcm_blocks alg offset)
([
va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3;
va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12;
va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp;
va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx;
va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem
])
(va_wp_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b
scratch_b key round_keys keys_b hkeys_b)
(va_wpProof_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b
iv_b scratch_b key round_keys keys_b hkeys_b)) | false |
Vale.X64.Instructions_s.fsti | Vale.X64.Instructions_s.eval_Pinsrd | val eval_Pinsrd (index: nat8) (dst: quad32) (src: nat64) : option quad32 | val eval_Pinsrd (index: nat8) (dst: quad32) (src: nat64) : option quad32 | let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4))) | {
"file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 68,
"end_line": 268,
"start_col": 0,
"start_line": 267
} | module Vale.X64.Instructions_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.CPU_Features_s
open Vale.X64.CryptoInstructions_s
open FStar.Seq.Base
let eval_Mov64 (src:nat64) : option nat64 = Some src
val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64
let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None
val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64
let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst)
val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64
let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst)
val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64
let eval_Add64 (dst src:nat64) : option (bool & nat64) =
let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64)
val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64
let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64)
val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64
let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_carry then 1 else 0) in
Some (sum >= pow2_64, sum % pow2_64)
val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64
let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_flag then 1 else 0) in
if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None
val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
let eval_Sub64 (dst src:nat64) : option (bool & nat64) =
let diff = dst - src in Some (diff < 0, diff % pow2_64)
val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64
let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let diff = dst - (src + (if old_carry then 1 else 0)) in
Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags)
val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64
let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) =
Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src)
val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64
let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) =
let hi = FStar.UInt.mul_div #64 rdx src in
let lo = FStar.UInt.mul_mod #64 rdx src in
if bmi2_enabled then Some (hi, lo) else None
val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64
let eval_IMul64 (dst src:nat64) : option nat64 =
Some (FStar.UInt.mul_mod #64 dst src)
val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64
let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src)
val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64
let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) =
Some (Vale.Def.Types_s.ixor dst src, (false, false))
val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64
let eval_Shr64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None
val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64
let eval_Shl64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None
val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64
let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) =
Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx)))
val ins_Cpuid :
instr_dep
[inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)]
[] PreserveFlags eval_Cpuid
// The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled.
// We underspecify XGETBV here to only support fetching XCR0, which
// is supported on any processor supporting the XGETBV instruction
let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) =
if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None
val ins_Xgetbv :
instr_dep
[out (one64Reg rRax); out (one64Reg rRdx)]
[one64Reg rRcx] PreserveFlags eval_Xgetbv
let check_avx (#a:Type0) (x:option a) : option a =
if avx_enabled then x else None
let check_sse2 (#a:Type0) (x:option a) : option a =
if sse2_enabled then x else None
let check_ssse3 (#a:Type0) (x:option a) : option a =
if ssse3_enabled then x else None
let check_sse4_1 (#a:Type0) (x:option a) : option a =
if sse4_1_enabled then x else None
let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src)
val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu
let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src))
val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor
let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2))
val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor
let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src))
val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand
let eval_Paddd_raw (src1 src2:quad32) : option quad32 =
Some (Mkfour
((src1.lo0 + src2.lo0) % pow2_32)
((src1.lo1 + src2.lo1) % pow2_32)
((src1.hi2 + src2.hi2) % pow2_32)
((src1.hi3 + src2.hi3) % pow2_32))
let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2)
val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd
let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2)
val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd
let eval_Pslld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None)
val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt)
let eval_Psrld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None)
val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt)
let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 (
if 0 <= amt && amt < 16 then
let src_bytes = le_quad32_to_bytes dst in
let zero_pad = Seq.create amt 0 in
let remaining_bytes = slice src_bytes amt (length src_bytes) in
Some (le_bytes_to_quad32 (append zero_pad remaining_bytes))
else None)
val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt)
let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if amount = 4 then
Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0)
else if amount = 8 then
Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1)
else None
let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_ssse3 (eval_Palignr_raw amount src1 src2)
val ins_Palignr (amount:nat8) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount)
let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_avx (eval_Palignr_raw amount src1 src2)
val ins_VPalignr (amount:nat8) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount)
let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 =
if 0 <= permutation && permutation < 4 then
Some (Mkfour
(if permutation % 2 = 0 then src1.lo0 else src1.hi2)
(if permutation % 2 = 0 then src1.lo1 else src1.hi3)
(if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2)
(if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3))
else None
let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_sse2 (eval_Shufpd_raw permutation src1 src2)
val ins_Shufpd (permutation:int) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation)
let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Shufpd_raw permutation src1 src2)
val ins_VShufpd (permutation:int) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation)
let is_full_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x04050607 &&
q.hi3 = 0x00010203
let is_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x00010203 &&
q.lo1 = 0x04050607 &&
q.hi2 = 0x08090A0B &&
q.hi3 = 0x0C0D0E0F
let is_high_dup_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let is_lower_upper_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x04050607 &&
q.lo1 = 0x00010203 &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let eval_Pshufb_raw (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if is_full_byte_reversal_mask src2 then
Some (reverse_bytes_quad32 src1)
else if is_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3))
else if is_high_dup_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else if is_lower_upper_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else None
let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2)
val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb
let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2)
val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb
let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 (
let bits:bits_of_byte = byte_to_twobits permutation in
Some (Mkfour
(select_word src bits.lo0)
(select_word src bits.lo1)
(select_word src bits.hi2)
(select_word src bits.hi3)))
val ins_Pshufd (permutation:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation)
let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 (
let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in
Some (Mkfour
(eq_result (src.lo0 = dst.lo0))
(eq_result (src.lo1 = dst.lo1))
(eq_result (src.hi2 = dst.hi2))
(eq_result (src.hi3 = dst.hi3))))
val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd
let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 (
let src_two = four_to_two_two src in
Some (two_to_nat 32 (two_select src_two (index % 2))))
val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instructions_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | index: Vale.Def.Types_s.nat8 -> dst: Vale.X64.Machine_s.quad32 -> src: Vale.X64.Machine_s.nat64
-> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32 | Prims.Tot | [
"total"
] | [] | [
"Vale.Def.Types_s.nat8",
"Vale.X64.Machine_s.quad32",
"Vale.X64.Machine_s.nat64",
"Vale.X64.Instructions_s.check_sse4_1",
"FStar.Pervasives.Native.Some",
"Vale.Def.Types_s.insert_nat32",
"Prims.op_Modulus",
"Vale.X64.Machine_s.pow2_32",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | true | false | let eval_Pinsrd (index: nat8) (dst: quad32) (src: nat64) : option quad32 =
| check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4))) | false |
Vale.X64.Instructions_s.fsti | Vale.X64.Instructions_s.eval_Pcmpeqd | val eval_Pcmpeqd (dst src: quad32) : option quad32 | val eval_Pcmpeqd (dst src: quad32) : option quad32 | let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 (
let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in
Some (Mkfour
(eq_result (src.lo0 = dst.lo0))
(eq_result (src.lo1 = dst.lo1))
(eq_result (src.hi2 = dst.hi2))
(eq_result (src.hi3 = dst.hi3)))) | {
"file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 37,
"end_line": 259,
"start_col": 0,
"start_line": 253
} | module Vale.X64.Instructions_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.CPU_Features_s
open Vale.X64.CryptoInstructions_s
open FStar.Seq.Base
let eval_Mov64 (src:nat64) : option nat64 = Some src
val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64
let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None
val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64
let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst)
val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64
let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst)
val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64
let eval_Add64 (dst src:nat64) : option (bool & nat64) =
let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64)
val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64
let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64)
val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64
let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_carry then 1 else 0) in
Some (sum >= pow2_64, sum % pow2_64)
val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64
let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_flag then 1 else 0) in
if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None
val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
let eval_Sub64 (dst src:nat64) : option (bool & nat64) =
let diff = dst - src in Some (diff < 0, diff % pow2_64)
val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64
let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let diff = dst - (src + (if old_carry then 1 else 0)) in
Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags)
val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64
let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) =
Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src)
val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64
let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) =
let hi = FStar.UInt.mul_div #64 rdx src in
let lo = FStar.UInt.mul_mod #64 rdx src in
if bmi2_enabled then Some (hi, lo) else None
val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64
let eval_IMul64 (dst src:nat64) : option nat64 =
Some (FStar.UInt.mul_mod #64 dst src)
val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64
let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src)
val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64
let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) =
Some (Vale.Def.Types_s.ixor dst src, (false, false))
val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64
let eval_Shr64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None
val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64
let eval_Shl64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None
val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64
let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) =
Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx)))
val ins_Cpuid :
instr_dep
[inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)]
[] PreserveFlags eval_Cpuid
// The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled.
// We underspecify XGETBV here to only support fetching XCR0, which
// is supported on any processor supporting the XGETBV instruction
let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) =
if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None
val ins_Xgetbv :
instr_dep
[out (one64Reg rRax); out (one64Reg rRdx)]
[one64Reg rRcx] PreserveFlags eval_Xgetbv
let check_avx (#a:Type0) (x:option a) : option a =
if avx_enabled then x else None
let check_sse2 (#a:Type0) (x:option a) : option a =
if sse2_enabled then x else None
let check_ssse3 (#a:Type0) (x:option a) : option a =
if ssse3_enabled then x else None
let check_sse4_1 (#a:Type0) (x:option a) : option a =
if sse4_1_enabled then x else None
let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src)
val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu
let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src))
val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor
let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2))
val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor
let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src))
val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand
let eval_Paddd_raw (src1 src2:quad32) : option quad32 =
Some (Mkfour
((src1.lo0 + src2.lo0) % pow2_32)
((src1.lo1 + src2.lo1) % pow2_32)
((src1.hi2 + src2.hi2) % pow2_32)
((src1.hi3 + src2.hi3) % pow2_32))
let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2)
val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd
let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2)
val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd
let eval_Pslld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None)
val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt)
let eval_Psrld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None)
val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt)
let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 (
if 0 <= amt && amt < 16 then
let src_bytes = le_quad32_to_bytes dst in
let zero_pad = Seq.create amt 0 in
let remaining_bytes = slice src_bytes amt (length src_bytes) in
Some (le_bytes_to_quad32 (append zero_pad remaining_bytes))
else None)
val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt)
let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if amount = 4 then
Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0)
else if amount = 8 then
Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1)
else None
let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_ssse3 (eval_Palignr_raw amount src1 src2)
val ins_Palignr (amount:nat8) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount)
let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_avx (eval_Palignr_raw amount src1 src2)
val ins_VPalignr (amount:nat8) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount)
let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 =
if 0 <= permutation && permutation < 4 then
Some (Mkfour
(if permutation % 2 = 0 then src1.lo0 else src1.hi2)
(if permutation % 2 = 0 then src1.lo1 else src1.hi3)
(if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2)
(if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3))
else None
let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_sse2 (eval_Shufpd_raw permutation src1 src2)
val ins_Shufpd (permutation:int) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation)
let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Shufpd_raw permutation src1 src2)
val ins_VShufpd (permutation:int) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation)
let is_full_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x04050607 &&
q.hi3 = 0x00010203
let is_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x00010203 &&
q.lo1 = 0x04050607 &&
q.hi2 = 0x08090A0B &&
q.hi3 = 0x0C0D0E0F
let is_high_dup_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let is_lower_upper_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x04050607 &&
q.lo1 = 0x00010203 &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let eval_Pshufb_raw (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if is_full_byte_reversal_mask src2 then
Some (reverse_bytes_quad32 src1)
else if is_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3))
else if is_high_dup_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else if is_lower_upper_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else None
let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2)
val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb
let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2)
val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb
let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 (
let bits:bits_of_byte = byte_to_twobits permutation in
Some (Mkfour
(select_word src bits.lo0)
(select_word src bits.lo1)
(select_word src bits.hi2)
(select_word src bits.hi3)))
val ins_Pshufd (permutation:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instructions_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | dst: Vale.X64.Machine_s.quad32 -> src: Vale.X64.Machine_s.quad32
-> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32 | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Machine_s.quad32",
"Vale.X64.Instructions_s.check_sse2",
"FStar.Pervasives.Native.Some",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Prims.op_Equality",
"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.bool",
"Vale.Def.Words_s.nat32",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | true | false | let eval_Pcmpeqd (dst src: quad32) : option quad32 =
| check_sse2 (let eq_result (b: bool) : nat32 = if b then 0xFFFFFFFF else 0 in
Some
(Mkfour (eq_result (src.lo0 = dst.lo0))
(eq_result (src.lo1 = dst.lo1))
(eq_result (src.hi2 = dst.hi2))
(eq_result (src.hi3 = dst.hi3)))) | false |
Vale.X64.Instructions_s.fsti | Vale.X64.Instructions_s.eval_Pextrq | val eval_Pextrq (index: nat8) (src: quad32) : option nat64 | val eval_Pextrq (index: nat8) (src: quad32) : option nat64 | let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 (
let src_two = four_to_two_two src in
Some (two_to_nat 32 (two_select src_two (index % 2)))) | {
"file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 56,
"end_line": 264,
"start_col": 0,
"start_line": 262
} | module Vale.X64.Instructions_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.CPU_Features_s
open Vale.X64.CryptoInstructions_s
open FStar.Seq.Base
let eval_Mov64 (src:nat64) : option nat64 = Some src
val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64
let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None
val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64
let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst)
val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64
let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst)
val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64
let eval_Add64 (dst src:nat64) : option (bool & nat64) =
let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64)
val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64
let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64)
val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64
let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_carry then 1 else 0) in
Some (sum >= pow2_64, sum % pow2_64)
val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64
let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_flag then 1 else 0) in
if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None
val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
let eval_Sub64 (dst src:nat64) : option (bool & nat64) =
let diff = dst - src in Some (diff < 0, diff % pow2_64)
val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64
let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let diff = dst - (src + (if old_carry then 1 else 0)) in
Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags)
val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64
let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) =
Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src)
val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64
let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) =
let hi = FStar.UInt.mul_div #64 rdx src in
let lo = FStar.UInt.mul_mod #64 rdx src in
if bmi2_enabled then Some (hi, lo) else None
val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64
let eval_IMul64 (dst src:nat64) : option nat64 =
Some (FStar.UInt.mul_mod #64 dst src)
val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64
let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src)
val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64
let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) =
Some (Vale.Def.Types_s.ixor dst src, (false, false))
val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64
let eval_Shr64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None
val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64
let eval_Shl64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None
val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64
let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) =
Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx)))
val ins_Cpuid :
instr_dep
[inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)]
[] PreserveFlags eval_Cpuid
// The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled.
// We underspecify XGETBV here to only support fetching XCR0, which
// is supported on any processor supporting the XGETBV instruction
let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) =
if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None
val ins_Xgetbv :
instr_dep
[out (one64Reg rRax); out (one64Reg rRdx)]
[one64Reg rRcx] PreserveFlags eval_Xgetbv
let check_avx (#a:Type0) (x:option a) : option a =
if avx_enabled then x else None
let check_sse2 (#a:Type0) (x:option a) : option a =
if sse2_enabled then x else None
let check_ssse3 (#a:Type0) (x:option a) : option a =
if ssse3_enabled then x else None
let check_sse4_1 (#a:Type0) (x:option a) : option a =
if sse4_1_enabled then x else None
let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src)
val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu
let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src))
val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor
let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2))
val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor
let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src))
val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand
let eval_Paddd_raw (src1 src2:quad32) : option quad32 =
Some (Mkfour
((src1.lo0 + src2.lo0) % pow2_32)
((src1.lo1 + src2.lo1) % pow2_32)
((src1.hi2 + src2.hi2) % pow2_32)
((src1.hi3 + src2.hi3) % pow2_32))
let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2)
val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd
let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2)
val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd
let eval_Pslld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None)
val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt)
let eval_Psrld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None)
val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt)
let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 (
if 0 <= amt && amt < 16 then
let src_bytes = le_quad32_to_bytes dst in
let zero_pad = Seq.create amt 0 in
let remaining_bytes = slice src_bytes amt (length src_bytes) in
Some (le_bytes_to_quad32 (append zero_pad remaining_bytes))
else None)
val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt)
let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if amount = 4 then
Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0)
else if amount = 8 then
Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1)
else None
let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_ssse3 (eval_Palignr_raw amount src1 src2)
val ins_Palignr (amount:nat8) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount)
let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_avx (eval_Palignr_raw amount src1 src2)
val ins_VPalignr (amount:nat8) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount)
let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 =
if 0 <= permutation && permutation < 4 then
Some (Mkfour
(if permutation % 2 = 0 then src1.lo0 else src1.hi2)
(if permutation % 2 = 0 then src1.lo1 else src1.hi3)
(if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2)
(if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3))
else None
let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_sse2 (eval_Shufpd_raw permutation src1 src2)
val ins_Shufpd (permutation:int) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation)
let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Shufpd_raw permutation src1 src2)
val ins_VShufpd (permutation:int) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation)
let is_full_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x04050607 &&
q.hi3 = 0x00010203
let is_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x00010203 &&
q.lo1 = 0x04050607 &&
q.hi2 = 0x08090A0B &&
q.hi3 = 0x0C0D0E0F
let is_high_dup_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let is_lower_upper_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x04050607 &&
q.lo1 = 0x00010203 &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let eval_Pshufb_raw (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if is_full_byte_reversal_mask src2 then
Some (reverse_bytes_quad32 src1)
else if is_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3))
else if is_high_dup_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else if is_lower_upper_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else None
let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2)
val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb
let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2)
val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb
let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 (
let bits:bits_of_byte = byte_to_twobits permutation in
Some (Mkfour
(select_word src bits.lo0)
(select_word src bits.lo1)
(select_word src bits.hi2)
(select_word src bits.hi3)))
val ins_Pshufd (permutation:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation)
let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 (
let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in
Some (Mkfour
(eq_result (src.lo0 = dst.lo0))
(eq_result (src.lo1 = dst.lo1))
(eq_result (src.hi2 = dst.hi2))
(eq_result (src.hi3 = dst.hi3))))
val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instructions_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | index: Vale.Def.Types_s.nat8 -> src: Vale.X64.Machine_s.quad32
-> FStar.Pervasives.Native.option Vale.X64.Machine_s.nat64 | Prims.Tot | [
"total"
] | [] | [
"Vale.Def.Types_s.nat8",
"Vale.X64.Machine_s.quad32",
"Vale.X64.Instructions_s.check_sse4_1",
"Vale.X64.Machine_s.nat64",
"FStar.Pervasives.Native.Some",
"Vale.Def.Words.Two_s.two_to_nat",
"Vale.Def.Words.Two_s.two_select",
"Vale.Def.Words_s.two",
"Vale.Def.Types_s.nat32",
"Prims.op_Modulus",
"Vale.Def.Words_s.nat32",
"Vale.Def.Words.Four_s.four_to_two_two",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | true | false | let eval_Pextrq (index: nat8) (src: quad32) : option nat64 =
| check_sse4_1 (let src_two = four_to_two_two src in
Some (two_to_nat 32 (two_select src_two (index % 2)))) | false |
Vale.X64.Instructions_s.fsti | Vale.X64.Instructions_s.eval_Pinsrq | val eval_Pinsrq (index: nat8) (dst: quad32) (src: nat64) : option quad32 | val eval_Pinsrq (index: nat8) (dst: quad32) (src: nat64) : option quad32 | let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat64_def dst src (index % 2))) | {
"file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 60,
"end_line": 272,
"start_col": 0,
"start_line": 271
} | module Vale.X64.Instructions_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.CPU_Features_s
open Vale.X64.CryptoInstructions_s
open FStar.Seq.Base
let eval_Mov64 (src:nat64) : option nat64 = Some src
val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64
let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None
val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64
let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst)
val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64
let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst)
val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64
let eval_Add64 (dst src:nat64) : option (bool & nat64) =
let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64)
val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64
let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64)
val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64
let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_carry then 1 else 0) in
Some (sum >= pow2_64, sum % pow2_64)
val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64
let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_flag then 1 else 0) in
if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None
val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
let eval_Sub64 (dst src:nat64) : option (bool & nat64) =
let diff = dst - src in Some (diff < 0, diff % pow2_64)
val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64
let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let diff = dst - (src + (if old_carry then 1 else 0)) in
Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags)
val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64
let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) =
Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src)
val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64
let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) =
let hi = FStar.UInt.mul_div #64 rdx src in
let lo = FStar.UInt.mul_mod #64 rdx src in
if bmi2_enabled then Some (hi, lo) else None
val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64
let eval_IMul64 (dst src:nat64) : option nat64 =
Some (FStar.UInt.mul_mod #64 dst src)
val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64
let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src)
val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64
let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) =
Some (Vale.Def.Types_s.ixor dst src, (false, false))
val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64
let eval_Shr64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None
val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64
let eval_Shl64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None
val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64
let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) =
Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx)))
val ins_Cpuid :
instr_dep
[inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)]
[] PreserveFlags eval_Cpuid
// The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled.
// We underspecify XGETBV here to only support fetching XCR0, which
// is supported on any processor supporting the XGETBV instruction
let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) =
if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None
val ins_Xgetbv :
instr_dep
[out (one64Reg rRax); out (one64Reg rRdx)]
[one64Reg rRcx] PreserveFlags eval_Xgetbv
let check_avx (#a:Type0) (x:option a) : option a =
if avx_enabled then x else None
let check_sse2 (#a:Type0) (x:option a) : option a =
if sse2_enabled then x else None
let check_ssse3 (#a:Type0) (x:option a) : option a =
if ssse3_enabled then x else None
let check_sse4_1 (#a:Type0) (x:option a) : option a =
if sse4_1_enabled then x else None
let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src)
val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu
let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src))
val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor
let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2))
val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor
let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src))
val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand
let eval_Paddd_raw (src1 src2:quad32) : option quad32 =
Some (Mkfour
((src1.lo0 + src2.lo0) % pow2_32)
((src1.lo1 + src2.lo1) % pow2_32)
((src1.hi2 + src2.hi2) % pow2_32)
((src1.hi3 + src2.hi3) % pow2_32))
let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2)
val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd
let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2)
val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd
let eval_Pslld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None)
val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt)
let eval_Psrld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None)
val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt)
let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 (
if 0 <= amt && amt < 16 then
let src_bytes = le_quad32_to_bytes dst in
let zero_pad = Seq.create amt 0 in
let remaining_bytes = slice src_bytes amt (length src_bytes) in
Some (le_bytes_to_quad32 (append zero_pad remaining_bytes))
else None)
val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt)
let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if amount = 4 then
Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0)
else if amount = 8 then
Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1)
else None
let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_ssse3 (eval_Palignr_raw amount src1 src2)
val ins_Palignr (amount:nat8) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount)
let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_avx (eval_Palignr_raw amount src1 src2)
val ins_VPalignr (amount:nat8) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount)
let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 =
if 0 <= permutation && permutation < 4 then
Some (Mkfour
(if permutation % 2 = 0 then src1.lo0 else src1.hi2)
(if permutation % 2 = 0 then src1.lo1 else src1.hi3)
(if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2)
(if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3))
else None
let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_sse2 (eval_Shufpd_raw permutation src1 src2)
val ins_Shufpd (permutation:int) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation)
let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Shufpd_raw permutation src1 src2)
val ins_VShufpd (permutation:int) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation)
let is_full_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x04050607 &&
q.hi3 = 0x00010203
let is_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x00010203 &&
q.lo1 = 0x04050607 &&
q.hi2 = 0x08090A0B &&
q.hi3 = 0x0C0D0E0F
let is_high_dup_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let is_lower_upper_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x04050607 &&
q.lo1 = 0x00010203 &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let eval_Pshufb_raw (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if is_full_byte_reversal_mask src2 then
Some (reverse_bytes_quad32 src1)
else if is_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3))
else if is_high_dup_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else if is_lower_upper_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else None
let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2)
val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb
let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2)
val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb
let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 (
let bits:bits_of_byte = byte_to_twobits permutation in
Some (Mkfour
(select_word src bits.lo0)
(select_word src bits.lo1)
(select_word src bits.hi2)
(select_word src bits.hi3)))
val ins_Pshufd (permutation:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation)
let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 (
let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in
Some (Mkfour
(eq_result (src.lo0 = dst.lo0))
(eq_result (src.lo1 = dst.lo1))
(eq_result (src.hi2 = dst.hi2))
(eq_result (src.hi3 = dst.hi3))))
val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd
let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 (
let src_two = four_to_two_two src in
Some (two_to_nat 32 (two_select src_two (index % 2))))
val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index)
let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4)))
val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instructions_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | index: Vale.Def.Types_s.nat8 -> dst: Vale.X64.Machine_s.quad32 -> src: Vale.X64.Machine_s.nat64
-> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32 | Prims.Tot | [
"total"
] | [] | [
"Vale.Def.Types_s.nat8",
"Vale.X64.Machine_s.quad32",
"Vale.X64.Machine_s.nat64",
"Vale.X64.Instructions_s.check_sse4_1",
"FStar.Pervasives.Native.Some",
"Vale.Def.Types_s.insert_nat64_def",
"Prims.op_Modulus",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | true | false | let eval_Pinsrq (index: nat8) (dst: quad32) (src: nat64) : option quad32 =
| check_sse4_1 (Some (insert_nat64_def dst src (index % 2))) | false |
Hacl.Impl.RSAPSS.fst | Hacl.Impl.RSAPSS.rsapss_verify_ | val rsapss_verify_:
#t:limb_t
-> ke:BE.exp t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_verify_st1 t ke a modBits | val rsapss_verify_:
#t:limb_t
-> ke:BE.exp t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_verify_st1 t ke a modBits | let rsapss_verify_ #t ke a modBits eBits pkey saltLen sgnt msgLen msg =
push_frame ();
[@inline_let] let bits : size_pos = bits t in
let nLen = blocks modBits (size bits) in
let m = create nLen (uint #t 0) in
let b = rsapss_verify_compute_msg ke modBits eBits pkey sgnt m in
let res = if b then rsapss_verify_bn_to_msg a modBits saltLen msgLen msg m else false in
pop_frame ();
res | {
"file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 5,
"end_line": 467,
"start_col": 0,
"start_line": 459
} | module Hacl.Impl.RSAPSS
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
module ST = FStar.HyperStack.ST
module Hash = Spec.Agile.Hash
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
module SD = Hacl.Spec.Bignum.Definitions
module SM = Hacl.Spec.Bignum.Montgomery
module SE = Hacl.Spec.Bignum.Exponentiation
module BN = Hacl.Bignum
module BE = Hacl.Bignum.Exponentiation
module BM = Hacl.Bignum.Montgomery
module S = Spec.RSAPSS
module LS = Hacl.Spec.RSAPSS
module LSeq = Lib.Sequence
module RP = Hacl.Impl.RSAPSS.Padding
module RM = Hacl.Impl.RSAPSS.MGF
module RK = Hacl.Impl.RSAPSS.Keys
#reset-options "--z3rlimit 150 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t}
inline_for_extraction noextract
let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t
-> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)}
-> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t)))
-> m:lbignum t len
-> m':lbignum t len
-> s:lbignum t len ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h skey /\ live h m /\ live h s /\ live h m' /\
disjoint s m /\ disjoint s skey /\ disjoint m skey /\
disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\
LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\
bn_v h m < bn_v h (gsub skey 0ul len))
(ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\
(r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m))
inline_for_extraction noextract
val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits
let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s =
[@inline_let] let bits : size_pos = bits t in
let nLen = blocks modBits (size bits) in
let eLen = blocks eBits (size bits) in
let dLen = blocks dBits (size bits) in
let n = sub skey 0ul nLen in
let r2 = sub skey nLen nLen in
let e = sub skey (nLen +! nLen) eLen in
let d = sub skey (nLen +! nLen +! eLen) dLen in
Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits);
let h0 = ST.get () in
SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n);
BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s;
BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m';
let h1 = ST.get () in
SD.bn_eval_inj (v nLen) (as_seq h1 s)
(SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2)
(as_seq h0 m) (v dBits) (as_seq h0 d));
SD.bn_eval_inj (v nLen) (as_seq h1 m')
(SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2)
(as_seq h1 s) (v eBits) (as_seq h0 e));
let eq_m = BN.bn_eq_mask nLen m m' in
mapT nLen s (logand eq_m) s;
BB.unsafe_bool_of_limb eq_m
inline_for_extraction noextract
let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
saltLen:size_t
-> salt:lbuffer uint8 saltLen
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen
-> m:lbignum t len ->
Stack unit
(requires fun h ->
live h salt /\ live h msg /\ live h m /\
disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\
as_seq h m == LSeq.create (v len) (uint #t 0) /\
LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg))
(ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\
as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg))
inline_for_extraction noextract
val rsapss_sign_msg_to_bn:
#t:limb_t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_sign_msg_to_bn_st t a modBits
let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m =
push_frame ();
[@inline_let] let bits : size_pos = bits t in
[@inline_let] let numb : size_pos = numbytes t in
let nLen = blocks modBits (size bits) in
let emBits = modBits -! 1ul in
let emLen = blocks emBits 8ul in
[@inline_let] let mLen = blocks emLen (size numb) in
let em = create emLen (u8 0) in
RP.pss_encode a saltLen salt msgLen msg emBits em;
LS.blocks_bits_lemma t (v emBits);
LS.blocks_numb_lemma t (v emBits);
assert (SD.blocks (v emBits) bits = v mLen);
assert (numb * v mLen <= max_size_t);
assert (v mLen <= v nLen);
let h' = ST.get () in
update_sub_f h' m 0ul mLen
(fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em))
(fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen));
pop_frame ()
inline_for_extraction noextract
let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t
-> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)}
-> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t)))
-> m:lbignum t len
-> sgnt:lbuffer uint8 (blocks modBits 8ul) ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h sgnt /\ live h skey /\ live h m /\
disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\
LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\
bn_v h m < bn_v h (gsub skey 0ul len))
(ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\
(eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m))
inline_for_extraction noextract
val rsapss_sign_compute_sgnt:
#t:limb_t
-> ke:BE.exp t
-> modBits:modBits_t t ->
rsapss_sign_compute_sgnt_st t ke modBits
let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt =
push_frame ();
let h_init = ST.get () in
[@inline_let] let bits : size_pos = bits t in
[@inline_let] let numb : size_pos = numbytes t in
let nLen = blocks modBits (size bits) in
let k = blocks modBits 8ul in
let s = create nLen (uint #t 0) in
let m' = create nLen (uint #t 0) in
let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in
LS.blocks_bits_lemma t (v modBits);
LS.blocks_numb_lemma t (v modBits);
assert (SD.blocks (v k) numb == v nLen);
assert (numb * v nLen <= max_size_t);
BN.bn_to_bytes_be k s sgnt;
pop_frame ();
eq_b
inline_for_extraction noextract
let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t
-> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)}
-> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t)))
-> saltLen:size_t
-> salt:lbuffer uint8 saltLen
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen
-> sgnt:lbuffer uint8 (blocks modBits 8ul) ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h salt /\ live h msg /\ live h sgnt /\ live h skey /\
disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\
disjoint salt msg /\
LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\
LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg))
(ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\
(eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits)
(as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg))
inline_for_extraction noextract
val rsapss_sign_:
#t:limb_t
-> ke:BE.exp t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_sign_st1 t ke a modBits
let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt =
push_frame ();
[@inline_let] let bits : size_pos = bits t in
let nLen = blocks modBits (size bits) in
let m = create nLen (uint #t 0) in
rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m;
let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in
pop_frame ();
eq_b
inline_for_extraction noextract
let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t
-> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)}
-> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t)))
-> saltLen:size_t
-> salt:lbuffer uint8 saltLen
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen
-> sgnt:lbuffer uint8 (blocks modBits 8ul) ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h salt /\ live h msg /\ live h sgnt /\ live h skey /\
disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\
disjoint salt msg /\
LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey))
(ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\
(b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits)
(as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt))
inline_for_extraction noextract
val rsapss_sign:
#t:limb_t
-> ke:BE.exp t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_sign_st t ke a modBits
let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt =
let hLen = RM.hash_len a in
Math.Lemmas.pow2_lt_compat 61 32;
Math.Lemmas.pow2_lt_compat 125 32;
//assert (max_size_t < Hash.max_input_length a);
let b =
saltLen <=. 0xfffffffful -! hLen -! 8ul &&
saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in
if b then
rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt
else
false
inline_for_extraction noextract
val bn_lt_pow2:
#t:limb_t
-> modBits:size_t{1 < v modBits}
-> m:lbignum t (blocks modBits (size (bits t))) ->
Stack bool
(requires fun h -> live h m)
(ensures fun h0 r h1 -> h0 == h1 /\
r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m))
let bn_lt_pow2 #t modBits m =
if not ((modBits -! 1ul) %. 8ul =. 0ul) then true
else begin
let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in
BB.unsafe_bool_of_limb0 get_bit end
inline_for_extraction noextract
let rsapss_verify_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)}
-> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t)))
-> m_def:lbignum t len
-> s:lbignum t len ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h pkey /\ live h m_def /\ live h s /\
disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\
LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey))
(ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\
(r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s))
inline_for_extraction noextract
val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits
let rsapss_verify_bn #t ke modBits eBits pkey m_def s =
[@inline_let] let bits = size (bits t) in
let nLen = blocks modBits bits in
let eLen = blocks eBits bits in
let n = sub pkey 0ul nLen in
let r2 = sub pkey nLen nLen in
let e = sub pkey (nLen +! nLen) eLen in
let mask = BN.bn_lt_mask nLen s n in
let h = ST.get () in
SB.bn_lt_mask_lemma (as_seq h s) (as_seq h n);
let res =
if BB.unsafe_bool_of_limb mask then begin
Math.Lemmas.pow2_le_compat (v bits * v nLen) (v modBits);
SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h n);
let h0 = ST.get () in
BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m_def;
let h1 = ST.get () in
SD.bn_eval_inj (v nLen) (as_seq h1 m_def)
(SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2)
(as_seq h1 s) (v eBits) (as_seq h0 e));
if bn_lt_pow2 modBits m_def then true
else false end
else false in
res
inline_for_extraction noextract
let rsapss_verify_bn_to_msg_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
saltLen:size_t
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen
-> m:lbignum t (blocks modBits (size (bits t))) ->
Stack bool
(requires fun h ->
live h msg /\ live h m /\ disjoint m msg /\
LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg))
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == LS.rsapss_verify_bn_to_msg a (v modBits) (v saltLen) (v msgLen) (as_seq h0 msg) (as_seq h0 m))
inline_for_extraction noextract
val rsapss_verify_bn_to_msg:
#t:limb_t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_verify_bn_to_msg_st t a modBits
let rsapss_verify_bn_to_msg #t a modBits saltLen msgLen msg m =
push_frame ();
[@inline_let] let bits : size_pos = bits t in
[@inline_let] let numb : size_pos = numbytes t in
let nLen = blocks modBits (size bits) in
let emBits = modBits -! 1ul in
let emLen = blocks emBits 8ul in
[@inline_let] let mLen = blocks emLen (size numb) in
let em = create emLen (u8 0) in
LS.blocks_bits_lemma t (v emBits);
LS.blocks_numb_lemma t (v emBits);
assert (SD.blocks (v emBits) bits == v mLen);
assert (numb * v mLen <= max_size_t);
assert (v mLen <= v nLen);
let m1 = sub m 0ul mLen in
BN.bn_to_bytes_be emLen m1 em;
let res = RP.pss_verify a saltLen msgLen msg emBits em in
pop_frame ();
res
inline_for_extraction noextract
let rsapss_verify_compute_msg_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)}
-> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t)))
-> sgnt:lbuffer uint8 (blocks modBits 8ul)
-> m:lbignum t len ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h sgnt /\ live h pkey /\ live h m /\
disjoint m sgnt /\ disjoint m pkey /\
as_seq h m == LSeq.create (v len) (uint #t 0) /\
LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey))
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(r, as_seq h1 m) == LS.rsapss_verify_compute_msg (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 sgnt))
inline_for_extraction noextract
val rsapss_verify_compute_msg:
#t:limb_t
-> ke:BE.exp t
-> modBits:modBits_t t ->
rsapss_verify_compute_msg_st t ke modBits
let rsapss_verify_compute_msg #t ke modBits eBits pkey sgnt m =
push_frame ();
[@inline_let] let bits : size_pos = bits t in
[@inline_let] let numb : size_pos = numbytes t in
let nLen = blocks modBits (size bits) in
let k = blocks modBits 8ul in
let s = create nLen (uint #t 0) in
LS.blocks_bits_lemma t (v modBits);
LS.blocks_numb_lemma t (v modBits);
assert (SD.blocks (v k) numb == v nLen);
assert (numb * v nLen <= max_size_t);
BN.bn_from_bytes_be k sgnt s;
let b = rsapss_verify_bn #t ke modBits eBits pkey m s in
pop_frame ();
b
inline_for_extraction noextract
let rsapss_verify_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)}
-> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t)))
-> saltLen:size_t
-> sgnt:lbuffer uint8 (blocks modBits 8ul)
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h msg /\ live h sgnt /\ live h pkey /\
disjoint msg sgnt /\ disjoint msg pkey /\
LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey) /\
LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg))
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == LS.rsapss_verify_ a (v modBits) (v eBits) (as_seq h0 pkey)
(v saltLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg))
inline_for_extraction noextract
val rsapss_verify_:
#t:limb_t
-> ke:BE.exp t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_verify_st1 t ke a modBits | {
"checked_file": "/",
"dependencies": [
"Spec.RSAPSS.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.RSAPSS.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Exponentiation.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Impl.RSAPSS.Padding.fst.checked",
"Hacl.Impl.RSAPSS.MGF.fst.checked",
"Hacl.Impl.RSAPSS.Keys.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.RSAPSS.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.RSAPSS.Keys",
"short_module": "RK"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.RSAPSS.MGF",
"short_module": "RM"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.RSAPSS.Padding",
"short_module": "RP"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.RSAPSS",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.RSAPSS",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 150,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
ke: Hacl.Bignum.Exponentiation.exp t ->
a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} ->
modBits: Hacl.Impl.RSAPSS.modBits_t t
-> Hacl.Impl.RSAPSS.rsapss_verify_st1 t ke a modBits | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.Exponentiation.exp",
"Spec.Hash.Definitions.hash_alg",
"Prims.b2t",
"Spec.RSAPSS.hash_is_supported",
"Hacl.Impl.RSAPSS.modBits_t",
"Lib.IntTypes.size_t",
"Hacl.Spec.RSAPSS.pkey_len_pre",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Bignum.Definitions.lbignum",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.op_Star_Bang",
"FStar.UInt32.__uint_to_t",
"Hacl.Bignum.Definitions.blocks",
"Lib.IntTypes.size",
"Lib.IntTypes.bits",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Prims.bool",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"Hacl.Impl.RSAPSS.rsapss_verify_bn_to_msg",
"Hacl.Impl.RSAPSS.rsapss_verify_compute_msg",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.create",
"Lib.IntTypes.uint",
"Lib.IntTypes.SEC",
"Lib.IntTypes.int_t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Prims.l_and",
"Prims.op_GreaterThan",
"Prims.op_LessThanOrEqual",
"Prims.op_Subtraction",
"Prims.pow2",
"Prims.op_Multiply",
"Lib.IntTypes.mk_int",
"Hacl.Spec.Bignum.Definitions.blocks",
"Prims.pos",
"FStar.HyperStack.ST.push_frame"
] | [] | false | false | false | false | false | let rsapss_verify_ #t ke a modBits eBits pkey saltLen sgnt msgLen msg =
| push_frame ();
[@@ inline_let ]let bits:size_pos = bits t in
let nLen = blocks modBits (size bits) in
let m = create nLen (uint #t 0) in
let b = rsapss_verify_compute_msg ke modBits eBits pkey sgnt m in
let res = if b then rsapss_verify_bn_to_msg a modBits saltLen msgLen msg m else false in
pop_frame ();
res | false |
Vale.X64.Instructions_s.fsti | Vale.X64.Instructions_s.eval_AESNI_keygen_assist | val eval_AESNI_keygen_assist (imm: nat8) (src: quad32) : option quad32 | val eval_AESNI_keygen_assist (imm: nat8) (src: quad32) : option quad32 | let eval_AESNI_keygen_assist (imm:nat8) (src:quad32) : option quad32 =
if aesni_enabled then
Some (Mkfour
(Vale.AES.AES_s.sub_word src.lo1)
(ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.lo1)) imm)
(Vale.AES.AES_s.sub_word src.hi3)
(ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.hi3)) imm))
else None | {
"file_name": "vale/specs/hardware/Vale.X64.Instructions_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 353,
"start_col": 0,
"start_line": 346
} | module Vale.X64.Instructions_s
open FStar.Mul
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
open Vale.X64.CPU_Features_s
open Vale.X64.CryptoInstructions_s
open FStar.Seq.Base
let eval_Mov64 (src:nat64) : option nat64 = Some src
val ins_Mov64 : instr_dep [out op64] [op64] PreserveFlags eval_Mov64
let eval_MovBe64 (src:nat64) : option nat64 = if movbe_enabled then Some (reverse_bytes_nat64 src) else None
val ins_MovBe64 : instr_dep [out op64] [op64] PreserveFlags eval_MovBe64
let eval_Bswap64 (dst:nat64) : option nat64 = Some (reverse_bytes_nat64 dst)
val ins_Bswap64 : instr_dep [inOut op64] [] PreserveFlags eval_Bswap64
let eval_Cmovc64 (dst src:nat64) (carry:bool) : option nat64 = Some (if carry then src else dst)
val ins_Cmovc64 : instr_dep [inOut op64] [op64; opFlagsCf] PreserveFlags eval_Cmovc64
let eval_Add64 (dst src:nat64) : option (bool & nat64) =
let sum = dst + src in Some (sum >= pow2_64, sum % pow2_64)
val ins_Add64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Add64
let eval_AddLea64 (src1 src2:nat64) : option nat64 = Some ((src1 + src2) % pow2_64)
val ins_AddLea64 :instr_dep [out op64] [op64; op64] PreserveFlags eval_AddLea64
let eval_AddCarry64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_carry then 1 else 0) in
Some (sum >= pow2_64, sum % pow2_64)
val ins_AddCarry64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_AddCarry64
let eval_Adcx64_Adox64 (old_flag:bool) (dst src:nat64) : option (bool & nat64) =
let sum = dst + src + (if old_flag then 1 else 0) in
if adx_enabled then Some (sum >= pow2_64, sum % pow2_64) else None
val ins_Adcx64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
val ins_Adox64 : instr_dep [inOut opFlagsOf; inOut op64] [op64] PreserveFlags eval_Adcx64_Adox64
let eval_Sub64 (dst src:nat64) : option (bool & nat64) =
let diff = dst - src in Some (diff < 0, diff % pow2_64)
val ins_Sub64 : instr_dep [out opFlagsCf; inOut op64] [op64] HavocFlags eval_Sub64
let eval_Sbb64 (old_carry:bool) (dst src:nat64) : option (bool & nat64) =
let diff = dst - (src + (if old_carry then 1 else 0)) in
Some (diff < 0, diff % pow2_64) // We specify cf, but underspecify everything else (via HavocFlags)
val ins_Sbb64 : instr_dep [inOut opFlagsCf; inOut op64] [op64] HavocFlags eval_Sbb64
let eval_Mul64 (rax src:nat64) : option (nat64 & nat64) =
Some (FStar.UInt.mul_div #64 rax src, FStar.UInt.mul_mod #64 rax src)
val ins_Mul64 : instr_dep [out (one64Reg rRdx); inOut (one64Reg rRax)] [op64] HavocFlags eval_Mul64
let eval_Mulx64 (rdx src:nat64) : option (nat64 & nat64) =
let hi = FStar.UInt.mul_div #64 rdx src in
let lo = FStar.UInt.mul_mod #64 rdx src in
if bmi2_enabled then Some (hi, lo) else None
val ins_Mulx64 : instr_dep [out op64; out op64] [one64Reg rRdx; op64] PreserveFlags eval_Mulx64
let eval_IMul64 (dst src:nat64) : option nat64 =
Some (FStar.UInt.mul_mod #64 dst src)
val ins_IMul64 : instr_dep [inOut op64] [op64] HavocFlags eval_IMul64
let eval_And64 (dst src:nat64) : option nat64 = Some (iand dst src)
val ins_And64 : instr_dep [inOut op64] [op64] HavocFlags eval_And64
let eval_Xor64 (dst src:nat64) : option (nat64 & (bool & bool)) =
Some (Vale.Def.Types_s.ixor dst src, (false, false))
val ins_Xor64 : instr_dep [inOut op64; out opFlagsCf; out opFlagsOf] [op64] HavocFlags eval_Xor64
let eval_Shr64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishr dst amt) else None
val ins_Shr64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shr64
let eval_Shl64 (dst amt:nat64) : option nat64 =
if amt < 64 then Some (Vale.Def.Types_s.ishl dst amt) else None
val ins_Shl64 : instr_dep [inOut op64] [op64] HavocFlags eval_Shl64
let eval_Cpuid (rax rcx:nat64) : option (nat64 & (nat64 & (nat64 & nat64))) =
Some (cpuid rRax rax rcx, (cpuid rRbx rax rcx, (cpuid rRcx rax rcx, cpuid rRdx rax rcx)))
val ins_Cpuid :
instr_dep
[inOut (one64Reg rRax); out (one64Reg rRbx); inOut (one64Reg rRcx); out (one64Reg rRdx)]
[] PreserveFlags eval_Cpuid
// The XGETBV instruction requires that OSXSAVE (in CPUID) is enabled.
// We underspecify XGETBV here to only support fetching XCR0, which
// is supported on any processor supporting the XGETBV instruction
let eval_Xgetbv (rcx:nat64) : option (nat64 & nat64) =
if osxsave_enabled && rcx = 0 then Some (xgetbv rRax rcx, xgetbv rRdx rcx) else None
val ins_Xgetbv :
instr_dep
[out (one64Reg rRax); out (one64Reg rRdx)]
[one64Reg rRcx] PreserveFlags eval_Xgetbv
let check_avx (#a:Type0) (x:option a) : option a =
if avx_enabled then x else None
let check_sse2 (#a:Type0) (x:option a) : option a =
if sse2_enabled then x else None
let check_ssse3 (#a:Type0) (x:option a) : option a =
if ssse3_enabled then x else None
let check_sse4_1 (#a:Type0) (x:option a) : option a =
if sse4_1_enabled then x else None
let eval_Movdqu (src:quad32) : option quad32 = check_sse2 (Some src)
val ins_Movdqu : instr_dep [out opXmm] [opXmm] PreserveFlags eval_Movdqu
let eval_Pxor (dst src:quad32) : option quad32 = check_sse2 (Some (quad32_xor dst src))
val ins_Pxor : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pxor
let eval_VPxor (src1 src2:quad32) : option quad32 = check_avx (Some (quad32_xor src1 src2))
val ins_VPxor : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPxor
let eval_Pand (dst src:quad32) : option quad32 = check_sse2 (Some (four_map2 (fun di si -> iand di si) dst src))
val ins_Pand : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pand
let eval_Paddd_raw (src1 src2:quad32) : option quad32 =
Some (Mkfour
((src1.lo0 + src2.lo0) % pow2_32)
((src1.lo1 + src2.lo1) % pow2_32)
((src1.hi2 + src2.hi2) % pow2_32)
((src1.hi3 + src2.hi3) % pow2_32))
let eval_Paddd (src1 src2:quad32) : option quad32 = check_sse2 (eval_Paddd_raw src1 src2)
val ins_Paddd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Paddd
let eval_VPaddd (src1 src2:quad32) : option quad32 = check_avx (eval_Paddd_raw src1 src2)
val ins_VPaddd : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPaddd
let eval_Pslld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishl i amt) dst) else None)
val ins_Pslld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Pslld amt)
let eval_Psrld (amt:int) (dst:quad32) : option quad32 =
check_sse2 (if 0 <= amt && amt < 32 then Some (four_map (fun i -> ishr i amt) dst) else None)
val ins_Psrld (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrld amt)
let eval_Psrldq (amt:int) (dst:quad32) : option quad32 = check_sse2 (
if 0 <= amt && amt < 16 then
let src_bytes = le_quad32_to_bytes dst in
let zero_pad = Seq.create amt 0 in
let remaining_bytes = slice src_bytes amt (length src_bytes) in
Some (le_bytes_to_quad32 (append zero_pad remaining_bytes))
else None)
val ins_Psrldq (amt:int) : instr_dep [inOut opXmm] [] PreserveFlags (eval_Psrldq amt)
let eval_Palignr_raw (amount:nat8) (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if amount = 4 then
Some (Mkfour src2.lo1 src2.hi2 src2.hi3 src1.lo0)
else if amount = 8 then
Some (Mkfour src2.hi2 src2.hi3 src1.lo0 src1.lo1)
else None
let eval_Palignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_ssse3 (eval_Palignr_raw amount src1 src2)
val ins_Palignr (amount:nat8) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Palignr amount)
let eval_VPalignr (amount:nat8) (src1 src2:quad32) : option quad32 =
check_avx (eval_Palignr_raw amount src1 src2)
val ins_VPalignr (amount:nat8) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPalignr amount)
let eval_Shufpd_raw (permutation:int) (src1 src2:quad32) : option quad32 =
if 0 <= permutation && permutation < 4 then
Some (Mkfour
(if permutation % 2 = 0 then src1.lo0 else src1.hi2)
(if permutation % 2 = 0 then src1.lo1 else src1.hi3)
(if (permutation / 2) % 2 = 0 then src2.lo0 else src2.hi2)
(if (permutation / 2) % 2 = 0 then src2.lo1 else src2.hi3))
else None
let eval_Shufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_sse2 (eval_Shufpd_raw permutation src1 src2)
val ins_Shufpd (permutation:int) :
instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Shufpd permutation)
let eval_VShufpd (permutation:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Shufpd_raw permutation src1 src2)
val ins_VShufpd (permutation:int) :
instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VShufpd permutation)
let is_full_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x04050607 &&
q.hi3 = 0x00010203
let is_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x00010203 &&
q.lo1 = 0x04050607 &&
q.hi2 = 0x08090A0B &&
q.hi3 = 0x0C0D0E0F
let is_high_dup_reversal_mask (q:quad32) : bool =
q.lo0 = 0x0C0D0E0F &&
q.lo1 = 0x08090A0B &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let is_lower_upper_byte_reversal_mask (q:quad32) : bool =
q.lo0 = 0x04050607 &&
q.lo1 = 0x00010203 &&
q.hi2 = 0x0C0D0E0F &&
q.hi3 = 0x08090A0B
let eval_Pshufb_raw (src1 src2:quad32) : option quad32 =
// We only spec a restricted version sufficient for a handful of standard patterns
if is_full_byte_reversal_mask src2 then
Some (reverse_bytes_quad32 src1)
else if is_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3))
else if is_high_dup_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else if is_lower_upper_byte_reversal_mask src2 then
Some (Mkfour
(reverse_bytes_nat32 src1.lo1)
(reverse_bytes_nat32 src1.lo0)
(reverse_bytes_nat32 src1.hi3)
(reverse_bytes_nat32 src1.hi2))
else None
let eval_Pshufb (src1 src2:quad32) : option quad32 = check_ssse3 (eval_Pshufb_raw src1 src2)
val ins_Pshufb : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pshufb
let eval_VPshufb (src1 src2:quad32) : option quad32 = check_avx (eval_Pshufb_raw src1 src2)
val ins_VPshufb : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VPshufb
let eval_Pshufd (permutation:nat8) (src:quad32) : option quad32 = check_sse2 (
let bits:bits_of_byte = byte_to_twobits permutation in
Some (Mkfour
(select_word src bits.lo0)
(select_word src bits.lo1)
(select_word src bits.hi2)
(select_word src bits.hi3)))
val ins_Pshufd (permutation:nat8) :
instr_dep [out opXmm] [opXmm] PreserveFlags (eval_Pshufd permutation)
let eval_Pcmpeqd (dst src:quad32) : option quad32 = check_sse2 (
let eq_result (b:bool):nat32 = if b then 0xFFFFFFFF else 0 in
Some (Mkfour
(eq_result (src.lo0 = dst.lo0))
(eq_result (src.lo1 = dst.lo1))
(eq_result (src.hi2 = dst.hi2))
(eq_result (src.hi3 = dst.hi3))))
val ins_Pcmpeqd : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_Pcmpeqd
let eval_Pextrq (index:nat8) (src:quad32) : option nat64 = check_sse4_1 (
let src_two = four_to_two_two src in
Some (two_to_nat 32 (two_select src_two (index % 2))))
val ins_Pextrq (index:nat8) : instr_dep [out op64] [opXmm] PreserveFlags (eval_Pextrq index)
let eval_Pinsrd (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat32 dst (src % pow2_32) (index % 4)))
val ins_Pinsrd (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrd index)
let eval_Pinsrq (index:nat8) (dst:quad32) (src:nat64) : option quad32 =
check_sse4_1 (Some (insert_nat64_def dst src (index % 2)))
val ins_Pinsrq (index:nat8) : instr_dep [inOut opXmm] [op64] PreserveFlags (eval_Pinsrq index)
let eval_Pslldq_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the two very special cases we need
if count = 4 then Some (Mkfour 0 src.lo0 src.lo1 src.hi2)
else if count = 8 then Some (Mkfour 0 0 src.lo0 src.lo1)
else None
let eval_VPslldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Pslldq_raw count src)
val ins_VPslldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPslldq count)
let eval_Psrldq_8_raw (count:nat8) (src:quad32) : option quad32 =
// We only spec the one very special case we need
if count = 8 then Some (Mkfour src.hi2 src.hi3 0 0)
else None
let eval_VPsrldq (count:nat8) (src:quad32) : option quad32 = check_avx (eval_Psrldq_8_raw count src)
val ins_VPsrldq (count:nat8) : instr_dep [out opXmm] [opXmm] PreserveFlags (eval_VPsrldq count)
let eval_Pclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
let Mkfour a0 a1 a2 a3 = src1 in
let Mkfour b0 b1 b2 b3 = src2 in
let f x0 x1 y0 y1 =
let x = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo x0 x1) in
let y = Vale.Math.Poly2.Bits_s.of_double32 (Mktwo y0 y1) in
Vale.Math.Poly2.Bits_s.to_quad32 (Vale.Math.Poly2_s.mul x y)
in
if pclmulqdq_enabled then
match imm with
| 0 -> Some (f a0 a1 b0 b1)
| 1 -> Some (f a2 a3 b0 b1)
| 16 -> Some (f a0 a1 b2 b3)
| 17 -> Some (f a2 a3 b2 b3)
| _ -> None
else None
val ins_Pclmulqdq (imm:int) : instr_dep [inOut opXmm] [opXmm] PreserveFlags (eval_Pclmulqdq imm)
let eval_VPclmulqdq (imm:int) (src1 src2:quad32) : option quad32 =
check_avx (eval_Pclmulqdq imm src1 src2)
val ins_VPclmulqdq (imm:int) : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags (eval_VPclmulqdq imm)
let eval_AESNI_enc (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.mix_columns_LE (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1))) src2)
else None
val ins_AESNI_enc : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc
let eval_VAESNI_enc (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc src1 src2)
val ins_VAESNI_enc : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc
let eval_AESNI_enc_last (src1 src2:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.sub_bytes (Vale.AES.AES_s.shift_rows_LE src1)) src2)
else None
val ins_AESNI_enc_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_enc_last
let eval_VAESNI_enc_last (src1 src2:quad32) : option quad32 = check_avx (eval_AESNI_enc_last src1 src2)
val ins_VAESNI_enc_last : instr_dep [out opXmm] [opXmm; opXmm] PreserveFlags eval_VAESNI_enc_last
let eval_AESNI_dec (dst src:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.inv_mix_columns_LE (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst))) src)
else None
val ins_AESNI_dec : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec
let eval_AESNI_dec_last (dst src:quad32) : option quad32 =
if aesni_enabled then
Some (quad32_xor (Vale.AES.AES_s.inv_sub_bytes (Vale.AES.AES_s.inv_shift_rows_LE dst)) src)
else None
val ins_AESNI_dec_last : instr_dep [inOut opXmm] [opXmm] PreserveFlags eval_AESNI_dec_last
let eval_AESNI_imc (src:quad32) : option quad32 =
if aesni_enabled then Some (Vale.AES.AES_s.inv_mix_columns_LE src) else None
val ins_AESNI_imc : instr_dep [out opXmm] [opXmm] PreserveFlags eval_AESNI_imc | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CryptoInstructions_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Instructions_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CryptoInstructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | imm: Vale.Def.Types_s.nat8 -> src: Vale.X64.Machine_s.quad32
-> FStar.Pervasives.Native.option Vale.X64.Machine_s.quad32 | Prims.Tot | [
"total"
] | [] | [
"Vale.Def.Types_s.nat8",
"Vale.X64.Machine_s.quad32",
"Vale.X64.CPU_Features_s.aesni_enabled",
"FStar.Pervasives.Native.Some",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Vale.AES.AES_common_s.sub_word",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Vale.Def.Types_s.ixor",
"Vale.Def.Words_s.pow2_32",
"Vale.AES.AES_s.rot_word_LE",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Prims.bool",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | true | false | let eval_AESNI_keygen_assist (imm: nat8) (src: quad32) : option quad32 =
| if aesni_enabled
then
Some
(Mkfour (Vale.AES.AES_s.sub_word src.lo1)
(ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.lo1)) imm)
(Vale.AES.AES_s.sub_word src.hi3)
(ixor (Vale.AES.AES_s.rot_word_LE (Vale.AES.AES_s.sub_word src.hi3)) imm))
else None | false |
Steel.GhostMonotonicHigherReference.fsti | Steel.GhostMonotonicHigherReference.property | val property : a: Type -> Type | let property (a:Type)
= a -> prop | {
"file_name": "lib/steel/Steel.GhostMonotonicHigherReference.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 13,
"end_line": 61,
"start_col": 0,
"start_line": 60
} | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.GhostMonotonicHigherReference
open FStar.PCM
open FStar.Ghost
open Steel.FractionalPermission
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module Preorder = FStar.Preorder
/// A library for Steel references that are monotonic with respect to a user-specified preorder.
/// This library builds on top of Steel.HigherReference, and is specialized to values at universe 1.
/// An abstract datatype for monotonic references
[@@erasable]
val ref (a:Type u#1) (p:Preorder.preorder a)
: Type u#0
/// The standard points to separation logic predicate
val pts_to_sl (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:a)
: slprop u#1
/// Lifting the standard points to predicate to vprop, with a non-informative selector
[@@ __steel_reduce__]
unfold let pts_to (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:a) : vprop =
to_vprop (pts_to_sl r f v)
/// Allocates a reference with value [x]. We have full permission on the newly
/// allocated reference.
val alloc (#opened: _) (#a:Type) (p:Preorder.preorder a) (v:a)
: SteelGhostT (ref a p) opened emp (fun r -> pts_to r full_perm v)
/// Writes value [x] in the reference [r], as long as we have full ownership of [r]
val write (#opened: _) (#a:Type) (#p:Preorder.preorder a) (#v:a)
(r:ref a p) (x:a)
: SteelGhost unit opened (pts_to r full_perm v)
(fun v -> pts_to r full_perm x)
(requires fun _ -> p v x /\ True)
(ensures fun _ _ _ -> True) | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.GhostMonotonicHigherReference.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "Preorder"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Type -> Type | Prims.Tot | [
"total"
] | [] | [
"Prims.prop"
] | [] | false | false | false | true | true | let property (a: Type) =
| a -> prop | false |
|
Steel.GhostMonotonicHigherReference.fsti | Steel.GhostMonotonicHigherReference.stable_property | val stable_property : p: FStar.Preorder.preorder a -> Type | let stable_property (#a:Type) (p:Preorder.preorder a)
= fact:property a { Preorder.stable fact p } | {
"file_name": "lib/steel/Steel.GhostMonotonicHigherReference.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 46,
"end_line": 71,
"start_col": 0,
"start_line": 70
} | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.GhostMonotonicHigherReference
open FStar.PCM
open FStar.Ghost
open Steel.FractionalPermission
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module Preorder = FStar.Preorder
/// A library for Steel references that are monotonic with respect to a user-specified preorder.
/// This library builds on top of Steel.HigherReference, and is specialized to values at universe 1.
/// An abstract datatype for monotonic references
[@@erasable]
val ref (a:Type u#1) (p:Preorder.preorder a)
: Type u#0
/// The standard points to separation logic predicate
val pts_to_sl (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:a)
: slprop u#1
/// Lifting the standard points to predicate to vprop, with a non-informative selector
[@@ __steel_reduce__]
unfold let pts_to (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:a) : vprop =
to_vprop (pts_to_sl r f v)
/// Allocates a reference with value [x]. We have full permission on the newly
/// allocated reference.
val alloc (#opened: _) (#a:Type) (p:Preorder.preorder a) (v:a)
: SteelGhostT (ref a p) opened emp (fun r -> pts_to r full_perm v)
/// Writes value [x] in the reference [r], as long as we have full ownership of [r]
val write (#opened: _) (#a:Type) (#p:Preorder.preorder a) (#v:a)
(r:ref a p) (x:a)
: SteelGhost unit opened (pts_to r full_perm v)
(fun v -> pts_to r full_perm x)
(requires fun _ -> p v x /\ True)
(ensures fun _ _ _ -> True)
/// A wrapper around a predicate that depends on a value of type [a]
let property (a:Type)
= a -> prop
/// A wrapper around a property [fact] that has been witnessed to be true and stable
/// with respect to preorder [p]
val witnessed (#a:Type u#1) (#p:Preorder.preorder a) (r:ref a p) (fact:property a)
: Type0
/// The type of properties depending on values of type [a], and that | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.GhostMonotonicHigherReference.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "Preorder"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: FStar.Preorder.preorder a -> Type | Prims.Tot | [
"total"
] | [] | [
"FStar.Preorder.preorder",
"Steel.GhostMonotonicHigherReference.property",
"FStar.Preorder.stable"
] | [] | false | false | false | true | true | let stable_property (#a: Type) (p: Preorder.preorder a) =
| fact: property a {Preorder.stable fact p} | false |
|
Steel.GhostMonotonicHigherReference.fsti | Steel.GhostMonotonicHigherReference.pts_to | val pts_to (#a: Type) (#p: Preorder.preorder a) (r: ref a p) (f: perm) (v: a) : vprop | val pts_to (#a: Type) (#p: Preorder.preorder a) (r: ref a p) (f: perm) (v: a) : vprop | let pts_to (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:a) : vprop =
to_vprop (pts_to_sl r f v) | {
"file_name": "lib/steel/Steel.GhostMonotonicHigherReference.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 28,
"end_line": 44,
"start_col": 7,
"start_line": 43
} | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.GhostMonotonicHigherReference
open FStar.PCM
open FStar.Ghost
open Steel.FractionalPermission
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module Preorder = FStar.Preorder
/// A library for Steel references that are monotonic with respect to a user-specified preorder.
/// This library builds on top of Steel.HigherReference, and is specialized to values at universe 1.
/// An abstract datatype for monotonic references
[@@erasable]
val ref (a:Type u#1) (p:Preorder.preorder a)
: Type u#0
/// The standard points to separation logic predicate
val pts_to_sl (#a:Type) (#p:Preorder.preorder a) (r:ref a p) (f:perm) (v:a)
: slprop u#1
/// Lifting the standard points to predicate to vprop, with a non-informative selector | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.GhostMonotonicHigherReference.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "Preorder"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | r: Steel.GhostMonotonicHigherReference.ref a p -> f: Steel.FractionalPermission.perm -> v: a
-> Steel.Effect.Common.vprop | Prims.Tot | [
"total"
] | [] | [
"FStar.Preorder.preorder",
"Steel.GhostMonotonicHigherReference.ref",
"Steel.FractionalPermission.perm",
"Steel.Effect.Common.to_vprop",
"Steel.GhostMonotonicHigherReference.pts_to_sl",
"Steel.Effect.Common.vprop"
] | [] | false | false | false | false | false | let pts_to (#a: Type) (#p: Preorder.preorder a) (r: ref a p) (f: perm) (v: a) : vprop =
| to_vprop (pts_to_sl r f v) | false |
LowStar.Lib.LinkedList.fst | LowStar.Lib.LinkedList.deref_data | val deref_data (#a: _) (h: HS.mem) (c: B.pointer (cell a)) : GTot a | val deref_data (#a: _) (h: HS.mem) (c: B.pointer (cell a)) : GTot a | let deref_data #a (h: HS.mem) (c: B.pointer (cell a)): GTot a =
(B.deref h c).data | {
"file_name": "krmllib/LowStar.Lib.LinkedList.fst",
"git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} | {
"end_col": 20,
"end_line": 273,
"start_col": 0,
"start_line": 272
} | module LowStar.Lib.LinkedList
/// This module, oftentimes referred to as LL1 in other parts of the
/// documentation, provides a low-level view over a linked list. Unless you
/// intend on modifying the structure of the linked list (e.g. removing cells)
/// or iterating over each cell, your are probably better off using LL2.
///
/// This module is intentionally not relying on a tight abstraction, to i) permit
/// direct-style iteration by clients and ii) allow stating some SMTPat lemmas
/// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can
/// happen automatically at the SMT level since LL2 does not have an fsti either).
///
/// Some open questions relative to the design of this module:
/// - should ``v`` be defined directly in terms of ``cells`` rather than have a
/// recursive definition along with an equivalence lemma?
/// - should ``footprint`` be defined directly in terms of ``cells`` rather than
/// have a recursive definition along with an equivalence lemma?
/// - is it worth the trouble defining a footprint? my intuition is that it's
/// fine and allows some clients to do very precise reasoning -- other modules
/// (e.g. AssocList), when establishing abstraction boundaries, can simplify
/// things and get rid of the precise footprint reasoning in favor of a static
/// region-based footprint
///
/// Some remaining work items:
/// - switch to C.Loops.while
open LowStar.BufferOps
module B = LowStar.Buffer
module HS = FStar.HyperStack
module G = FStar.Ghost
module L = FStar.List.Tot
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
open FStar.HyperStack.ST
/// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since
/// everything does recursive list reasoning.
#set-options "--__no_positivity --fuel 1 --ifuel 1"
/// Definition of the Low* type
/// ---------------------------
noeq
type t (a: Type0) =
B.pointer_or_null (cell a)
and cell (a: Type0) = {
next: t a;
data: a;
}
/// Unlike the canonical style that associates a ``v`` function to any stateful
/// representation, we use a relation here. Writing a function is just
/// impossible, since we can't prove termination of ``v`` owing to the fact that
/// there may be an infinite number of cells in the heap.
///
/// LL2 is the module that switches to the function style.
///
/// Note: no need to use erased here for ``l`` since the function is already in ``GTot``.
let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) =
B.live h c /\ (
match l with
| [] ->
B.g_is_null c
| a :: q ->
B.length c == 1 /\ (
let { data=data; next=next } = B.get h c 0 in
a == data /\
well_formed h next (G.hide q)
))
/// Precise reasoning via the cells predicate
/// -----------------------------------------
///
/// The modifies clauses are given either on the footprint of the list, or on a
/// region that includes the footprint of the list (higher up the stack, e.g.
/// LL2). This is good, but does not rule out "stupid" implementations that
/// might re-allocate every single list cell when, say, doing a pop.
///
/// For advanced usages which take pointers directly to individual list cells,
/// it's important to rule out these cases. We thus define the ``cells``
/// predicate for that purpose.
let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a)))
(requires well_formed h c l)
(ensures fun _ -> True)
(decreases l)
=
if B.g_is_null c then
[]
else
c :: cells h (B.deref h c).next (List.Tot.tl l)
/// A missing bit of automated reasoning
/// ------------------------------------
/// This should be absolutely trivial, yet, because there's no pattern on
/// null_unique, we have to do the case analysis and the decomposition
/// ourselves. This is quite tedious, as it usually takes a while (at least it
/// did for me!) to realize that this property does not hold automatically.
///
/// I'm setting an SMTPat on this lemma because it's absolutely impossible to
/// get any work done without it.
let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma
(requires (
well_formed h0 ll0 l0 /\
well_formed h1 ll1 l1 /\
cells h0 ll0 l0 == cells h1 ll1 l1))
(ensures (
ll0 == ll1))
[ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ]
=
if B.g_is_null ll0 && B.g_is_null ll1 then begin
B.null_unique ll0;
B.null_unique ll1
end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin
()
end else
false_elim ()
/// Classic stateful reasoning lemmas
/// ---------------------------------
///
/// This essentially follows ``stateful``, the type class of a mutable piece of
/// state defined using the modifies-theory of Low*v2 and equipped with the
/// right lemmas to enable usage by clients. See
/// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context.
val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc
(requires (well_formed h l n))
(ensures (fun refs -> True))
(decreases n)
let rec footprint #a h l n =
if B.g_is_null l
then B.loc_none
else
let {next = next} = B.get h l 0 in
let refs = footprint h next (G.hide (L.tl n)) in
B.loc_union (B.loc_addr_of_buffer l) refs
/// Departing from LinkedList4 here. I prefer to bolt these into the invariant
/// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to
/// deduce these.
val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_pairwise_disjoint #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\
cells_pairwise_disjoint h next (L.tl n)
val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_live_freeable #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.live h l /\ B.freeable l /\
cells_live_freeable h next (L.tl n)
val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let invariant #a h l n =
cells_live_freeable h l n /\ cells_pairwise_disjoint h l n
/// Normally this would be automatic and writing a custom lemma for that stuff
/// would be needed only when writing an fsti, however, as stated earlier,
/// recursion makes everything more difficult and this absolutely needs to be in
/// scope otherwise the modifies-clause theory cannot deduce disjointness of
/// fresh allocations w.r.t. the footprint.
let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a): Lemma
(requires well_formed h l n)
(ensures B.loc_in (footprint h l n) h)
(decreases n)
[ SMTPat (invariant h l n) ]
=
if B.g_is_null l then
()
else
let next = (B.deref h l).next in
invariant_loc_in_footprint h next (L.tl n)
/// Another absolutely essential lemma, for which interestingly the pattern
/// "invariant h1 l n" does not work, but well_formed does... I guess that's
/// alright.
let rec frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem): Lemma
(requires (
well_formed h0 l n /\
invariant h0 l n /\
B.loc_disjoint r (footprint h0 l n) /\
B.modifies r h0 h1
))
(ensures (
well_formed h1 l n /\
footprint h1 l n == footprint h0 l n /\
cells h1 l n == cells h0 l n /\
invariant h1 l n
))
(decreases n)
[ SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1) ]
=
if B.g_is_null l then
()
else
frame (B.deref h0 l).next (L.tl n) r h0 h1
/// Lemmas for working with linked lists
/// ------------------------------------
///
/// Since it's a recursive data structure, a lot of the automated reasoning from
/// LowStar.Buffer doesn't work since it requires inductions. Some helpful
/// properties are therefore proved here.
let rec length_functional #a (h: HS.mem) (c: t a) (l1 l2: list a):
Lemma
(requires (well_formed h c l1 /\ well_formed h c l2))
(ensures (l1 == l2))
(decreases (G.reveal l1))
[ SMTPat (well_formed h c l1); SMTPat (well_formed h c l2) ] =
if B.g_is_null c
then ()
else
let { next=next } = B.get h c 0 in
length_functional h next (G.hide (L.tl l1)) (G.hide (L.tl l2))
/// The footprint is based on loc_addr_of_buffer so that we can write a free
/// operation that operates on the footprint. However, this invalidates most of
/// the helper lemmas for disjointness that were present in the previous
/// iteration of this module, named LinkedList4.fst. It's ok, we bake
/// disjointness directly onto the invariant and it works just as well.
/// Connection between ``cells`` and ``v``
/// --------------------------------------
/// Redefining some helpers.
#push-options "--ifuel 1"
let rec gmap #a #b (f: a -> GTot b) (xs: list a): GTot (list b) =
match xs with
| [] -> []
| x :: xs -> f x :: gmap f xs
/// "As we all know", right folds are the easiest to work with because they
/// follow the natural structure of recursion (left-folds are evil).
let rec gfold_right #a #b (f: b -> a -> GTot b) (xs: list a) (acc: b): Ghost b
(requires True)
(ensures fun _ -> True)
(decreases xs)
=
match xs with
| [] -> acc
| x :: xs -> f (gfold_right f xs acc) x
#pop-options
/// Connecting ``v`` and ``cells``.
///
/// See ``tests/Wireguard.fst`` for why going through gmap is important and how
/// to structure your definitions (should you need to reason about ``cells``) in | {
"checked_file": "/",
"dependencies": [
"TestLib.fsti.checked",
"prims.fst.checked",
"LowStar.Failure.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int32.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Lib.LinkedList.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> c: LowStar.Buffer.pointer (LowStar.Lib.LinkedList.cell a)
-> Prims.GTot a | Prims.GTot | [
"sometrivial"
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"LowStar.Buffer.pointer",
"LowStar.Lib.LinkedList.cell",
"LowStar.Lib.LinkedList.__proj__Mkcell__item__data",
"LowStar.Monotonic.Buffer.deref",
"LowStar.Buffer.trivial_preorder"
] | [] | false | false | false | false | false | let deref_data #a (h: HS.mem) (c: B.pointer (cell a)) : GTot a =
| (B.deref h c).data | false |
Vale.AES.X64.GCMdecryptOpt.fst | Vale.AES.X64.GCMdecryptOpt.va_quick_Gcm_blocks_wrapped | val va_quick_Gcm_blocks_wrapped
(alg: algorithm)
(offset: int)
(auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b: buffer128)
(iv: supported_iv_LE)
(scratch_b: buffer128)
(key: (seq nat32))
(round_keys: (seq quad32))
(keys_b hkeys_b: buffer128)
(expected_tag: (seq nat8))
: (va_quickCode unit (va_code_Gcm_blocks_wrapped alg offset)) | val va_quick_Gcm_blocks_wrapped
(alg: algorithm)
(offset: int)
(auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b: buffer128)
(iv: supported_iv_LE)
(scratch_b: buffer128)
(key: (seq nat32))
(round_keys: (seq quad32))
(keys_b hkeys_b: buffer128)
(expected_tag: (seq nat8))
: (va_quickCode unit (va_code_Gcm_blocks_wrapped alg offset)) | let va_quick_Gcm_blocks_wrapped (alg:algorithm) (offset:int) (auth_b:buffer128)
(abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128)
(out128_b:buffer128) (inout_b:buffer128) (iv_b:buffer128) (iv:supported_iv_LE)
(scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128)
(hkeys_b:buffer128) (expected_tag:(seq nat8)) : (va_quickCode unit (va_code_Gcm_blocks_wrapped
alg offset)) =
(va_QProc (va_code_Gcm_blocks_wrapped alg offset) ([va_Mod_flags; va_Mod_mem_heaplet 6;
va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1;
va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10;
va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm
3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64
rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64
rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64
rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_Gcm_blocks_wrapped alg offset
auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b iv scratch_b key round_keys
keys_b hkeys_b expected_tag) (va_wpProof_Gcm_blocks_wrapped alg offset auth_b abytes_b
in128x6_b out128x6_b in128_b out128_b inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b
expected_tag)) | {
"file_name": "obj/Vale.AES.X64.GCMdecryptOpt.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 18,
"end_line": 1909,
"start_col": 0,
"start_line": 1892
} | module Vale.AES.X64.GCMdecryptOpt
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open FStar.Seq
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_s
open Vale.AES.GCTR_s
open Vale.AES.GCTR
open Vale.AES.GCM
open Vale.AES.GHash_s
open Vale.AES.GHash
open Vale.AES.GCM_s
open Vale.AES.X64.AES
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.Poly1305.Math
open Vale.AES.GCM_helpers
open Vale.AES.X64.GHash
open Vale.AES.X64.GCTR
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.X64.Stack_i
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.InsBasic
open Vale.X64.InsMem
open Vale.X64.InsVector
open Vale.X64.InsStack
open Vale.X64.InsAes
open Vale.X64.QuickCode
open Vale.X64.QuickCodes
open Vale.AES.X64.GF128_Mul
open Vale.X64.Stack
open Vale.X64.CPU_Features_s
open Vale.Math.Poly2.Bits_s
open Vale.AES.X64.AESopt
open Vale.AES.X64.AESGCM
open Vale.AES.X64.AESopt2
open Vale.Lib.Meta
open Vale.AES.X64.GCMencryptOpt
open Vale.AES.OptPublic
open Vale.Lib.Basic
#reset-options "--z3rlimit 20 --max_ifuel 0"
//-- Gcm_extra_bytes
val va_code_Gcm_extra_bytes : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_extra_bytes alg =
(va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0)
(va_op_reg_opr64_reg64 rRax) 0 Secret) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 10)
(va_op_xmm_xmm 0)) (va_CCons (va_code_Ghash_extra_bytes ()) (va_CCons (va_code_Mov128
(va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_CCons (va_code_Pshufb (va_op_xmm_xmm 0)
(va_op_xmm_xmm 9)) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons (va_code_Pxor
(va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_CCons (va_code_Store128_buffer
(va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret)
(va_CNil ()))))))))))
val va_codegen_success_Gcm_extra_bytes : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_extra_bytes alg =
(va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0)
(va_op_reg_opr64_reg64 rRax) 0 Secret) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm
10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Ghash_extra_bytes ()) (va_pbool_and
(va_codegen_success_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_pbool_and
(va_codegen_success_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and
(va_codegen_success_AESEncryptBlock alg) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm
10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Store128_buffer
(va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret)
(va_ttrue ())))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_extra_bytes (va_mods:va_mods_t) (alg:algorithm) (inout_b:buffer128) (key:(seq
nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat)
(old_hash:quad32) (completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit
(va_code_Gcm_extra_bytes alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (len:(va_int_range
1 1)) = 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 188 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRax) 0 Secret inout_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 189 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (fun (va_s:va_state) _ -> let
(hash_input:quad32) = va_get_xmm 0 va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 193 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_extra_bytes hkeys_b total_bytes old_hash h_LE completed_quads) (fun
(va_s:va_state) _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 194 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.equal #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s)
inout_b) (FStar.Seq.Base.create #quad32 1 hash_input)) (let (snap:(FStar.Seq.Base.seq
Vale.X64.Decls.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 198 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 199 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 200 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AESEncryptBlock alg (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 11 va_s)) key
round_keys keys_b) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 201 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.AES_s.aes_encrypt_LE_reveal ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 204 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 205 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax)
(va_op_xmm_xmm 10) 0 Secret inout_b 0) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 207 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.gctr_partial_reveal ()) (va_QEmpty (()))))))))))))))
val va_lemma_Gcm_extra_bytes : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
inout_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> total_bytes:nat -> old_hash:quad32 -> completed_quads:(seq quad32) ->
h_LE:quad32
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_extra_bytes alg) va_s0 /\ va_get_ok va_s0 /\ (let
(len:(va_int_range 1 1)) = 1 in sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b
inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b inout_b /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax va_s0) inout_b
len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys
keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0
va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32
(Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length
#quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply`
FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes
`op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16
`op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
(Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads =
FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0)
inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes =
Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) /\ va_state_eq va_sM
(va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM (va_update_ok va_sM
(va_update_mem va_sM va_s0))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_extra_bytes va_b0 va_s0 alg inout_b key round_keys keys_b hkeys_b total_bytes
old_hash completed_quads h_LE =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_extra_bytes va_mods alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_extra_bytes alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 121 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (len:(va_int_range 1 1)) = 1 in label va_range1
"***** POSTCONDITION NOT MET AT line 174 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 177 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg len (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0)) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 180 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let raw_quads = FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 181 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 182 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 183 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let input_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 186 column 59 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(l_and (FStar.Seq.Base.length #Vale.Def.Types_s.quad32 input_quads > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE old_hash input_quads)))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm
7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32)
(completed_quads:(seq quad32)) (h_LE:quad32) (va_s0:va_state) (va_k:(va_state -> unit -> Type0))
: Type0 =
(va_get_ok va_s0 /\ (let (len:(va_int_range 1 1)) = 1 in sse_enabled /\
Vale.X64.Decls.buffers_disjoint128 keys_b inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b
inout_b /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax
va_s0) inout_b len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys
keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0
va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32
(Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length
#quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply`
FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes
`op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16
`op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
(Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes) /\ (forall
(va_x_mem:vale_heap) (va_x_rcx:nat64) (va_x_r11:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32)
(va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32)
(va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm10:quad32) (va_x_heap5:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 5
va_x_heap5 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7
(va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3
(va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR11
va_x_r11 (va_upd_reg64 rRcx va_x_rcx (va_upd_mem va_x_mem va_s0)))))))))))))) in va_get_ok
va_sM /\ (let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads =
FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0)
inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes =
Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) ==> va_k va_sM (())))
val va_wpProof_Gcm_extra_bytes : alg:algorithm -> inout_b:buffer128 -> key:(seq nat32) ->
round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> total_bytes:nat ->
old_hash:quad32 -> completed_quads:(seq quad32) -> h_LE: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_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_extra_bytes alg) ([va_Mod_flags;
va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5;
va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11;
va_Mod_reg64 rRcx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash
completed_quads h_LE va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_extra_bytes (va_code_Gcm_extra_bytes alg) va_s0 alg inout_b key
round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10
va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm
7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32)
(completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit (va_code_Gcm_extra_bytes alg)) =
(va_QProc (va_code_Gcm_extra_bytes alg) ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10;
va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm
2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem])
(va_wp_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash
completed_quads h_LE) (va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE))
//--
//-- Gcm_blocks128
val va_code_Gcm_blocks128 : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks128 alg =
(va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi))
(va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_CCons
(va_code_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_CCons
(va_code_Ghash_buffer ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdi)
(va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx)
(va_op_opr64_reg64 rR12)) (va_CCons (va_code_Gctr_blocks128 alg) (va_CNil ())))))))))
val va_codegen_success_Gcm_blocks128 : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks128 alg =
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi))
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx))
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax))
(va_pbool_and (va_codegen_success_Ghash_buffer ()) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_pbool_and
(va_codegen_success_Gctr_blocks128 alg) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks128 (va_mods:va_mods_t) (alg:algorithm) (in_b:buffer128) (out_b:buffer128)
(key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32)
: (va_quickCode unit (va_code_Gcm_blocks128 alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 274 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 275 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 276 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 277 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_buffer hkeys_b in_b h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_old_s))) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 278 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 279 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 280 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gctr_blocks128 alg in_b out_b key round_keys keys_b) (va_QEmpty (()))))))))))
val va_lemma_Gcm_blocks128 : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> in_b:buffer128 ->
out_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> h_LE:quad32
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks128 alg) va_s0 /\ va_get_ok va_s0 /\
(sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b out_b /\
Vale.X64.Decls.buffers_disjoint128 hkeys_b out_b /\ (Vale.X64.Decls.buffers_disjoint128 in_b
out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16
`op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply`
va_get_reg64 rRdx va_s0 < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b)
(Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx
va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\
va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8
va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0)
(va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM ==
va_get_xmm 8 va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b ==
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ (va_get_reg64 rRdx va_s0 > 0 ==>
l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==> FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b)))) /\ va_state_eq va_sM (va_update_flags va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 10 va_sM (va_update_xmm 11 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rR10 va_sM
(va_update_reg64 rR11 va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRbx va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_blocks128 va_b0 va_s0 alg in_b out_b key round_keys keys_b hkeys_b h_LE =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11;
va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm
2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks128 va_mods alg in_b out_b key round_keys keys_b hkeys_b h_LE in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks128 alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 210 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 255 column 53 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 261 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 262 column 45 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0) (va_get_reg64 rRdx
va_s0)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 265 column 93 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM == va_get_xmm 8 va_s0)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b == Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) out_b)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 267 column 131 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRdx va_s0 > 0 ==> l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==>
FStar.Seq.Base.length #Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm
8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2;
va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_blocks128 (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32) (va_s0:va_state)
(va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b out_b /\
Vale.X64.Decls.buffers_disjoint128 hkeys_b out_b /\ (Vale.X64.Decls.buffers_disjoint128 in_b
out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16
`op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply`
va_get_reg64 rRdx va_s0 < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b)
(Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx
va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\
va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8
va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret) /\ (forall (va_x_mem:vale_heap) (va_x_rbx:nat64) (va_x_rdi:nat64) (va_x_r11:nat64)
(va_x_r10:nat64) (va_x_rdx:nat64) (va_x_r12:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32)
(va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32)
(va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm11:quad32) (va_x_xmm10:quad32)
(va_x_heap1:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 11 va_x_xmm11
(va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5
(va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1
(va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64
rR10 va_x_r10 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRbx
va_x_rbx (va_upd_mem va_x_mem va_s0))))))))))))))))))) in va_get_ok va_sM /\
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0)
(va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM ==
va_get_xmm 8 va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b ==
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ (va_get_reg64 rRdx va_s0 > 0 ==>
l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==> FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b)))) ==> va_k va_sM (())))
val va_wpProof_Gcm_blocks128 : alg:algorithm -> in_b:buffer128 -> out_b:buffer128 -> key:(seq
nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> h_LE: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_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b
h_LE va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks128 alg) ([va_Mod_flags;
va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6;
va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0;
va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10; va_Mod_reg64 rR11; va_Mod_reg64 rRdi;
va_Mod_reg64 rRbx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_blocks128 (va_code_Gcm_blocks128 alg) va_s0 alg in_b out_b key
round_keys keys_b hkeys_b h_LE in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 1 va_sM (va_update_xmm 10
va_sM (va_update_xmm 11 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6
va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2
va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR12 va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rRdi va_sM (va_update_reg64 rRbx va_sM (va_update_ok va_sM (va_update_mem
va_sM va_s0))))))))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm
8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2;
va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_blocks128 (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32) : (va_quickCode
unit (va_code_Gcm_blocks128 alg)) =
(va_QProc (va_code_Gcm_blocks128 alg) ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10;
va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm
3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64
rR10; va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_mem])
(va_wp_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE)
(va_wpProof_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE))
//--
//-- Gcm_blocks
#push-options "--z3rlimit 1000"
val va_code_Gcm_blocks : alg:algorithm -> offset:int -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks alg offset =
(va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx))
(va_CCons (va_code_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9) (va_const_opr64
32)) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRsp)
(offset + 0)) (va_CCons (va_code_Gcm_blocks_auth ()) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8)) (va_CCons
(va_code_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp) (offset + 16))
(va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp)
(offset + 24)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13))
(va_CCons (va_code_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64
rR8) 0 Public) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_reg_opr64_reg64 rRbp) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_Load_one_lsb
(va_op_xmm_xmm 10)) (va_CCons (va_code_VPaddd (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)
(va_op_xmm_xmm 10)) (va_CCons (va_code_AES_GCM_decrypt_6mult alg) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11) (va_op_reg_opr64_reg64
rRbp) 32 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx))
(va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp)
(offset + 32)) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRdi)
(va_op_reg_opr64_reg64 rRsp) (offset + 40)) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 48)) (va_CCons
(va_code_Mov64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRdx)) (va_CCons
(va_code_InitPshufbMask (va_op_xmm_xmm 9) (va_op_reg_opr64_reg64 rR12)) (va_CCons
(va_code_Pshufb (va_op_xmm_xmm 11) (va_op_xmm_xmm 9)) (va_CCons (va_code_Gcm_blocks128 alg)
(va_CCons (va_code_Stack_lemma ()) (va_CCons (va_code_Add64 (va_op_dst_opr64_reg64 rR14)
(va_opr_code_Stack (va_op_reg64_reg64 rRsp) (offset + 24) Public)) (va_CCons (va_code_IMul64
(va_op_dst_opr64_reg64 rR14) (va_const_opr64 16)) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rR13) (va_op_reg_opr64_reg64 rRsp) (offset + 64)) (va_CCons (va_IfElse
(va_cmp_gt (va_op_cmp_reg64 rR13) (va_op_cmp_reg64 rR14)) (va_Block (va_CCons
(va_code_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 56))
(va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR13)) (va_CCons
(va_code_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 15)) (va_CCons
(va_code_Gcm_extra_bytes alg) (va_CCons (va_Block (va_CNil ())) (va_CNil ()))))))) (va_Block
(va_CNil ()))) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15))
(va_CCons (va_code_Gcm_make_length_quad ()) (va_CCons (va_code_Ghash_register ()) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRbp) 0 Secret) (va_CCons (va_code_Gctr_register alg) (va_CCons (va_Block (va_CNil ()))
(va_CNil ()))))))))))))))))))))))))))))))))))))
val va_codegen_success_Gcm_blocks : alg:algorithm -> offset:int -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks alg offset =
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx))
(va_pbool_and (va_codegen_success_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9)
(va_const_opr64 32)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64
rRbx) (va_op_reg_opr64_reg64 rRsp) (offset + 0)) (va_pbool_and
(va_codegen_success_Gcm_blocks_auth ()) (va_pbool_and (va_codegen_success_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8)) (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp)
(offset + 16)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRdx)
(va_op_reg_opr64_reg64 rRsp) (offset + 24)) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13)) (va_pbool_and (va_codegen_success_Mov128
(va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_Load128_buffer
(va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rR8) 0 Public)
(va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_reg_opr64_reg64 rRbp) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and
(va_codegen_success_Load_one_lsb (va_op_xmm_xmm 10)) (va_pbool_and (va_codegen_success_VPaddd
(va_op_xmm_xmm 1) (va_op_xmm_xmm 1) (va_op_xmm_xmm 10)) (va_pbool_and
(va_codegen_success_AES_GCM_decrypt_6mult alg) (va_pbool_and (va_codegen_success_Load128_buffer
(va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11) (va_op_reg_opr64_reg64 rRbp) 32 Secret)
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx))
(va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRax)
(va_op_reg_opr64_reg64 rRsp) (offset + 32)) (va_pbool_and (va_codegen_success_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 40)) (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp)
(offset + 48)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR14)
(va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_InitPshufbMask (va_op_xmm_xmm 9)
(va_op_reg_opr64_reg64 rR12)) (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 11)
(va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_Gcm_blocks128 alg) (va_pbool_and
(va_codegen_success_Stack_lemma ()) (va_pbool_and (va_codegen_success_Add64
(va_op_dst_opr64_reg64 rR14) (va_opr_code_Stack (va_op_reg64_reg64 rRsp) (offset + 24) Public))
(va_pbool_and (va_codegen_success_IMul64 (va_op_dst_opr64_reg64 rR14) (va_const_opr64 16))
(va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rR13)
(va_op_reg_opr64_reg64 rRsp) (offset + 64)) (va_pbool_and (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp)
(offset + 56)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR10)
(va_op_opr64_reg64 rR13)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rR10)
(va_const_opr64 15)) (va_codegen_success_Gcm_extra_bytes alg)))) (va_pbool_and
(va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15)) (va_pbool_and
(va_codegen_success_Gcm_make_length_quad ()) (va_pbool_and (va_codegen_success_Ghash_register
()) (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRbp) 0 Secret) (va_pbool_and
(va_codegen_success_Gctr_register alg) (va_ttrue ()))))))))))))))))))))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks (va_mods:va_mods_t) (alg:algorithm) (offset:int) (auth_b:buffer128)
(abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128)
(out128_b:buffer128) (inout_b:buffer128) (iv_b:buffer128) (scratch_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit
(va_code_Gcm_blocks alg offset)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 0) (va_get_stack va_s) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 8) (va_get_stack va_s) in let
(out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 16) (va_get_stack va_s) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 24) (va_get_stack va_s) in let
(in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 32) (va_get_stack va_s) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 40) (va_get_stack va_s) in let
(len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset
+ 48) (va_get_stack va_s) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 56) (va_get_stack va_s) in let
(plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s
+ offset + 64) (va_get_stack va_s) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_old_s)) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 463 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 464 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9) (va_const_opr64 32))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 465 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRsp) (offset + 0))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 466 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks_auth auth_b abytes_b hkeys_b h_LE) (fun (va_s:va_state)
(auth_quad_seq:(seq quad32)) -> let (y_0:quad32) = Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 0 0 0 0 in let (y_auth_bytes:quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 473 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 474 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp) (offset + 16))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 475 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 24))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 476 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 477 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (fun (va_s:va_state) _ -> let
(iv_BE:Vale.X64.Decls.quad32) = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2
va_old_s) in let (ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32
iv_BE 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 483 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64
rR8) 0 Public iv_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 485 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_reg_opr64_reg64 rRbp)
(va_op_xmm_xmm 1) 0 Secret scratch_b 0) (fun (va_s:va_state) _ -> let (j0:quad32) = va_get_xmm
1 va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 487 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load_one_lsb (va_op_xmm_xmm 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 489 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_VPaddd (va_op_xmm_xmm 1) (va_op_xmm_xmm 1) (va_op_xmm_xmm 10)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 491 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AES_GCM_decrypt_6mult alg h_LE iv_b in128x6_b out128x6_b scratch_b key round_keys
keys_b hkeys_b) (fun (va_s:va_state) _ -> let (y_cipher128x6:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in let (auth_in:(seq quad32)) =
auth_quad_seq in let (va_arg138:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) =
Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b in let
(va_arg137:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg136:Vale.Def.Types_s.quad32) = y_auth_bytes in let (va_arg135:Vale.Def.Types_s.quad32) =
y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 494 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_ghash_incremental0_append h_LE va_arg135 va_arg136
y_cipher128x6 va_arg137 va_arg138) (let auth_in = FStar.Seq.Base.append #quad32 auth_in
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 498 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11)
(va_op_reg_opr64_reg64 rRbp) 32 Secret scratch_b 2) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 499 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 500 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 32))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 501 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 40))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 502 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 48))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 503 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 504 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_InitPshufbMask (va_op_xmm_xmm 9) (va_op_reg_opr64_reg64 rR12)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 505 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pshufb (va_op_xmm_xmm 11) (va_op_xmm_xmm 9)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 506 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks128 alg in128_b out128_b key round_keys keys_b hkeys_b h_LE) (fun
(va_s:va_state) _ -> let (y_cipher128:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in let (va_arg134:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b in let
(va_arg133:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg132:Vale.Def.Types_s.quad32) = y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 508 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_ghash_incremental0_append h_LE va_arg132 y_cipher128x6
y_cipher128 va_arg133 va_arg134) (let auth_in = FStar.Seq.Base.append #quad32 auth_in
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 512 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Stack_lemma (va_op_reg64_reg64 rRsp) (offset + 24) Public) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 512 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Add64 (va_op_dst_opr64_reg64 rR14) (va_opr_code_Stack (va_op_reg64_reg64 rRsp)
(offset + 24) Public)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 513 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_IMul64 (va_op_dst_opr64_reg64 rR14) (va_const_opr64 16)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 514 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rR13) (va_op_reg_opr64_reg64 rRsp) (offset + 64))
(fun (va_s:va_state) _ -> let (y_inout:Vale.Def.Types_s.quad32) = y_cipher128 in let
(plain_byte_seq:(seq quad32)) = empty_seq_quad32 in let (cipher_byte_seq:(seq quad32)) =
empty_seq_quad32 in let (va_arg131:Vale.Def.Types_s.quad32) = va_get_xmm 11 va_s in let
(va_arg130:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in let
(va_arg129:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = cipher_byte_seq in let
(va_arg128:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = plain_byte_seq in let
(va_arg127:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 519 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.gctr_partial_opaque_init va_arg127 va_arg128 va_arg129 va_arg130
va_arg131) (let (total_bytes:(va_int_at_least 0)) = FStar.Seq.Base.length #quad32 auth_quad_seq
`op_Multiply` 16 + plain_num_bytes in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 523 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_qIf va_mods (Cmp_gt (va_op_cmp_reg64 rR13) (va_op_cmp_reg64 rR14)) (qblock va_mods (fun
(va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 525 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 56))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 526 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR13)) (fun (va_s:va_state) _
-> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 527 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.Poly1305.Math.lemma_poly_bits64 ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 528 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 15)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 532 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes y_0 auth_in
h_LE) (fun (va_s:va_state) _ -> let y_inout = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm
8 va_s) in let (raw_auth_quads:(FStar.Seq.Base.seq quad32)) = FStar.Seq.Base.append #quad32
auth_in (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b) in va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 536 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun a_1906 (s_1907:(FStar.Seq.Base.seq a_1906)) (i_1908:Prims.nat) (j_1909:Prims.nat) -> let
(j_1869:Prims.nat) = j_1909 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1908
j_1869) (Prims.op_LessThanOrEqual j_1869 (FStar.Seq.Base.length #a_1906 s_1907))))
Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 total_bytes)
(fun _ -> let (auth_input_bytes:(FStar.Seq.Base.seq Vale.Def.Types_s.nat8)) =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
raw_auth_quads) 0 total_bytes in let (padded_auth_bytes:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in let auth_in =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes in let plain_byte_seq =
Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b in let cipher_byte_seq =
Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b in va_QEmpty ((auth_in,
cipher_byte_seq, plain_byte_seq, y_inout)))))))))) (qblock va_mods (fun (va_s:va_state) ->
va_QEmpty ((auth_in, cipher_byte_seq, plain_byte_seq, y_inout))))) (fun (va_s:va_state) va_g ->
let ((auth_in:(seq quad32)), (cipher_byte_seq:(seq quad32)), (plain_byte_seq:(seq quad32)),
(y_inout:Vale.Def.Types_s.quad32)) = va_g in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 547 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 548 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_make_length_quad ()) (fun (va_s:va_state) _ -> let
(length_quad32:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 0
va_s) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 551 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_register hkeys_b h_LE y_inout) (fun (va_s:va_state) _ -> let
(y_final:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s)
in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 554 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRbp) 0 Secret scratch_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 557 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gctr_register alg key round_keys keys_b) (fun (va_s:va_state) _ -> let
(va_arg126:Vale.Def.Types_s.quad32) = va_get_xmm 8 va_s in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 560 column 40 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.Arch.Types.le_seq_quad32_to_bytes_of_singleton va_arg126)
(va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 561 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun (icb_BE_677:Vale.Def.Types_s.quad32) (plain_LE_678:Vale.Def.Types_s.quad32)
(alg_679:Vale.AES.AES_common_s.algorithm) (key_680:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32))
(i_681:Prims.int) -> Vale.AES.AES_s.is_aes_key_LE alg_679 key_680) j0 y_final alg key 0) (fun _
-> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 561 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 8 va_s == Vale.AES.GCTR_s.gctr_encrypt_block j0 y_final alg key 0) (let
(plain128:(FStar.Seq.Base.seq Vale.X64.Decls.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in let
(cipher128:(FStar.Seq.Base.seq Vale.X64.Decls.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) in128_b) in va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 566 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.length #quad32 plain_byte_seq == 0 ==> FStar.Seq.Base.equal
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 plain128 plain_byte_seq)
plain128) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 567 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.length #quad32 cipher_byte_seq == 0 ==> FStar.Seq.Base.equal
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 cipher128 cipher_byte_seq)
cipher128) (let (va_arg125:Vale.Def.Types_s.quad32) = Vale.AES.GCTR.inc32lite ctr_BE_2 len128x6
in let (va_arg124:Vale.Def.Types_s.quad32) = ctr_BE_2 in let (va_arg123:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) = key in let (va_arg122:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32))
= Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b in let
(va_arg121:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) in128_b in let (va_arg120:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) out128x6_b in let
(va_arg119:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_old_s) in128x6_b in let (va_arg118:Prims.nat) = len128 in let
(va_arg117:Prims.nat) = len128x6 in let (va_arg116:Vale.AES.AES_common_s.algorithm) = alg in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 569 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.lemma_gctr_partial_append va_arg116 va_arg117 va_arg118
va_arg119 va_arg120 va_arg121 va_arg122 va_arg123 va_arg124 va_arg125) (let
(va_arg115:Vale.Def.Types_s.quad32) = Vale.AES.GCTR.inc32lite (Vale.AES.GCTR.inc32lite ctr_BE_2
len128x6) len128 in let (va_arg114:Vale.Def.Types_s.quad32) = ctr_BE_2 in let
(va_arg113:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in let
(va_arg112:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = cipher_byte_seq in let
(va_arg111:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = plain_byte_seq in let
(va_arg110:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b) in let
(va_arg109:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in let (va_arg108:Prims.nat) =
FStar.Seq.Base.length #quad32 plain_byte_seq in let (va_arg107:Prims.nat) = len128x6 + len128
in let (va_arg106:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 575 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.lemma_gctr_partial_append va_arg106 va_arg107 va_arg108
va_arg109 va_arg110 va_arg111 va_arg112 va_arg113 va_arg114 va_arg115) (let
(va_arg105:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg104:Vale.Def.Types_s.quad32) = y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 583 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_hash_append2 h_LE va_arg104 y_inout y_final va_arg105
length_quad32) (let auth_in = FStar.Seq.Base.append #quad32 auth_in (FStar.Seq.Base.create
#Vale.Def.Types_s.quad32 1 length_quad32) in let (va_arg103:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = auth_in in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 585 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.ghash_incremental_to_ghash h_LE va_arg103) (va_QEmpty
(()))))))))))))))))))))))))))))))))))))))))))))))))
val va_lemma_Gcm_blocks : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> offset:int ->
auth_b:buffer128 -> abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 ->
in128_b:buffer128 -> out128_b:buffer128 -> inout_b:buffer128 -> iv_b:buffer128 ->
scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks alg offset) va_s0 /\ va_get_ok va_s0 /\
(let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in sse_enabled /\ movbe_enabled /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp
va_s0 + offset + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet
1 va_s0) (va_get_reg64 rRdi va_s0) auth_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2
va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6
va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) in128_ptr in128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1
va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) inout_ptr inout_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0) hkeys_b 8
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet
1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b
(va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer128
scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) /\
Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32
/\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let
(ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in let
(plain_in:(seq quad32)) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) then FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) else FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in let (cipher_out:(seq quad32)) = (if (plain_num_bytes
> (len128x6 + len128) `op_Multiply` 128 `op_Division` 8) then FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) else
FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM)
out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b)) in let
(cipher_bound:nat) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128 `op_Division`
8) then (len128x6 + len128 + 1) else (len128x6 + len128)) in Vale.AES.GCTR.gctr_partial alg
cipher_bound plain_in cipher_out key ctr_BE_2 /\ (let (length_quad:quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) (8
`op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply` plain_num_bytes) 0) in let
(raw_auth_quads:(seq quad32)) = (if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) then FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b) else Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0)
auth_b) in let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64 rRsi va_s0) in let
(padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in let
(auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes in let
(raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 (FStar.Seq.Base.append #quad32
auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in let (total_bytes:nat) =
FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 + plain_num_bytes in let
(raw_quad_seq:(seq quad32)) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) then (let (ab:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32 raw_quad_seq
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let (pb:(seq
nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32 pb) else
raw_quad_seq) in let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 raw_quad_seq
(FStar.Seq.Base.create #quad32 1 length_quad) in va_get_xmm 8 va_sM ==
Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE h_LE auth_quad_seq) alg
key 0))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM
(va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm
13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm
9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM
(va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM
(va_update_reg64 rRbp va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0)))))))))))))))))))))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_blocks va_b0 va_s0 alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5;
va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14;
va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12;
va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp;
va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx;
va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks va_mods alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks alg offset) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 283 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
let (h_LE:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.X64.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 0 va_s0)) in label va_range1
"***** POSTCONDITION NOT MET AT line 396 column 56 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 397 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 398 column 57 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 399 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 400 column 58 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet
6 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 403 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(plain_num_bytes < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 404 column 38 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRsi va_s0 < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 406 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 408 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (ctr_BE_1:quad32) = iv_BE in label va_range1
"***** POSTCONDITION NOT MET AT line 409 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in label va_range1
"***** POSTCONDITION NOT MET AT line 412 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (plain_in:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in label va_range1
"***** POSTCONDITION NOT MET AT line 421 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (cipher_out:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_sM) out128_b)) in label va_range1
"***** POSTCONDITION NOT MET AT line 430 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (cipher_bound:nat) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> len128x6 + len128 + 1) (fun _ -> len128x6 + len128) in label
va_range1
"***** POSTCONDITION NOT MET AT line 434 column 77 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg cipher_bound plain_in cipher_out key ctr_BE_2) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 438 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (length_quad:quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 0 0 0 0) (8 `op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply`
plain_num_bytes) 0) in label va_range1
"***** POSTCONDITION NOT MET AT line 440 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_auth_quads:(seq quad32)) = va_if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b)) (fun _ -> Vale.X64.Decls.s128 (va_get_mem_heaplet 1
va_s0) auth_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 444 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64 rRsi va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 445 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in label
va_range1
"***** POSTCONDITION NOT MET AT line 446 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes
in label va_range1
"***** POSTCONDITION NOT MET AT line 448 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 (FStar.Seq.Base.append #quad32
auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 452 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (total_bytes:nat) = FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 +
plain_num_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 453 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_quad_seq:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply`
128 `op_Division` 8) (fun _ -> let (ab:(seq nat8)) = FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32
raw_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let
(pb:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32
pb) (fun _ -> raw_quad_seq) in label va_range1
"***** POSTCONDITION NOT MET AT line 460 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 raw_quad_seq
(FStar.Seq.Base.create #quad32 1 length_quad) in label va_range1
"***** POSTCONDITION NOT MET AT line 461 column 106 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 8 va_sM == Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE
h_LE auth_quad_seq) alg key 0)))))))))))))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_blocks (alg:algorithm) (offset:int) (auth_b:buffer128) (abytes_b:buffer128)
(in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128) (out128_b:buffer128)
(inout_b:buffer128) (iv_b:buffer128) (scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
let (h_LE:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.X64.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 0 va_s0)) in sse_enabled /\
movbe_enabled /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0)
(va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet
1 va_s0) (va_get_reg64 rRdi va_s0) auth_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2
va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6
va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) in128_ptr in128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1
va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) inout_ptr inout_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0) hkeys_b 8
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)))) /\ (forall (va_x_mem:vale_heap)
(va_x_rax:nat64) (va_x_rbx:nat64) (va_x_rcx:nat64) (va_x_rdx:nat64) (va_x_rdi:nat64)
(va_x_rsi:nat64) (va_x_rbp:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64)
(va_x_r11:nat64) (va_x_r12:nat64) (va_x_r13:nat64) (va_x_r14:nat64) (va_x_r15:nat64)
(va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32)
(va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm9:quad32)
(va_x_xmm10:quad32) (va_x_xmm11:quad32) (va_x_xmm12:quad32) (va_x_xmm13:quad32)
(va_x_xmm14:quad32) (va_x_xmm15:quad32) (va_x_heap1:vale_heap) (va_x_heap2:vale_heap)
(va_x_heap3:vale_heap) (va_x_heap5:vale_heap) (va_x_heap6:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 6
va_x_heap6 (va_upd_mem_heaplet 5 va_x_heap5 (va_upd_mem_heaplet 3 va_x_heap3
(va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 15 va_x_xmm15
(va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12 (va_upd_xmm 11
va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (va_upd_xmm 8 va_x_xmm8
(va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4
(va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0
(va_upd_reg64 rR15 va_x_r15 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13
(va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10
(va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRbp va_x_rbp (va_upd_reg64
rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRcx
va_x_rcx (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem
va_s0))))))))))))))))))))))))))))))))))))) in va_get_ok va_sM /\ (let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet
1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b
(va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer128
scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) /\
Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32
/\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let
(ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in let
(plain_in:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in let (cipher_out:(seq quad32)) = va_if
(plain_num_bytes > (len128x6 + len128) `op_Multiply` 128 `op_Division` 8) (fun _ ->
FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_sM) out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM)
inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) in let (cipher_bound:nat) = va_if (plain_num_bytes > (len128x6 + len128)
`op_Multiply` 128 `op_Division` 8) (fun _ -> len128x6 + len128 + 1) (fun _ -> len128x6 +
len128) in Vale.AES.GCTR.gctr_partial alg cipher_bound plain_in cipher_out key ctr_BE_2 /\ (let
(length_quad:quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) (8
`op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply` plain_num_bytes) 0) in let
(raw_auth_quads:(seq quad32)) = va_if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b)) (fun _ -> Vale.X64.Decls.s128 (va_get_mem_heaplet 1
va_s0) auth_b) in let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64
rRsi va_s0) in let (padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits
auth_input_bytes in let (auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32
padded_auth_bytes in let (raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32
(FStar.Seq.Base.append #quad32 auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0)
in128x6_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in let (total_bytes:nat)
= FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 + plain_num_bytes in let
(raw_quad_seq:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> let (ab:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32 raw_quad_seq
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let (pb:(seq
nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32 pb) (fun
_ -> raw_quad_seq) in let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32
raw_quad_seq (FStar.Seq.Base.create #quad32 1 length_quad) in va_get_xmm 8 va_sM ==
Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE h_LE auth_quad_seq) alg
key 0))) ==> va_k va_sM (())))
val va_wpProof_Gcm_blocks : alg:algorithm -> offset:int -> auth_b:buffer128 -> abytes_b:buffer128
-> in128x6_b:buffer128 -> out128x6_b:buffer128 -> in128_b:buffer128 -> out128_b:buffer128 ->
inout_b:buffer128 -> iv_b:buffer128 -> scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq
quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit ->
Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b
in128_b out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks alg offset) ([va_Mod_flags;
va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2;
va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm
11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5;
va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15;
va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10;
va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi;
va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) va_s0
va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b
iv_b scratch_b key round_keys keys_b hkeys_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_blocks (va_code_Gcm_blocks alg offset) va_s0 alg offset auth_b
abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b scratch_b key round_keys keys_b
hkeys_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM
(va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm
13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm
9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM
(va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM
(va_update_reg64 rRbp va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))))))))))))))))))))))))))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_blocks (alg:algorithm) (offset:int) (auth_b:buffer128) (abytes_b:buffer128)
(in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128) (out128_b:buffer128)
(inout_b:buffer128) (iv_b:buffer128) (scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit (va_code_Gcm_blocks alg
offset)) =
(va_QProc (va_code_Gcm_blocks alg offset) ([va_Mod_flags; va_Mod_mem_heaplet 6;
va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1;
va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10;
va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm
3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64
rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64
rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64
rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_Gcm_blocks alg offset auth_b
abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b scratch_b key round_keys keys_b
hkeys_b) (va_wpProof_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b))
#pop-options
//--
//-- Gcm_blocks_wrapped
#push-options "--z3rlimit 60"
val va_code_Gcm_blocks_wrapped : alg:algorithm -> offset:int -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks_wrapped alg offset =
(va_Block (va_CCons (va_code_Gcm_blocks alg offset) (va_CCons (va_Block (va_CNil ())) (va_CCons
(va_Block (va_CNil ())) (va_CNil ())))))
val va_codegen_success_Gcm_blocks_wrapped : alg:algorithm -> offset:int -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks_wrapped alg offset =
(va_pbool_and (va_codegen_success_Gcm_blocks alg offset) (va_ttrue ()))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks_wrapped (va_mods:va_mods_t) (alg:algorithm) (offset:int) (auth_b:buffer128)
(abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128)
(out128_b:buffer128) (inout_b:buffer128) (iv_b:buffer128) (iv:supported_iv_LE)
(scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128)
(hkeys_b:buffer128) (expected_tag:(seq nat8)) : (va_quickCode unit (va_code_Gcm_blocks_wrapped
alg offset)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 0) (va_get_stack va_s) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 8) (va_get_stack va_s) in let
(out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 16) (va_get_stack va_s) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 24) (va_get_stack va_s) in let
(in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 32) (va_get_stack va_s) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 40) (va_get_stack va_s) in let
(len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset
+ 48) (va_get_stack va_s) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 56) (va_get_stack va_s) in let
(plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s
+ offset + 64) (va_get_stack va_s) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 739 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b
iv_b scratch_b key round_keys keys_b hkeys_b) (fun (va_s:va_state) _ -> va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 741 column 37 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(8 `op_Multiply` va_get_reg64 rRsi va_old_s >= 0 /\ 8 `op_Multiply` va_get_reg64 rRsi va_old_s
<= 18446744073709551615 /\ 8 `op_Multiply` plain_num_bytes >= 0 /\ 8 `op_Multiply`
plain_num_bytes <= 18446744073709551615) (fun _ -> let (va_arg55:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) (8
`op_Multiply` va_get_reg64 rRsi va_old_s) 1) (8 `op_Multiply` plain_num_bytes) 0) in let
(va_arg54:Vale.Def.Types_s.quad32) = va_get_xmm 8 va_s in let
(va_arg53:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.X64.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 0 va_s)) in let
(va_arg52:Vale.Def.Types_s.quad32) = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2
va_old_s) in let (va_arg51:Vale.AES.GCM_s.supported_iv_LE) = iv in let (va_arg50:Prims.nat) =
va_get_reg64 rRsi va_old_s in let (va_arg49:Prims.nat) = plain_num_bytes in let
(va_arg48:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s) inout_b in let (va_arg47:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b in let
(va_arg46:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s) out128x6_b in let (va_arg45:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b in let
(va_arg44:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) in128_b in let (va_arg43:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b in
let (va_arg42:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_old_s) abytes_b in let (va_arg41:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) auth_b in let
(va_arg40:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = key in let
(va_arg39:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 741 column 37 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCM.gcm_blocks_dec_helper_simplified va_arg39 va_arg40 va_arg41
va_arg42 va_arg43 va_arg44 va_arg45 va_arg46 va_arg47 va_arg48 va_arg49 va_arg50 va_arg51
va_arg52 va_arg53 va_arg54 va_arg55) (let (auth_raw_quads:(FStar.Seq.Base.seq
Vale.X64.Decls.quad32)) = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) auth_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_old_s)
abytes_b) in va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 751 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun a_1906 (s_1907:(FStar.Seq.Base.seq a_1906)) (i_1908:Prims.nat) (j_1909:Prims.nat) -> let
(j_1869:Prims.nat) = j_1909 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1908
j_1869) (Prims.op_LessThanOrEqual j_1869 (FStar.Seq.Base.length #a_1906 s_1907))))
Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0 (va_get_reg64
rRsi va_old_s)) (fun _ -> let (auth_bytes:(FStar.Seq.Base.seq Vale.Def.Types_s.nat8)) =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
auth_raw_quads) 0 (va_get_reg64 rRsi va_old_s) in let (va_arg38:Vale.Def.Types_s.quad32) =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_old_s) in let
(va_arg37:Vale.AES.GCM_s.supported_iv_LE) = iv in let (va_arg36:Prims.nat) = plain_num_bytes in
let (va_arg35:(FStar.Seq.Base.seq Vale.Def.Words_s.nat8)) = expected_tag in let
(va_arg34:(FStar.Seq.Base.seq Vale.Def.Words_s.nat8)) = auth_bytes in let
(va_arg33:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s) inout_b in let (va_arg32:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b in let
(va_arg31:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s) out128x6_b in let (va_arg30:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b in let
(va_arg29:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) in128_b in let (va_arg28:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b in
let (va_arg27:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = key in let
(va_arg26:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 752 column 37 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCM.gcm_blocks_helper_dec_simplified va_arg26 va_arg27 va_arg28
va_arg29 va_arg30 va_arg31 va_arg32 va_arg33 va_arg34 va_arg35 va_arg36 va_arg37 va_arg38)
(va_QEmpty (()))))))))
val va_lemma_Gcm_blocks_wrapped : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> offset:int ->
auth_b:buffer128 -> abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 ->
in128_b:buffer128 -> out128_b:buffer128 -> inout_b:buffer128 -> iv_b:buffer128 ->
iv:supported_iv_LE -> scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) ->
keys_b:buffer128 -> hkeys_b:buffer128 -> expected_tag:(seq nat8)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks_wrapped alg offset) va_s0 /\ va_get_ok
va_s0 /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in sse_enabled /\ movbe_enabled /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp
va_s0 + offset + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet
1 va_s0) (va_get_reg64 rRdi va_s0) auth_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2
va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6
va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) in128_ptr in128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1
va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) inout_ptr inout_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0) hkeys_b 8
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\ (let iv_BE =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let h_LE =
Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
in iv_BE == Vale.AES.GCM_s.compute_iv_BE h_LE iv))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in Vale.X64.Decls.modifies_buffer128 out128_b
(va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128
iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\
Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM) /\ Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0)
(va_get_mem_heaplet 5 va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b
(va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\
va_get_reg64 rRsi va_s0 < pow2_32 /\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0
(va_get_mem_heaplet 2 va_s0) in let auth_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_s0) abytes_b) in let auth_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
auth_raw_quads) 0 (va_get_reg64 rRsi va_s0) in let plain_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0)
in128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) in let plain_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
plain_raw_quads) 0 plain_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) in let cipher_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
cipher_raw_quads) 0 plain_num_bytes in l_and (l_and (l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.nat8 auth_bytes < pow2_32) (FStar.Seq.Base.length #Vale.Def.Types_s.nat8
plain_bytes < pow2_32)) (cipher_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq
Vale.Def.Types_s.nat8) #bool (Vale.AES.GCM_s.gcm_decrypt_LE alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes expected_tag)))
(Vale.Def.Types_s.le_quad32_to_bytes (va_get_xmm 8 va_sM) == Vale.AES.GCM.gcm_decrypt_LE_tag
alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM (va_update_mem_heaplet
5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 1
va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12
va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm 9 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM
(va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM
(va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRbp va_sM
(va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRdx va_sM
(va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_blocks_wrapped va_b0 va_s0 alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b expected_tag =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5;
va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14;
va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12;
va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp;
va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx;
va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks_wrapped va_mods alg offset auth_b abytes_b in128x6_b out128x6_b
in128_b out128_b inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b expected_tag in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks_wrapped alg offset) va_qc
va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 588 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 711 column 56 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 712 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 713 column 57 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 714 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 715 column 58 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet
6 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 718 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(plain_num_bytes < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 719 column 38 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRsi va_s0 < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 721 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 723 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let auth_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_s0)
abytes_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 724 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let auth_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0 (va_get_reg64 rRsi va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 725 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let plain_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 726 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let plain_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads) 0 plain_num_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 727 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let cipher_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 728 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let cipher_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads) 0 plain_num_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 737 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(l_and (l_and (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 auth_bytes < pow2_32)
(FStar.Seq.Base.length #Vale.Def.Types_s.nat8 plain_bytes < pow2_32)) (cipher_bytes ==
__proj__Mktuple2__item___1 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv
plain_bytes auth_bytes expected_tag))) (Vale.Def.Types_s.le_quad32_to_bytes (va_get_xmm 8
va_sM) == Vale.AES.GCM.gcm_decrypt_LE_tag alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE
key) iv plain_bytes auth_bytes))))))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_blocks_wrapped (alg:algorithm) (offset:int) (auth_b:buffer128) (abytes_b:buffer128)
(in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128) (out128_b:buffer128)
(inout_b:buffer128) (iv_b:buffer128) (iv:supported_iv_LE) (scratch_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (expected_tag:(seq nat8))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
sse_enabled /\ movbe_enabled /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 +
offset + 0) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 32) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 48) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 64) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) auth_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0) (va_get_reg64 rR8 va_s0) iv_b 1
(va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6
va_s0) in128x6_ptr in128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6 va_s0) out128x6_ptr out128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1
va_s0) in128_ptr in128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) out128_ptr out128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5
va_s0) inout_ptr inout_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128
(va_get_mem_heaplet 3 va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0)
hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\ (let iv_BE =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let h_LE =
Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
in iv_BE == Vale.AES.GCM_s.compute_iv_BE h_LE iv)) /\ (forall (va_x_mem:vale_heap)
(va_x_rax:nat64) (va_x_rbx:nat64) (va_x_rcx:nat64) (va_x_rdx:nat64) (va_x_rdi:nat64)
(va_x_rsi:nat64) (va_x_rbp:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64)
(va_x_r11:nat64) (va_x_r12:nat64) (va_x_r13:nat64) (va_x_r14:nat64) (va_x_r15:nat64)
(va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32)
(va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm9:quad32)
(va_x_xmm10:quad32) (va_x_xmm11:quad32) (va_x_xmm12:quad32) (va_x_xmm13:quad32)
(va_x_xmm14:quad32) (va_x_xmm15:quad32) (va_x_heap1:vale_heap) (va_x_heap2:vale_heap)
(va_x_heap3:vale_heap) (va_x_heap5:vale_heap) (va_x_heap6:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 6
va_x_heap6 (va_upd_mem_heaplet 5 va_x_heap5 (va_upd_mem_heaplet 3 va_x_heap3
(va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 15 va_x_xmm15
(va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12 (va_upd_xmm 11
va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (va_upd_xmm 8 va_x_xmm8
(va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4
(va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0
(va_upd_reg64 rR15 va_x_r15 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13
(va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10
(va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRbp va_x_rbp (va_upd_reg64
rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRcx
va_x_rcx (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem
va_s0))))))))))))))))))))))))))))))))))))) in va_get_ok va_sM /\ (let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in Vale.X64.Decls.modifies_buffer128 out128_b
(va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128
iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\
Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM) /\ Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0)
(va_get_mem_heaplet 5 va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b
(va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\
va_get_reg64 rRsi va_s0 < pow2_32 /\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0
(va_get_mem_heaplet 2 va_s0) in let auth_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_s0) abytes_b) in let auth_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
auth_raw_quads) 0 (va_get_reg64 rRsi va_s0) in let plain_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0)
in128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) in let plain_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
plain_raw_quads) 0 plain_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) in let cipher_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
cipher_raw_quads) 0 plain_num_bytes in l_and (l_and (l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.nat8 auth_bytes < pow2_32) (FStar.Seq.Base.length #Vale.Def.Types_s.nat8
plain_bytes < pow2_32)) (cipher_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq
Vale.Def.Types_s.nat8) #bool (Vale.AES.GCM_s.gcm_decrypt_LE alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes expected_tag)))
(Vale.Def.Types_s.le_quad32_to_bytes (va_get_xmm 8 va_sM) == Vale.AES.GCM.gcm_decrypt_LE_tag
alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) ==> va_k
va_sM (())))
val va_wpProof_Gcm_blocks_wrapped : alg:algorithm -> offset:int -> auth_b:buffer128 ->
abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 -> in128_b:buffer128 ->
out128_b:buffer128 -> inout_b:buffer128 -> iv_b:buffer128 -> iv:supported_iv_LE ->
scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> expected_tag:(seq nat8) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gcm_blocks_wrapped alg offset auth_b abytes_b in128x6_b
out128x6_b in128_b out128_b inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b
expected_tag va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks_wrapped alg offset)
([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3;
va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_blocks_wrapped alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b
inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b expected_tag va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_blocks_wrapped (va_code_Gcm_blocks_wrapped alg offset) va_s0
alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b iv scratch_b key
round_keys keys_b hkeys_b expected_tag in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM
(va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm
13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm
9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM
(va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM
(va_update_reg64 rRbp va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))))))))))))))))))))))))))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Stack.fsti.checked",
"Vale.X64.QuickCodes.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.InsVector.fsti.checked",
"Vale.X64.InsStack.fsti.checked",
"Vale.X64.InsMem.fsti.checked",
"Vale.X64.InsBasic.fsti.checked",
"Vale.X64.InsAes.fsti.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Lib.Meta.fsti.checked",
"Vale.Lib.Basic.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_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",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.X64.GHash.fsti.checked",
"Vale.AES.X64.GF128_Mul.fsti.checked",
"Vale.AES.X64.GCTR.fsti.checked",
"Vale.AES.X64.GCMencryptOpt.fsti.checked",
"Vale.AES.X64.AESopt2.fsti.checked",
"Vale.AES.X64.AESopt.fsti.checked",
"Vale.AES.X64.AESGCM.fsti.checked",
"Vale.AES.X64.AES.fsti.checked",
"Vale.AES.OptPublic.fsti.checked",
"Vale.AES.GHash_s.fst.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_s.fst.checked",
"Vale.AES.GCTR.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"Vale.AES.GCM.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_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.X64.GCMdecryptOpt.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Lib.Basic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"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.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_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": "Vale.Def.Types_s",
"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": "FStar.Seq",
"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.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"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.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_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": "Vale.Def.Types_s",
"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": "FStar.Seq",
"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.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 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": 60,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
alg: Vale.AES.AES_common_s.algorithm ->
offset: Prims.int ->
auth_b: Vale.X64.Memory.buffer128 ->
abytes_b: Vale.X64.Memory.buffer128 ->
in128x6_b: Vale.X64.Memory.buffer128 ->
out128x6_b: Vale.X64.Memory.buffer128 ->
in128_b: Vale.X64.Memory.buffer128 ->
out128_b: Vale.X64.Memory.buffer128 ->
inout_b: Vale.X64.Memory.buffer128 ->
iv_b: Vale.X64.Memory.buffer128 ->
iv: Vale.AES.GCM_s.supported_iv_LE ->
scratch_b: Vale.X64.Memory.buffer128 ->
key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 ->
round_keys: FStar.Seq.Base.seq Vale.X64.Decls.quad32 ->
keys_b: Vale.X64.Memory.buffer128 ->
hkeys_b: Vale.X64.Memory.buffer128 ->
expected_tag: FStar.Seq.Base.seq Vale.X64.Memory.nat8
-> Vale.X64.QuickCode.va_quickCode Prims.unit
(Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_blocks_wrapped alg offset) | Prims.Tot | [
"total"
] | [] | [
"Vale.AES.AES_common_s.algorithm",
"Prims.int",
"Vale.X64.Memory.buffer128",
"Vale.AES.GCM_s.supported_iv_LE",
"FStar.Seq.Base.seq",
"Vale.X64.Memory.nat32",
"Vale.X64.Decls.quad32",
"Vale.X64.Memory.nat8",
"Vale.X64.QuickCode.va_QProc",
"Prims.unit",
"Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_blocks_wrapped",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_Mod_flags",
"Vale.X64.QuickCode.va_Mod_mem_heaplet",
"Vale.X64.QuickCode.va_Mod_xmm",
"Vale.X64.QuickCode.va_Mod_reg64",
"Vale.X64.Machine_s.rR15",
"Vale.X64.Machine_s.rR14",
"Vale.X64.Machine_s.rR13",
"Vale.X64.Machine_s.rR12",
"Vale.X64.Machine_s.rR11",
"Vale.X64.Machine_s.rR10",
"Vale.X64.Machine_s.rR9",
"Vale.X64.Machine_s.rR8",
"Vale.X64.Machine_s.rRbp",
"Vale.X64.Machine_s.rRsi",
"Vale.X64.Machine_s.rRdi",
"Vale.X64.Machine_s.rRdx",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.Machine_s.rRax",
"Vale.X64.QuickCode.va_Mod_mem",
"Prims.Nil",
"Vale.AES.X64.GCMdecryptOpt.va_wp_Gcm_blocks_wrapped",
"Vale.AES.X64.GCMdecryptOpt.va_wpProof_Gcm_blocks_wrapped",
"Vale.X64.QuickCode.va_quickCode"
] | [] | false | false | false | false | false | let va_quick_Gcm_blocks_wrapped
(alg: algorithm)
(offset: int)
(auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b: buffer128)
(iv: supported_iv_LE)
(scratch_b: buffer128)
(key: (seq nat32))
(round_keys: (seq quad32))
(keys_b hkeys_b: buffer128)
(expected_tag: (seq nat8))
: (va_quickCode unit (va_code_Gcm_blocks_wrapped alg offset)) =
| (va_QProc (va_code_Gcm_blocks_wrapped alg offset)
([
va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3;
va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12;
va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp;
va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx;
va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem
])
(va_wp_Gcm_blocks_wrapped alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b
inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b expected_tag)
(va_wpProof_Gcm_blocks_wrapped alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b
inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b expected_tag)) | false |
Vale.AES.X64.GCMdecryptOpt.fst | Vale.AES.X64.GCMdecryptOpt.va_lemma_Gcm_extra_bytes | val va_lemma_Gcm_extra_bytes : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
inout_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> total_bytes:nat -> old_hash:quad32 -> completed_quads:(seq quad32) ->
h_LE:quad32
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_extra_bytes alg) va_s0 /\ va_get_ok va_s0 /\ (let
(len:(va_int_range 1 1)) = 1 in sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b
inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b inout_b /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax va_s0) inout_b
len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys
keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0
va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32
(Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length
#quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply`
FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes
`op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16
`op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
(Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads =
FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0)
inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes =
Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) /\ va_state_eq va_sM
(va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM (va_update_ok va_sM
(va_update_mem va_sM va_s0)))))))))))))))))) | val va_lemma_Gcm_extra_bytes : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
inout_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> total_bytes:nat -> old_hash:quad32 -> completed_quads:(seq quad32) ->
h_LE:quad32
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_extra_bytes alg) va_s0 /\ va_get_ok va_s0 /\ (let
(len:(va_int_range 1 1)) = 1 in sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b
inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b inout_b /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax va_s0) inout_b
len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys
keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0
va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32
(Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length
#quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply`
FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes
`op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16
`op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
(Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads =
FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0)
inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes =
Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) /\ va_state_eq va_sM
(va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM (va_update_ok va_sM
(va_update_mem va_sM va_s0)))))))))))))))))) | let va_lemma_Gcm_extra_bytes va_b0 va_s0 alg inout_b key round_keys keys_b hkeys_b total_bytes
old_hash completed_quads h_LE =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_extra_bytes va_mods alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_extra_bytes alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 121 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (len:(va_int_range 1 1)) = 1 in label va_range1
"***** POSTCONDITION NOT MET AT line 174 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 177 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg len (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0)) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 180 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let raw_quads = FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 181 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 182 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 183 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let input_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 186 column 59 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(l_and (FStar.Seq.Base.length #Vale.Def.Types_s.quad32 input_quads > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE old_hash input_quads)))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm
7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM) | {
"file_name": "obj/Vale.AES.X64.GCMdecryptOpt.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 192,
"start_col": 0,
"start_line": 156
} | module Vale.AES.X64.GCMdecryptOpt
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open FStar.Seq
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_s
open Vale.AES.GCTR_s
open Vale.AES.GCTR
open Vale.AES.GCM
open Vale.AES.GHash_s
open Vale.AES.GHash
open Vale.AES.GCM_s
open Vale.AES.X64.AES
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.Poly1305.Math
open Vale.AES.GCM_helpers
open Vale.AES.X64.GHash
open Vale.AES.X64.GCTR
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.X64.Stack_i
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.InsBasic
open Vale.X64.InsMem
open Vale.X64.InsVector
open Vale.X64.InsStack
open Vale.X64.InsAes
open Vale.X64.QuickCode
open Vale.X64.QuickCodes
open Vale.AES.X64.GF128_Mul
open Vale.X64.Stack
open Vale.X64.CPU_Features_s
open Vale.Math.Poly2.Bits_s
open Vale.AES.X64.AESopt
open Vale.AES.X64.AESGCM
open Vale.AES.X64.AESopt2
open Vale.Lib.Meta
open Vale.AES.X64.GCMencryptOpt
open Vale.AES.OptPublic
open Vale.Lib.Basic
#reset-options "--z3rlimit 20 --max_ifuel 0"
//-- Gcm_extra_bytes
val va_code_Gcm_extra_bytes : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_extra_bytes alg =
(va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0)
(va_op_reg_opr64_reg64 rRax) 0 Secret) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 10)
(va_op_xmm_xmm 0)) (va_CCons (va_code_Ghash_extra_bytes ()) (va_CCons (va_code_Mov128
(va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_CCons (va_code_Pshufb (va_op_xmm_xmm 0)
(va_op_xmm_xmm 9)) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons (va_code_Pxor
(va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_CCons (va_code_Store128_buffer
(va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret)
(va_CNil ()))))))))))
val va_codegen_success_Gcm_extra_bytes : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_extra_bytes alg =
(va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0)
(va_op_reg_opr64_reg64 rRax) 0 Secret) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm
10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Ghash_extra_bytes ()) (va_pbool_and
(va_codegen_success_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_pbool_and
(va_codegen_success_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and
(va_codegen_success_AESEncryptBlock alg) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm
10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Store128_buffer
(va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret)
(va_ttrue ())))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_extra_bytes (va_mods:va_mods_t) (alg:algorithm) (inout_b:buffer128) (key:(seq
nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat)
(old_hash:quad32) (completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit
(va_code_Gcm_extra_bytes alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (len:(va_int_range
1 1)) = 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 188 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRax) 0 Secret inout_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 189 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (fun (va_s:va_state) _ -> let
(hash_input:quad32) = va_get_xmm 0 va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 193 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_extra_bytes hkeys_b total_bytes old_hash h_LE completed_quads) (fun
(va_s:va_state) _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 194 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.equal #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s)
inout_b) (FStar.Seq.Base.create #quad32 1 hash_input)) (let (snap:(FStar.Seq.Base.seq
Vale.X64.Decls.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 198 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 199 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 200 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AESEncryptBlock alg (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 11 va_s)) key
round_keys keys_b) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 201 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.AES_s.aes_encrypt_LE_reveal ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 204 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 205 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax)
(va_op_xmm_xmm 10) 0 Secret inout_b 0) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 207 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.gctr_partial_reveal ()) (va_QEmpty (()))))))))))))))
val va_lemma_Gcm_extra_bytes : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
inout_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> total_bytes:nat -> old_hash:quad32 -> completed_quads:(seq quad32) ->
h_LE:quad32
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_extra_bytes alg) va_s0 /\ va_get_ok va_s0 /\ (let
(len:(va_int_range 1 1)) = 1 in sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b
inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b inout_b /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax va_s0) inout_b
len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys
keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0
va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32
(Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length
#quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply`
FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes
`op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16
`op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
(Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads =
FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0)
inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes =
Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) /\ va_state_eq va_sM
(va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM (va_update_ok va_sM
(va_update_mem va_sM va_s0)))))))))))))))))) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Stack.fsti.checked",
"Vale.X64.QuickCodes.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.InsVector.fsti.checked",
"Vale.X64.InsStack.fsti.checked",
"Vale.X64.InsMem.fsti.checked",
"Vale.X64.InsBasic.fsti.checked",
"Vale.X64.InsAes.fsti.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Lib.Meta.fsti.checked",
"Vale.Lib.Basic.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_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",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.X64.GHash.fsti.checked",
"Vale.AES.X64.GF128_Mul.fsti.checked",
"Vale.AES.X64.GCTR.fsti.checked",
"Vale.AES.X64.GCMencryptOpt.fsti.checked",
"Vale.AES.X64.AESopt2.fsti.checked",
"Vale.AES.X64.AESopt.fsti.checked",
"Vale.AES.X64.AESGCM.fsti.checked",
"Vale.AES.X64.AES.fsti.checked",
"Vale.AES.OptPublic.fsti.checked",
"Vale.AES.GHash_s.fst.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_s.fst.checked",
"Vale.AES.GCTR.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"Vale.AES.GCM.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_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.X64.GCMdecryptOpt.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Lib.Basic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"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.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_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": "Vale.Def.Types_s",
"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": "FStar.Seq",
"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.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"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.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_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": "Vale.Def.Types_s",
"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": "FStar.Seq",
"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.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
va_b0: Vale.X64.Decls.va_code ->
va_s0: Vale.X64.Decls.va_state ->
alg: Vale.AES.AES_common_s.algorithm ->
inout_b: Vale.X64.Memory.buffer128 ->
key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 ->
round_keys: FStar.Seq.Base.seq Vale.X64.Decls.quad32 ->
keys_b: Vale.X64.Memory.buffer128 ->
hkeys_b: Vale.X64.Memory.buffer128 ->
total_bytes: Prims.nat ->
old_hash: Vale.X64.Decls.quad32 ->
completed_quads: FStar.Seq.Base.seq Vale.X64.Decls.quad32 ->
h_LE: Vale.X64.Decls.quad32
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | Prims.Ghost | [] | [] | [
"Vale.X64.Decls.va_code",
"Vale.X64.Decls.va_state",
"Vale.AES.AES_common_s.algorithm",
"Vale.X64.Memory.buffer128",
"FStar.Seq.Base.seq",
"Vale.X64.Memory.nat32",
"Vale.X64.Decls.quad32",
"Prims.nat",
"Vale.X64.QuickCodes.fuel",
"Prims.unit",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Decls.va_fuel",
"Vale.X64.QuickCode.va_lemma_norm_mods",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_Mod_flags",
"Vale.X64.QuickCode.va_Mod_mem_heaplet",
"Vale.X64.QuickCode.va_Mod_xmm",
"Vale.X64.QuickCode.va_Mod_reg64",
"Vale.X64.Machine_s.rR11",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.QuickCode.va_Mod_ok",
"Vale.X64.QuickCode.va_Mod_mem",
"Prims.Nil",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.list",
"Vale.X64.QuickCode.__proj__QProc__item__mods",
"Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_extra_bytes",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.tuple3",
"Vale.X64.State.vale_state",
"Vale.X64.QuickCodes.va_wp_sound_code_norm",
"Prims.l_and",
"Vale.X64.QuickCodes.label",
"Vale.X64.QuickCodes.va_range1",
"Prims.b2t",
"Vale.X64.Decls.va_get_ok",
"Vale.X64.Decls.modifies_buffer128",
"Vale.X64.Decls.va_get_mem_heaplet",
"Vale.AES.GCTR.gctr_partial",
"Vale.X64.Decls.s128",
"Vale.X64.Decls.va_get_xmm",
"Prims.op_GreaterThan",
"FStar.Seq.Base.length",
"Vale.Def.Types_s.quad32",
"Vale.Def.Types_s.reverse_bytes_quad32",
"Vale.AES.GHash.ghash_incremental",
"Vale.Def.Types_s.le_bytes_to_seq_quad32",
"Vale.Def.Words_s.nat8",
"Vale.AES.GCTR_s.pad_to_128_bits",
"FStar.Seq.Base.slice",
"Vale.Def.Types_s.nat8",
"Vale.Def.Types_s.le_seq_quad32_to_bytes",
"FStar.Seq.Base.append",
"Vale.X64.Decls.va_int_range",
"Vale.X64.QuickCode.quickCode",
"Vale.AES.X64.GCMdecryptOpt.va_qcode_Gcm_extra_bytes"
] | [] | false | false | false | false | false | let va_lemma_Gcm_extra_bytes
va_b0
va_s0
alg
inout_b
key
round_keys
keys_b
hkeys_b
total_bytes
old_hash
completed_quads
h_LE
=
| let va_mods:va_mods_t =
[
va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6;
va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0;
va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem
]
in
let va_qc =
va_qcode_Gcm_extra_bytes va_mods alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash
completed_quads h_LE
in
let va_sM, va_fM, va_g =
va_wp_sound_code_norm (va_code_Gcm_extra_bytes alg)
va_qc
va_s0
(fun va_s0 va_sM va_g ->
let () = va_g in
label va_range1
"***** POSTCONDITION NOT MET AT line 121 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\
(let len:(va_int_range 1 1) = 1 in
label va_range1
"***** POSTCONDITION NOT MET AT line 174 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0)
(va_get_mem_heaplet 5 va_sM)) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 177 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg
len
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b)
key
(va_get_xmm 11 va_s0)) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 180 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let raw_quads =
FStar.Seq.Base.append #quad32
completed_quads
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b)
in
label va_range1
"***** POSTCONDITION NOT MET AT line 181 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let input_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads)
0
total_bytes
in
label va_range1
"***** POSTCONDITION NOT MET AT line 182 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in
label va_range1
"***** POSTCONDITION NOT MET AT line 183 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let input_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in
label va_range1
"***** POSTCONDITION NOT MET AT line 186 column 59 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(l_and (FStar.Seq.Base.length #Vale.Def.Types_s.quad32 input_quads > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) ==
Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))))))))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([
va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6;
va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0;
va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem
])
va_sM
va_s0;
(va_sM, va_fM) | false |
Spec.Box.fst | Spec.Box.ecdh | val ecdh (pk: publickey) (sk: secretkey) : option secretkey | val ecdh (pk: publickey) (sk: secretkey) : option secretkey | let ecdh (pk:publickey) (sk:secretkey) : option secretkey =
let shared = Spec.Curve25519.scalarmult sk pk in
if not (lbytes_eq shared (create 32 (u8 0))) then
Some shared
else None | {
"file_name": "specs/Spec.Box.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 11,
"end_line": 24,
"start_col": 0,
"start_line": 20
} | module Spec.Box
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.SecretBox
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
(* Constants *)
let size_publickey = 32 (* in bytes *)
let size_secretkey = 32 (* in bytes *)
type publickey = lbytes size_publickey
type secretkey = lbytes size_secretkey | {
"checked_file": "/",
"dependencies": [
"Spec.SecretBox.fst.checked",
"Spec.Salsa20.fst.checked",
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Box.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.SecretBox",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | pk: Spec.Box.publickey -> sk: Spec.Box.secretkey
-> FStar.Pervasives.Native.option Spec.Box.secretkey | Prims.Tot | [
"total"
] | [] | [
"Spec.Box.publickey",
"Spec.Box.secretkey",
"Prims.op_Negation",
"Lib.ByteSequence.lbytes_eq",
"Lib.Sequence.create",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.IntTypes.u8",
"FStar.Pervasives.Native.Some",
"Prims.bool",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option",
"Spec.Curve25519.serialized_point",
"Spec.Curve25519.scalarmult"
] | [] | false | false | false | true | false | let ecdh (pk: publickey) (sk: secretkey) : option secretkey =
| let shared = Spec.Curve25519.scalarmult sk pk in
if not (lbytes_eq shared (create 32 (u8 0))) then Some shared else None | false |
Spec.Box.fst | Spec.Box.box_beforenm | val box_beforenm (pk: publickey) (sk: secretkey) : option key | val box_beforenm (pk: publickey) (sk: secretkey) : option key | let box_beforenm (pk:publickey) (sk:secretkey) : option key =
let shared = ecdh pk sk in
match shared with
| Some shared -> Some (Spec.Salsa20.hsalsa20 shared (create 16 (u8 0)))
| None -> None | {
"file_name": "specs/Spec.Box.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 31,
"start_col": 0,
"start_line": 27
} | module Spec.Box
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.SecretBox
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
(* Constants *)
let size_publickey = 32 (* in bytes *)
let size_secretkey = 32 (* in bytes *)
type publickey = lbytes size_publickey
type secretkey = lbytes size_secretkey
let ecdh (pk:publickey) (sk:secretkey) : option secretkey =
let shared = Spec.Curve25519.scalarmult sk pk in
if not (lbytes_eq shared (create 32 (u8 0))) then
Some shared
else None | {
"checked_file": "/",
"dependencies": [
"Spec.SecretBox.fst.checked",
"Spec.Salsa20.fst.checked",
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Box.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.SecretBox",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | pk: Spec.Box.publickey -> sk: Spec.Box.secretkey
-> FStar.Pervasives.Native.option Spec.SecretBox.key | Prims.Tot | [
"total"
] | [] | [
"Spec.Box.publickey",
"Spec.Box.secretkey",
"FStar.Pervasives.Native.Some",
"Spec.SecretBox.key",
"Spec.Salsa20.hsalsa20",
"Lib.Sequence.create",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.IntTypes.u8",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option",
"Spec.Box.ecdh"
] | [] | false | false | false | true | false | let box_beforenm (pk: publickey) (sk: secretkey) : option key =
| let shared = ecdh pk sk in
match shared with
| Some shared -> Some (Spec.Salsa20.hsalsa20 shared (create 16 (u8 0)))
| None -> None | false |
Spec.Box.fst | Spec.Box.box_open_detached | val box_open_detached
(pk: publickey)
(sk: secretkey)
(n: nonce)
(t: tag)
(c: bytes{length c / size_block <= max_size_t})
: option (m: bytes{length m = length c}) | val box_open_detached
(pk: publickey)
(sk: secretkey)
(n: nonce)
(t: tag)
(c: bytes{length c / size_block <= max_size_t})
: option (m: bytes{length m = length c}) | let box_open_detached (pk:publickey) (sk:secretkey) (n:nonce) (t:tag) (c:bytes{length c / size_block <= max_size_t}) : option (m:bytes{length m = length c}) =
let k = box_beforenm pk sk in
match k with
| Some k -> box_open_detached_afternm k n t c
| None -> None | {
"file_name": "specs/Spec.Box.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 53,
"start_col": 0,
"start_line": 49
} | module Spec.Box
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.SecretBox
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
(* Constants *)
let size_publickey = 32 (* in bytes *)
let size_secretkey = 32 (* in bytes *)
type publickey = lbytes size_publickey
type secretkey = lbytes size_secretkey
let ecdh (pk:publickey) (sk:secretkey) : option secretkey =
let shared = Spec.Curve25519.scalarmult sk pk in
if not (lbytes_eq shared (create 32 (u8 0))) then
Some shared
else None
let box_beforenm (pk:publickey) (sk:secretkey) : option key =
let shared = ecdh pk sk in
match shared with
| Some shared -> Some (Spec.Salsa20.hsalsa20 shared (create 16 (u8 0)))
| None -> None
let box_detached_afternm (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : tag & c:bytes{length c = length m} =
secretbox_detached k n m
let box_detached (sk:secretkey) (pk:publickey) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : option (tag & c:bytes{length c = length m}) =
let k = box_beforenm pk sk in
match k with
| Some k -> Some (box_detached_afternm k n m)
| None -> None
let box_open_detached_afternm (k:key) (n:nonce) (t:tag) (c:bytes{length c / size_block <= max_size_t}) : option (m:bytes{length m = length c}) =
secretbox_open_detached k n t c | {
"checked_file": "/",
"dependencies": [
"Spec.SecretBox.fst.checked",
"Spec.Salsa20.fst.checked",
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Box.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.SecretBox",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
pk: Spec.Box.publickey ->
sk: Spec.Box.secretkey ->
n: Spec.SecretBox.nonce ->
t: Spec.SecretBox.tag ->
c:
Lib.ByteSequence.bytes
{Lib.Sequence.length c / Spec.SecretBox.size_block <= Lib.IntTypes.max_size_t}
-> FStar.Pervasives.Native.option (m:
Lib.ByteSequence.bytes{Lib.Sequence.length m = Lib.Sequence.length c}) | Prims.Tot | [
"total"
] | [] | [
"Spec.Box.publickey",
"Spec.Box.secretkey",
"Spec.SecretBox.nonce",
"Spec.SecretBox.tag",
"Lib.ByteSequence.bytes",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Division",
"Lib.Sequence.length",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.SecretBox.size_block",
"Lib.IntTypes.max_size_t",
"Spec.SecretBox.key",
"Spec.Box.box_open_detached_afternm",
"FStar.Pervasives.Native.None",
"Prims.op_Equality",
"Prims.nat",
"FStar.Pervasives.Native.option",
"Spec.Box.box_beforenm"
] | [] | false | false | false | false | false | let box_open_detached
(pk: publickey)
(sk: secretkey)
(n: nonce)
(t: tag)
(c: bytes{length c / size_block <= max_size_t})
: option (m: bytes{length m = length c}) =
| let k = box_beforenm pk sk in
match k with
| Some k -> box_open_detached_afternm k n t c
| None -> None | false |
Spec.Box.fst | Spec.Box.box_detached | val box_detached
(sk: secretkey)
(pk: publickey)
(n: nonce)
(m: bytes{length m / size_block <= max_size_t})
: option (tag & c: bytes{length c = length m}) | val box_detached
(sk: secretkey)
(pk: publickey)
(n: nonce)
(m: bytes{length m / size_block <= max_size_t})
: option (tag & c: bytes{length c = length m}) | let box_detached (sk:secretkey) (pk:publickey) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : option (tag & c:bytes{length c = length m}) =
let k = box_beforenm pk sk in
match k with
| Some k -> Some (box_detached_afternm k n m)
| None -> None | {
"file_name": "specs/Spec.Box.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 42,
"start_col": 0,
"start_line": 38
} | module Spec.Box
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.SecretBox
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
(* Constants *)
let size_publickey = 32 (* in bytes *)
let size_secretkey = 32 (* in bytes *)
type publickey = lbytes size_publickey
type secretkey = lbytes size_secretkey
let ecdh (pk:publickey) (sk:secretkey) : option secretkey =
let shared = Spec.Curve25519.scalarmult sk pk in
if not (lbytes_eq shared (create 32 (u8 0))) then
Some shared
else None
let box_beforenm (pk:publickey) (sk:secretkey) : option key =
let shared = ecdh pk sk in
match shared with
| Some shared -> Some (Spec.Salsa20.hsalsa20 shared (create 16 (u8 0)))
| None -> None
let box_detached_afternm (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : tag & c:bytes{length c = length m} =
secretbox_detached k n m | {
"checked_file": "/",
"dependencies": [
"Spec.SecretBox.fst.checked",
"Spec.Salsa20.fst.checked",
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Box.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.SecretBox",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
sk: Spec.Box.secretkey ->
pk: Spec.Box.publickey ->
n: Spec.SecretBox.nonce ->
m:
Lib.ByteSequence.bytes
{Lib.Sequence.length m / Spec.SecretBox.size_block <= Lib.IntTypes.max_size_t}
-> FStar.Pervasives.Native.option (Spec.SecretBox.tag *
c:
Lib.ByteSequence.bytes{Lib.Sequence.length c = Lib.Sequence.length m}) | Prims.Tot | [
"total"
] | [] | [
"Spec.Box.secretkey",
"Spec.Box.publickey",
"Spec.SecretBox.nonce",
"Lib.ByteSequence.bytes",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Division",
"Lib.Sequence.length",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.SecretBox.size_block",
"Lib.IntTypes.max_size_t",
"Spec.SecretBox.key",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.tuple2",
"Spec.SecretBox.tag",
"Prims.op_Equality",
"Prims.nat",
"Spec.Box.box_detached_afternm",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option",
"Spec.Box.box_beforenm"
] | [] | false | false | false | false | false | let box_detached
(sk: secretkey)
(pk: publickey)
(n: nonce)
(m: bytes{length m / size_block <= max_size_t})
: option (tag & c: bytes{length c = length m}) =
| let k = box_beforenm pk sk in
match k with
| Some k -> Some (box_detached_afternm k n m)
| None -> None | false |
LowStar.Lib.LinkedList.fst | LowStar.Lib.LinkedList.cells | val cells (#a: _) (h: HS.mem) (c: t a) (l: list a)
: Ghost (list (B.pointer (cell a)))
(requires well_formed h c l)
(ensures fun _ -> True)
(decreases l) | val cells (#a: _) (h: HS.mem) (c: t a) (l: list a)
: Ghost (list (B.pointer (cell a)))
(requires well_formed h c l)
(ensures fun _ -> True)
(decreases l) | let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a)))
(requires well_formed h c l)
(ensures fun _ -> True)
(decreases l)
=
if B.g_is_null c then
[]
else
c :: cells h (B.deref h c).next (List.Tot.tl l) | {
"file_name": "krmllib/LowStar.Lib.LinkedList.fst",
"git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} | {
"end_col": 51,
"end_line": 93,
"start_col": 0,
"start_line": 85
} | module LowStar.Lib.LinkedList
/// This module, oftentimes referred to as LL1 in other parts of the
/// documentation, provides a low-level view over a linked list. Unless you
/// intend on modifying the structure of the linked list (e.g. removing cells)
/// or iterating over each cell, your are probably better off using LL2.
///
/// This module is intentionally not relying on a tight abstraction, to i) permit
/// direct-style iteration by clients and ii) allow stating some SMTPat lemmas
/// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can
/// happen automatically at the SMT level since LL2 does not have an fsti either).
///
/// Some open questions relative to the design of this module:
/// - should ``v`` be defined directly in terms of ``cells`` rather than have a
/// recursive definition along with an equivalence lemma?
/// - should ``footprint`` be defined directly in terms of ``cells`` rather than
/// have a recursive definition along with an equivalence lemma?
/// - is it worth the trouble defining a footprint? my intuition is that it's
/// fine and allows some clients to do very precise reasoning -- other modules
/// (e.g. AssocList), when establishing abstraction boundaries, can simplify
/// things and get rid of the precise footprint reasoning in favor of a static
/// region-based footprint
///
/// Some remaining work items:
/// - switch to C.Loops.while
open LowStar.BufferOps
module B = LowStar.Buffer
module HS = FStar.HyperStack
module G = FStar.Ghost
module L = FStar.List.Tot
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
open FStar.HyperStack.ST
/// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since
/// everything does recursive list reasoning.
#set-options "--__no_positivity --fuel 1 --ifuel 1"
/// Definition of the Low* type
/// ---------------------------
noeq
type t (a: Type0) =
B.pointer_or_null (cell a)
and cell (a: Type0) = {
next: t a;
data: a;
}
/// Unlike the canonical style that associates a ``v`` function to any stateful
/// representation, we use a relation here. Writing a function is just
/// impossible, since we can't prove termination of ``v`` owing to the fact that
/// there may be an infinite number of cells in the heap.
///
/// LL2 is the module that switches to the function style.
///
/// Note: no need to use erased here for ``l`` since the function is already in ``GTot``.
let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) =
B.live h c /\ (
match l with
| [] ->
B.g_is_null c
| a :: q ->
B.length c == 1 /\ (
let { data=data; next=next } = B.get h c 0 in
a == data /\
well_formed h next (G.hide q)
))
/// Precise reasoning via the cells predicate
/// -----------------------------------------
///
/// The modifies clauses are given either on the footprint of the list, or on a
/// region that includes the footprint of the list (higher up the stack, e.g.
/// LL2). This is good, but does not rule out "stupid" implementations that
/// might re-allocate every single list cell when, say, doing a pop.
///
/// For advanced usages which take pointers directly to individual list cells,
/// it's important to rule out these cases. We thus define the ``cells``
/// predicate for that purpose. | {
"checked_file": "/",
"dependencies": [
"TestLib.fsti.checked",
"prims.fst.checked",
"LowStar.Failure.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int32.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Lib.LinkedList.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> c: LowStar.Lib.LinkedList.t a -> l: Prims.list a
-> Prims.Ghost (Prims.list (LowStar.Buffer.pointer (LowStar.Lib.LinkedList.cell a))) | Prims.Ghost | [
""
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"LowStar.Lib.LinkedList.t",
"Prims.list",
"LowStar.Monotonic.Buffer.g_is_null",
"LowStar.Lib.LinkedList.cell",
"LowStar.Buffer.trivial_preorder",
"Prims.Nil",
"LowStar.Buffer.pointer",
"Prims.bool",
"Prims.Cons",
"LowStar.Lib.LinkedList.cells",
"LowStar.Lib.LinkedList.__proj__Mkcell__item__next",
"LowStar.Monotonic.Buffer.deref",
"FStar.List.Tot.Base.tl",
"LowStar.Lib.LinkedList.well_formed",
"Prims.l_True"
] | [
"recursion"
] | false | false | false | false | false | let rec cells #a (h: HS.mem) (c: t a) (l: list a)
: Ghost (list (B.pointer (cell a)))
(requires well_formed h c l)
(ensures fun _ -> True)
(decreases l) =
| if B.g_is_null c then [] else c :: cells h (B.deref h c).next (List.Tot.tl l) | false |
Steel.GhostPCMReference.fst | Steel.GhostPCMReference.gather | val gather (#o:inames)
(#a:Type)
(#p:FStar.PCM.pcm a)
(r:ref a p)
(v0:a)
(v1:a)
: SteelGhostT (_:unit{composable p v0 v1}) o
(pts_to r v0 `star` pts_to r v1)
(fun _ -> pts_to r (op p v0 v1)) | val gather (#o:inames)
(#a:Type)
(#p:FStar.PCM.pcm a)
(r:ref a p)
(v0:a)
(v1:a)
: SteelGhostT (_:unit{composable p v0 v1}) o
(pts_to r v0 `star` pts_to r v1)
(fun _ -> pts_to r (op p v0 v1)) | let gather (#o:inames)
(#a:Type)
(#p:FStar.PCM.pcm a)
(r:ref a p)
(v0:a)
(v1:a)
: SteelGhostT (_:unit{composable p v0 v1}) o
(pts_to r v0 `star` pts_to r v1)
(fun _ -> pts_to r (op p v0 v1))
= P.gather r v0 v1 | {
"file_name": "lib/steel/Steel.GhostPCMReference.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 20,
"end_line": 111,
"start_col": 0,
"start_line": 102
} | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.GhostPCMReference
(* A ghost variant of Steel.PCMReference *)
open FStar.PCM
open FStar.Ghost
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
module Mem = Steel.Memory
module P = Steel.PCMReference
let ref (a:Type) (p:pcm a) = erased (Steel.Memory.ref a p)
/// Its selector is non-informative (it is unit)
[@@__reduce__]
let pts_to (#a:Type u#1) (#pcm:pcm a) (r:ref a pcm) ([@@@smt_fallback]v:a)
= to_vprop (Steel.Memory.pts_to r v)
let alloc (#o:inames)
(#a:Type)
(#pcm:pcm a)
(x:a)
: SteelGhost
(ref a pcm) o
(emp)
(fun r -> pts_to r x)
(requires fun _ -> pcm.refine x)
(ensures fun _ _ _ -> True)
= rewrite_slprop emp (to_vprop Mem.emp) (fun _ -> reveal_emp ());
FStar.PCM.compatible_refl pcm x;
let r = as_atomic_action_ghost (alloc_action o x) in
r
let read (#o:inames)
(#a:Type)
(#pcm:pcm a)
(#v0:a)
(r:ref a pcm)
: SteelGhost a o
(pts_to r v0)
(fun _ -> pts_to r v0)
(requires fun _ -> True)
(ensures fun _ v _ -> compatible pcm v0 v)
= let v = as_atomic_action_ghost (sel_action o r v0) in
v
let write (#o:inames)
(#a:Type)
(#pcm:pcm a)
(r:ref a pcm)
(v0:a)
(v1:a)
: SteelGhost unit o
(pts_to r v0)
(fun _ -> pts_to r v1)
(requires fun _ -> frame_preserving pcm v0 v1 /\ pcm.refine v1)
(ensures fun _ _ _ -> True)
= as_atomic_action_ghost (upd_action o r v0 v1)
let upd_gen (#o:inames)
(#a:Type)
(#p:pcm a)
(r:ref a p)
(x y:a)
(f:frame_preserving_upd p x y)
: SteelGhostT unit o
(pts_to r x)
(fun _ -> pts_to r y)
= as_atomic_action_ghost (Steel.Memory.upd_gen o r x y f)
let share (#o:inames)
(#a:Type)
(#p:pcm a)
(r:ref a p)
(v:a)
(v0:a)
(v1:a)
: SteelGhost unit o
(pts_to r v)
(fun _ -> pts_to r v0 `star` pts_to r v1)
(requires fun _ ->
composable p v0 v1 /\
v == op p v0 v1)
(ensures fun _ _ _ -> True)
= P.split r v v0 v1 | {
"checked_file": "/",
"dependencies": [
"Steel.Preorder.fst.checked",
"Steel.PCMReference.fsti.checked",
"Steel.Memory.fsti.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.PCM.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Steel.GhostPCMReference.fst"
} | [
{
"abbrev": true,
"full_module": "Steel.PCMReference",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.PCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | r: Steel.GhostPCMReference.ref a p -> v0: a -> v1: a
-> Steel.Effect.Atomic.SteelGhostT (_: Prims.unit{FStar.PCM.composable p v0 v1}) | Steel.Effect.Atomic.SteelGhostT | [] | [] | [
"Steel.Memory.inames",
"FStar.PCM.pcm",
"Steel.GhostPCMReference.ref",
"Steel.PCMReference.gather",
"FStar.Ghost.reveal",
"Steel.Memory.ref",
"FStar.Ghost.hide",
"Prims.unit",
"FStar.PCM.composable",
"Steel.Effect.Common.star",
"Steel.GhostPCMReference.pts_to",
"FStar.PCM.op",
"Steel.Effect.Common.vprop"
] | [] | false | true | false | false | false | let gather (#o: inames) (#a: Type) (#p: FStar.PCM.pcm a) (r: ref a p) (v0 v1: a)
: SteelGhostT (_: unit{composable p v0 v1})
o
((pts_to r v0) `star` (pts_to r v1))
(fun _ -> pts_to r (op p v0 v1)) =
| P.gather r v0 v1 | false |
LowStar.Lib.LinkedList.fst | LowStar.Lib.LinkedList.footprint | val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc
(requires (well_formed h l n))
(ensures (fun refs -> True))
(decreases n) | val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc
(requires (well_formed h l n))
(ensures (fun refs -> True))
(decreases n) | let rec footprint #a h l n =
if B.g_is_null l
then B.loc_none
else
let {next = next} = B.get h l 0 in
let refs = footprint h next (G.hide (L.tl n)) in
B.loc_union (B.loc_addr_of_buffer l) refs | {
"file_name": "krmllib/LowStar.Lib.LinkedList.fst",
"git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} | {
"end_col": 45,
"end_line": 141,
"start_col": 0,
"start_line": 135
} | module LowStar.Lib.LinkedList
/// This module, oftentimes referred to as LL1 in other parts of the
/// documentation, provides a low-level view over a linked list. Unless you
/// intend on modifying the structure of the linked list (e.g. removing cells)
/// or iterating over each cell, your are probably better off using LL2.
///
/// This module is intentionally not relying on a tight abstraction, to i) permit
/// direct-style iteration by clients and ii) allow stating some SMTPat lemmas
/// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can
/// happen automatically at the SMT level since LL2 does not have an fsti either).
///
/// Some open questions relative to the design of this module:
/// - should ``v`` be defined directly in terms of ``cells`` rather than have a
/// recursive definition along with an equivalence lemma?
/// - should ``footprint`` be defined directly in terms of ``cells`` rather than
/// have a recursive definition along with an equivalence lemma?
/// - is it worth the trouble defining a footprint? my intuition is that it's
/// fine and allows some clients to do very precise reasoning -- other modules
/// (e.g. AssocList), when establishing abstraction boundaries, can simplify
/// things and get rid of the precise footprint reasoning in favor of a static
/// region-based footprint
///
/// Some remaining work items:
/// - switch to C.Loops.while
open LowStar.BufferOps
module B = LowStar.Buffer
module HS = FStar.HyperStack
module G = FStar.Ghost
module L = FStar.List.Tot
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
open FStar.HyperStack.ST
/// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since
/// everything does recursive list reasoning.
#set-options "--__no_positivity --fuel 1 --ifuel 1"
/// Definition of the Low* type
/// ---------------------------
noeq
type t (a: Type0) =
B.pointer_or_null (cell a)
and cell (a: Type0) = {
next: t a;
data: a;
}
/// Unlike the canonical style that associates a ``v`` function to any stateful
/// representation, we use a relation here. Writing a function is just
/// impossible, since we can't prove termination of ``v`` owing to the fact that
/// there may be an infinite number of cells in the heap.
///
/// LL2 is the module that switches to the function style.
///
/// Note: no need to use erased here for ``l`` since the function is already in ``GTot``.
let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) =
B.live h c /\ (
match l with
| [] ->
B.g_is_null c
| a :: q ->
B.length c == 1 /\ (
let { data=data; next=next } = B.get h c 0 in
a == data /\
well_formed h next (G.hide q)
))
/// Precise reasoning via the cells predicate
/// -----------------------------------------
///
/// The modifies clauses are given either on the footprint of the list, or on a
/// region that includes the footprint of the list (higher up the stack, e.g.
/// LL2). This is good, but does not rule out "stupid" implementations that
/// might re-allocate every single list cell when, say, doing a pop.
///
/// For advanced usages which take pointers directly to individual list cells,
/// it's important to rule out these cases. We thus define the ``cells``
/// predicate for that purpose.
let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a)))
(requires well_formed h c l)
(ensures fun _ -> True)
(decreases l)
=
if B.g_is_null c then
[]
else
c :: cells h (B.deref h c).next (List.Tot.tl l)
/// A missing bit of automated reasoning
/// ------------------------------------
/// This should be absolutely trivial, yet, because there's no pattern on
/// null_unique, we have to do the case analysis and the decomposition
/// ourselves. This is quite tedious, as it usually takes a while (at least it
/// did for me!) to realize that this property does not hold automatically.
///
/// I'm setting an SMTPat on this lemma because it's absolutely impossible to
/// get any work done without it.
let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma
(requires (
well_formed h0 ll0 l0 /\
well_formed h1 ll1 l1 /\
cells h0 ll0 l0 == cells h1 ll1 l1))
(ensures (
ll0 == ll1))
[ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ]
=
if B.g_is_null ll0 && B.g_is_null ll1 then begin
B.null_unique ll0;
B.null_unique ll1
end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin
()
end else
false_elim ()
/// Classic stateful reasoning lemmas
/// ---------------------------------
///
/// This essentially follows ``stateful``, the type class of a mutable piece of
/// state defined using the modifies-theory of Low*v2 and equipped with the
/// right lemmas to enable usage by clients. See
/// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context.
val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc
(requires (well_formed h l n))
(ensures (fun refs -> True))
(decreases n) | {
"checked_file": "/",
"dependencies": [
"TestLib.fsti.checked",
"prims.fst.checked",
"LowStar.Failure.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int32.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Lib.LinkedList.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> l: LowStar.Lib.LinkedList.t a -> n: Prims.list a
-> Prims.Ghost LowStar.Monotonic.Buffer.loc | Prims.Ghost | [
""
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"LowStar.Lib.LinkedList.t",
"Prims.list",
"LowStar.Monotonic.Buffer.g_is_null",
"LowStar.Lib.LinkedList.cell",
"LowStar.Buffer.trivial_preorder",
"LowStar.Monotonic.Buffer.loc_none",
"Prims.bool",
"LowStar.Buffer.pointer_or_null",
"LowStar.Monotonic.Buffer.loc_union",
"LowStar.Monotonic.Buffer.loc_addr_of_buffer",
"LowStar.Monotonic.Buffer.loc",
"LowStar.Lib.LinkedList.footprint",
"FStar.List.Tot.Base.tl",
"LowStar.Monotonic.Buffer.get"
] | [
"recursion"
] | false | false | false | false | false | let rec footprint #a h l n =
| if B.g_is_null l
then B.loc_none
else
let { next = next } = B.get h l 0 in
let refs = footprint h next (G.hide (L.tl n)) in
B.loc_union (B.loc_addr_of_buffer l) refs | false |
Spec.Box.fst | Spec.Box.box_detached_afternm | val box_detached_afternm (k: key) (n: nonce) (m: bytes{length m / size_block <= max_size_t})
: tag & c: bytes{length c = length m} | val box_detached_afternm (k: key) (n: nonce) (m: bytes{length m / size_block <= max_size_t})
: tag & c: bytes{length c = length m} | let box_detached_afternm (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : tag & c:bytes{length c = length m} =
secretbox_detached k n m | {
"file_name": "specs/Spec.Box.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 26,
"end_line": 35,
"start_col": 0,
"start_line": 34
} | module Spec.Box
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.SecretBox
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
(* Constants *)
let size_publickey = 32 (* in bytes *)
let size_secretkey = 32 (* in bytes *)
type publickey = lbytes size_publickey
type secretkey = lbytes size_secretkey
let ecdh (pk:publickey) (sk:secretkey) : option secretkey =
let shared = Spec.Curve25519.scalarmult sk pk in
if not (lbytes_eq shared (create 32 (u8 0))) then
Some shared
else None
let box_beforenm (pk:publickey) (sk:secretkey) : option key =
let shared = ecdh pk sk in
match shared with
| Some shared -> Some (Spec.Salsa20.hsalsa20 shared (create 16 (u8 0)))
| None -> None | {
"checked_file": "/",
"dependencies": [
"Spec.SecretBox.fst.checked",
"Spec.Salsa20.fst.checked",
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Box.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.SecretBox",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
k: Spec.SecretBox.key ->
n: Spec.SecretBox.nonce ->
m:
Lib.ByteSequence.bytes
{Lib.Sequence.length m / Spec.SecretBox.size_block <= Lib.IntTypes.max_size_t}
-> Spec.SecretBox.tag * c: Lib.ByteSequence.bytes{Lib.Sequence.length c = Lib.Sequence.length m} | Prims.Tot | [
"total"
] | [] | [
"Spec.SecretBox.key",
"Spec.SecretBox.nonce",
"Lib.ByteSequence.bytes",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Division",
"Lib.Sequence.length",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.SecretBox.size_block",
"Lib.IntTypes.max_size_t",
"Spec.SecretBox.secretbox_detached",
"FStar.Pervasives.Native.tuple2",
"Spec.SecretBox.tag",
"Prims.op_Equality",
"Prims.nat"
] | [] | false | false | false | false | false | let box_detached_afternm (k: key) (n: nonce) (m: bytes{length m / size_block <= max_size_t})
: tag & c: bytes{length c = length m} =
| secretbox_detached k n m | false |
LowStar.Lib.LinkedList.fst | LowStar.Lib.LinkedList.well_formed | val well_formed (#a: _) (h: HS.mem) (c: t a) (l: list a) : GTot Type0 (decreases l) | val well_formed (#a: _) (h: HS.mem) (c: t a) (l: list a) : GTot Type0 (decreases l) | let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) =
B.live h c /\ (
match l with
| [] ->
B.g_is_null c
| a :: q ->
B.length c == 1 /\ (
let { data=data; next=next } = B.get h c 0 in
a == data /\
well_formed h next (G.hide q)
)) | {
"file_name": "krmllib/LowStar.Lib.LinkedList.fst",
"git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} | {
"end_col": 4,
"end_line": 71,
"start_col": 0,
"start_line": 61
} | module LowStar.Lib.LinkedList
/// This module, oftentimes referred to as LL1 in other parts of the
/// documentation, provides a low-level view over a linked list. Unless you
/// intend on modifying the structure of the linked list (e.g. removing cells)
/// or iterating over each cell, your are probably better off using LL2.
///
/// This module is intentionally not relying on a tight abstraction, to i) permit
/// direct-style iteration by clients and ii) allow stating some SMTPat lemmas
/// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can
/// happen automatically at the SMT level since LL2 does not have an fsti either).
///
/// Some open questions relative to the design of this module:
/// - should ``v`` be defined directly in terms of ``cells`` rather than have a
/// recursive definition along with an equivalence lemma?
/// - should ``footprint`` be defined directly in terms of ``cells`` rather than
/// have a recursive definition along with an equivalence lemma?
/// - is it worth the trouble defining a footprint? my intuition is that it's
/// fine and allows some clients to do very precise reasoning -- other modules
/// (e.g. AssocList), when establishing abstraction boundaries, can simplify
/// things and get rid of the precise footprint reasoning in favor of a static
/// region-based footprint
///
/// Some remaining work items:
/// - switch to C.Loops.while
open LowStar.BufferOps
module B = LowStar.Buffer
module HS = FStar.HyperStack
module G = FStar.Ghost
module L = FStar.List.Tot
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
open FStar.HyperStack.ST
/// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since
/// everything does recursive list reasoning.
#set-options "--__no_positivity --fuel 1 --ifuel 1"
/// Definition of the Low* type
/// ---------------------------
noeq
type t (a: Type0) =
B.pointer_or_null (cell a)
and cell (a: Type0) = {
next: t a;
data: a;
}
/// Unlike the canonical style that associates a ``v`` function to any stateful
/// representation, we use a relation here. Writing a function is just
/// impossible, since we can't prove termination of ``v`` owing to the fact that
/// there may be an infinite number of cells in the heap.
///
/// LL2 is the module that switches to the function style.
/// | {
"checked_file": "/",
"dependencies": [
"TestLib.fsti.checked",
"prims.fst.checked",
"LowStar.Failure.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int32.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Lib.LinkedList.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> c: LowStar.Lib.LinkedList.t a -> l: Prims.list a
-> Prims.GTot Type0 | Prims.GTot | [
"sometrivial",
""
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"LowStar.Lib.LinkedList.t",
"Prims.list",
"Prims.l_and",
"LowStar.Monotonic.Buffer.live",
"LowStar.Lib.LinkedList.cell",
"LowStar.Buffer.trivial_preorder",
"Prims.b2t",
"LowStar.Monotonic.Buffer.g_is_null",
"Prims.eq2",
"Prims.int",
"LowStar.Monotonic.Buffer.length",
"LowStar.Buffer.pointer_or_null",
"LowStar.Lib.LinkedList.well_formed",
"Prims.logical",
"LowStar.Monotonic.Buffer.get"
] | [
"recursion"
] | false | false | false | false | true | let rec well_formed #a (h: HS.mem) (c: t a) (l: list a) : GTot Type0 (decreases l) =
| B.live h c /\
(match l with
| [] -> B.g_is_null c
| a :: q ->
B.length c == 1 /\
(let { data = data ; next = next } = B.get h c 0 in
a == data /\ well_formed h next (G.hide q))) | false |
LowStar.Lib.LinkedList.fst | LowStar.Lib.LinkedList.cells_pairwise_disjoint | val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n) | val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n) | let rec cells_pairwise_disjoint #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\
cells_pairwise_disjoint h next (L.tl n) | {
"file_name": "krmllib/LowStar.Lib.LinkedList.fst",
"git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} | {
"end_col": 43,
"end_line": 157,
"start_col": 0,
"start_line": 151
} | module LowStar.Lib.LinkedList
/// This module, oftentimes referred to as LL1 in other parts of the
/// documentation, provides a low-level view over a linked list. Unless you
/// intend on modifying the structure of the linked list (e.g. removing cells)
/// or iterating over each cell, your are probably better off using LL2.
///
/// This module is intentionally not relying on a tight abstraction, to i) permit
/// direct-style iteration by clients and ii) allow stating some SMTPat lemmas
/// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can
/// happen automatically at the SMT level since LL2 does not have an fsti either).
///
/// Some open questions relative to the design of this module:
/// - should ``v`` be defined directly in terms of ``cells`` rather than have a
/// recursive definition along with an equivalence lemma?
/// - should ``footprint`` be defined directly in terms of ``cells`` rather than
/// have a recursive definition along with an equivalence lemma?
/// - is it worth the trouble defining a footprint? my intuition is that it's
/// fine and allows some clients to do very precise reasoning -- other modules
/// (e.g. AssocList), when establishing abstraction boundaries, can simplify
/// things and get rid of the precise footprint reasoning in favor of a static
/// region-based footprint
///
/// Some remaining work items:
/// - switch to C.Loops.while
open LowStar.BufferOps
module B = LowStar.Buffer
module HS = FStar.HyperStack
module G = FStar.Ghost
module L = FStar.List.Tot
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
open FStar.HyperStack.ST
/// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since
/// everything does recursive list reasoning.
#set-options "--__no_positivity --fuel 1 --ifuel 1"
/// Definition of the Low* type
/// ---------------------------
noeq
type t (a: Type0) =
B.pointer_or_null (cell a)
and cell (a: Type0) = {
next: t a;
data: a;
}
/// Unlike the canonical style that associates a ``v`` function to any stateful
/// representation, we use a relation here. Writing a function is just
/// impossible, since we can't prove termination of ``v`` owing to the fact that
/// there may be an infinite number of cells in the heap.
///
/// LL2 is the module that switches to the function style.
///
/// Note: no need to use erased here for ``l`` since the function is already in ``GTot``.
let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) =
B.live h c /\ (
match l with
| [] ->
B.g_is_null c
| a :: q ->
B.length c == 1 /\ (
let { data=data; next=next } = B.get h c 0 in
a == data /\
well_formed h next (G.hide q)
))
/// Precise reasoning via the cells predicate
/// -----------------------------------------
///
/// The modifies clauses are given either on the footprint of the list, or on a
/// region that includes the footprint of the list (higher up the stack, e.g.
/// LL2). This is good, but does not rule out "stupid" implementations that
/// might re-allocate every single list cell when, say, doing a pop.
///
/// For advanced usages which take pointers directly to individual list cells,
/// it's important to rule out these cases. We thus define the ``cells``
/// predicate for that purpose.
let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a)))
(requires well_formed h c l)
(ensures fun _ -> True)
(decreases l)
=
if B.g_is_null c then
[]
else
c :: cells h (B.deref h c).next (List.Tot.tl l)
/// A missing bit of automated reasoning
/// ------------------------------------
/// This should be absolutely trivial, yet, because there's no pattern on
/// null_unique, we have to do the case analysis and the decomposition
/// ourselves. This is quite tedious, as it usually takes a while (at least it
/// did for me!) to realize that this property does not hold automatically.
///
/// I'm setting an SMTPat on this lemma because it's absolutely impossible to
/// get any work done without it.
let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma
(requires (
well_formed h0 ll0 l0 /\
well_formed h1 ll1 l1 /\
cells h0 ll0 l0 == cells h1 ll1 l1))
(ensures (
ll0 == ll1))
[ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ]
=
if B.g_is_null ll0 && B.g_is_null ll1 then begin
B.null_unique ll0;
B.null_unique ll1
end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin
()
end else
false_elim ()
/// Classic stateful reasoning lemmas
/// ---------------------------------
///
/// This essentially follows ``stateful``, the type class of a mutable piece of
/// state defined using the modifies-theory of Low*v2 and equipped with the
/// right lemmas to enable usage by clients. See
/// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context.
val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc
(requires (well_formed h l n))
(ensures (fun refs -> True))
(decreases n)
let rec footprint #a h l n =
if B.g_is_null l
then B.loc_none
else
let {next = next} = B.get h l 0 in
let refs = footprint h next (G.hide (L.tl n)) in
B.loc_union (B.loc_addr_of_buffer l) refs
/// Departing from LinkedList4 here. I prefer to bolt these into the invariant
/// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to
/// deduce these.
val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n) | {
"checked_file": "/",
"dependencies": [
"TestLib.fsti.checked",
"prims.fst.checked",
"LowStar.Failure.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int32.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Lib.LinkedList.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> l: LowStar.Lib.LinkedList.t a -> n: Prims.list a
-> Prims.Ghost Type0 | Prims.Ghost | [
""
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"LowStar.Lib.LinkedList.t",
"Prims.list",
"LowStar.Monotonic.Buffer.g_is_null",
"LowStar.Lib.LinkedList.cell",
"LowStar.Buffer.trivial_preorder",
"Prims.l_True",
"Prims.bool",
"Prims.l_and",
"LowStar.Monotonic.Buffer.loc_disjoint",
"LowStar.Monotonic.Buffer.loc_addr_of_buffer",
"LowStar.Lib.LinkedList.footprint",
"FStar.List.Tot.Base.tl",
"LowStar.Lib.LinkedList.cells_pairwise_disjoint",
"LowStar.Buffer.pointer_or_null",
"LowStar.Lib.LinkedList.__proj__Mkcell__item__next",
"LowStar.Monotonic.Buffer.deref"
] | [
"recursion"
] | false | false | false | false | true | let rec cells_pairwise_disjoint #_ h l n =
| if B.g_is_null l
then True
else
let next = (B.deref h l).next in
B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\
cells_pairwise_disjoint h next (L.tl n) | false |
LowStar.Lib.LinkedList.fst | LowStar.Lib.LinkedList.invariant | val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n) | val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n) | let invariant #a h l n =
cells_live_freeable h l n /\ cells_pairwise_disjoint h l n | {
"file_name": "krmllib/LowStar.Lib.LinkedList.fst",
"git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} | {
"end_col": 60,
"end_line": 177,
"start_col": 0,
"start_line": 176
} | module LowStar.Lib.LinkedList
/// This module, oftentimes referred to as LL1 in other parts of the
/// documentation, provides a low-level view over a linked list. Unless you
/// intend on modifying the structure of the linked list (e.g. removing cells)
/// or iterating over each cell, your are probably better off using LL2.
///
/// This module is intentionally not relying on a tight abstraction, to i) permit
/// direct-style iteration by clients and ii) allow stating some SMTPat lemmas
/// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can
/// happen automatically at the SMT level since LL2 does not have an fsti either).
///
/// Some open questions relative to the design of this module:
/// - should ``v`` be defined directly in terms of ``cells`` rather than have a
/// recursive definition along with an equivalence lemma?
/// - should ``footprint`` be defined directly in terms of ``cells`` rather than
/// have a recursive definition along with an equivalence lemma?
/// - is it worth the trouble defining a footprint? my intuition is that it's
/// fine and allows some clients to do very precise reasoning -- other modules
/// (e.g. AssocList), when establishing abstraction boundaries, can simplify
/// things and get rid of the precise footprint reasoning in favor of a static
/// region-based footprint
///
/// Some remaining work items:
/// - switch to C.Loops.while
open LowStar.BufferOps
module B = LowStar.Buffer
module HS = FStar.HyperStack
module G = FStar.Ghost
module L = FStar.List.Tot
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
open FStar.HyperStack.ST
/// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since
/// everything does recursive list reasoning.
#set-options "--__no_positivity --fuel 1 --ifuel 1"
/// Definition of the Low* type
/// ---------------------------
noeq
type t (a: Type0) =
B.pointer_or_null (cell a)
and cell (a: Type0) = {
next: t a;
data: a;
}
/// Unlike the canonical style that associates a ``v`` function to any stateful
/// representation, we use a relation here. Writing a function is just
/// impossible, since we can't prove termination of ``v`` owing to the fact that
/// there may be an infinite number of cells in the heap.
///
/// LL2 is the module that switches to the function style.
///
/// Note: no need to use erased here for ``l`` since the function is already in ``GTot``.
let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) =
B.live h c /\ (
match l with
| [] ->
B.g_is_null c
| a :: q ->
B.length c == 1 /\ (
let { data=data; next=next } = B.get h c 0 in
a == data /\
well_formed h next (G.hide q)
))
/// Precise reasoning via the cells predicate
/// -----------------------------------------
///
/// The modifies clauses are given either on the footprint of the list, or on a
/// region that includes the footprint of the list (higher up the stack, e.g.
/// LL2). This is good, but does not rule out "stupid" implementations that
/// might re-allocate every single list cell when, say, doing a pop.
///
/// For advanced usages which take pointers directly to individual list cells,
/// it's important to rule out these cases. We thus define the ``cells``
/// predicate for that purpose.
let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a)))
(requires well_formed h c l)
(ensures fun _ -> True)
(decreases l)
=
if B.g_is_null c then
[]
else
c :: cells h (B.deref h c).next (List.Tot.tl l)
/// A missing bit of automated reasoning
/// ------------------------------------
/// This should be absolutely trivial, yet, because there's no pattern on
/// null_unique, we have to do the case analysis and the decomposition
/// ourselves. This is quite tedious, as it usually takes a while (at least it
/// did for me!) to realize that this property does not hold automatically.
///
/// I'm setting an SMTPat on this lemma because it's absolutely impossible to
/// get any work done without it.
let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma
(requires (
well_formed h0 ll0 l0 /\
well_formed h1 ll1 l1 /\
cells h0 ll0 l0 == cells h1 ll1 l1))
(ensures (
ll0 == ll1))
[ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ]
=
if B.g_is_null ll0 && B.g_is_null ll1 then begin
B.null_unique ll0;
B.null_unique ll1
end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin
()
end else
false_elim ()
/// Classic stateful reasoning lemmas
/// ---------------------------------
///
/// This essentially follows ``stateful``, the type class of a mutable piece of
/// state defined using the modifies-theory of Low*v2 and equipped with the
/// right lemmas to enable usage by clients. See
/// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context.
val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc
(requires (well_formed h l n))
(ensures (fun refs -> True))
(decreases n)
let rec footprint #a h l n =
if B.g_is_null l
then B.loc_none
else
let {next = next} = B.get h l 0 in
let refs = footprint h next (G.hide (L.tl n)) in
B.loc_union (B.loc_addr_of_buffer l) refs
/// Departing from LinkedList4 here. I prefer to bolt these into the invariant
/// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to
/// deduce these.
val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_pairwise_disjoint #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\
cells_pairwise_disjoint h next (L.tl n)
val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_live_freeable #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.live h l /\ B.freeable l /\
cells_live_freeable h next (L.tl n)
val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True) | {
"checked_file": "/",
"dependencies": [
"TestLib.fsti.checked",
"prims.fst.checked",
"LowStar.Failure.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int32.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Lib.LinkedList.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> l: LowStar.Lib.LinkedList.t a -> n: Prims.list a
-> Prims.Ghost Type0 | Prims.Ghost | [
""
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"LowStar.Lib.LinkedList.t",
"Prims.list",
"Prims.l_and",
"LowStar.Lib.LinkedList.cells_live_freeable",
"LowStar.Lib.LinkedList.cells_pairwise_disjoint"
] | [] | false | false | false | false | true | let invariant #a h l n =
| cells_live_freeable h l n /\ cells_pairwise_disjoint h l n | false |
Spec.Box.fst | Spec.Box.box_open_detached_afternm | val box_open_detached_afternm
(k: key)
(n: nonce)
(t: tag)
(c: bytes{length c / size_block <= max_size_t})
: option (m: bytes{length m = length c}) | val box_open_detached_afternm
(k: key)
(n: nonce)
(t: tag)
(c: bytes{length c / size_block <= max_size_t})
: option (m: bytes{length m = length c}) | let box_open_detached_afternm (k:key) (n:nonce) (t:tag) (c:bytes{length c / size_block <= max_size_t}) : option (m:bytes{length m = length c}) =
secretbox_open_detached k n t c | {
"file_name": "specs/Spec.Box.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 33,
"end_line": 46,
"start_col": 0,
"start_line": 45
} | module Spec.Box
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.SecretBox
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
(* Constants *)
let size_publickey = 32 (* in bytes *)
let size_secretkey = 32 (* in bytes *)
type publickey = lbytes size_publickey
type secretkey = lbytes size_secretkey
let ecdh (pk:publickey) (sk:secretkey) : option secretkey =
let shared = Spec.Curve25519.scalarmult sk pk in
if not (lbytes_eq shared (create 32 (u8 0))) then
Some shared
else None
let box_beforenm (pk:publickey) (sk:secretkey) : option key =
let shared = ecdh pk sk in
match shared with
| Some shared -> Some (Spec.Salsa20.hsalsa20 shared (create 16 (u8 0)))
| None -> None
let box_detached_afternm (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : tag & c:bytes{length c = length m} =
secretbox_detached k n m
let box_detached (sk:secretkey) (pk:publickey) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : option (tag & c:bytes{length c = length m}) =
let k = box_beforenm pk sk in
match k with
| Some k -> Some (box_detached_afternm k n m)
| None -> None | {
"checked_file": "/",
"dependencies": [
"Spec.SecretBox.fst.checked",
"Spec.Salsa20.fst.checked",
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Box.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.SecretBox",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
k: Spec.SecretBox.key ->
n: Spec.SecretBox.nonce ->
t: Spec.SecretBox.tag ->
c:
Lib.ByteSequence.bytes
{Lib.Sequence.length c / Spec.SecretBox.size_block <= Lib.IntTypes.max_size_t}
-> FStar.Pervasives.Native.option (m:
Lib.ByteSequence.bytes{Lib.Sequence.length m = Lib.Sequence.length c}) | Prims.Tot | [
"total"
] | [] | [
"Spec.SecretBox.key",
"Spec.SecretBox.nonce",
"Spec.SecretBox.tag",
"Lib.ByteSequence.bytes",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Division",
"Lib.Sequence.length",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.SecretBox.size_block",
"Lib.IntTypes.max_size_t",
"Spec.SecretBox.secretbox_open_detached",
"FStar.Pervasives.Native.option",
"Prims.op_Equality",
"Prims.nat"
] | [] | false | false | false | false | false | let box_open_detached_afternm
(k: key)
(n: nonce)
(t: tag)
(c: bytes{length c / size_block <= max_size_t})
: option (m: bytes{length m = length c}) =
| secretbox_open_detached k n t c | false |
Spec.Box.fst | Spec.Box.box_easy_afternm | val box_easy_afternm (k: key) (n: nonce) (m: bytes{length m / size_block <= max_size_t})
: c: bytes{length c = size_tag + length m} | val box_easy_afternm (k: key) (n: nonce) (m: bytes{length m / size_block <= max_size_t})
: c: bytes{length c = size_tag + length m} | let box_easy_afternm (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : c:bytes{length c = size_tag + length m} =
let (tg, c) = box_detached_afternm k n m in
Seq.append tg c | {
"file_name": "specs/Spec.Box.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 17,
"end_line": 58,
"start_col": 0,
"start_line": 56
} | module Spec.Box
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.SecretBox
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
(* Constants *)
let size_publickey = 32 (* in bytes *)
let size_secretkey = 32 (* in bytes *)
type publickey = lbytes size_publickey
type secretkey = lbytes size_secretkey
let ecdh (pk:publickey) (sk:secretkey) : option secretkey =
let shared = Spec.Curve25519.scalarmult sk pk in
if not (lbytes_eq shared (create 32 (u8 0))) then
Some shared
else None
let box_beforenm (pk:publickey) (sk:secretkey) : option key =
let shared = ecdh pk sk in
match shared with
| Some shared -> Some (Spec.Salsa20.hsalsa20 shared (create 16 (u8 0)))
| None -> None
let box_detached_afternm (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : tag & c:bytes{length c = length m} =
secretbox_detached k n m
let box_detached (sk:secretkey) (pk:publickey) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : option (tag & c:bytes{length c = length m}) =
let k = box_beforenm pk sk in
match k with
| Some k -> Some (box_detached_afternm k n m)
| None -> None
let box_open_detached_afternm (k:key) (n:nonce) (t:tag) (c:bytes{length c / size_block <= max_size_t}) : option (m:bytes{length m = length c}) =
secretbox_open_detached k n t c
let box_open_detached (pk:publickey) (sk:secretkey) (n:nonce) (t:tag) (c:bytes{length c / size_block <= max_size_t}) : option (m:bytes{length m = length c}) =
let k = box_beforenm pk sk in
match k with
| Some k -> box_open_detached_afternm k n t c
| None -> None | {
"checked_file": "/",
"dependencies": [
"Spec.SecretBox.fst.checked",
"Spec.Salsa20.fst.checked",
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Box.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.SecretBox",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
k: Spec.SecretBox.key ->
n: Spec.SecretBox.nonce ->
m:
Lib.ByteSequence.bytes
{Lib.Sequence.length m / Spec.SecretBox.size_block <= Lib.IntTypes.max_size_t}
-> c:
Lib.ByteSequence.bytes{Lib.Sequence.length c = Spec.SecretBox.size_tag + Lib.Sequence.length m} | Prims.Tot | [
"total"
] | [] | [
"Spec.SecretBox.key",
"Spec.SecretBox.nonce",
"Lib.ByteSequence.bytes",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Division",
"Lib.Sequence.length",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.SecretBox.size_block",
"Lib.IntTypes.max_size_t",
"Spec.SecretBox.tag",
"Prims.op_Equality",
"Prims.nat",
"FStar.Seq.Base.append",
"Prims.int",
"Prims.op_Addition",
"Spec.SecretBox.size_tag",
"FStar.Pervasives.Native.tuple2",
"Lib.Sequence.seq",
"Lib.IntTypes.int_t",
"Spec.Box.box_detached_afternm"
] | [] | false | false | false | false | false | let box_easy_afternm (k: key) (n: nonce) (m: bytes{length m / size_block <= max_size_t})
: c: bytes{length c = size_tag + length m} =
| let tg, c = box_detached_afternm k n m in
Seq.append tg c | false |
Spec.Box.fst | Spec.Box.box_open_easy_afternm | val box_open_easy_afternm
(k: key)
(n: nonce)
(c: bytes{length c >= size_tag /\ (length c - size_tag) / size_block <= max_size_t})
: option (m: bytes{length m = length c - size_tag}) | val box_open_easy_afternm
(k: key)
(n: nonce)
(c: bytes{length c >= size_tag /\ (length c - size_tag) / size_block <= max_size_t})
: option (m: bytes{length m = length c - size_tag}) | let box_open_easy_afternm (k:key) (n:nonce) (c:bytes{length c >= size_tag /\ (length c - size_tag) / size_block <= max_size_t}) : option (m:bytes{length m = length c - size_tag}) =
let tg = Seq.slice c 0 size_tag in
let e = Seq.slice c size_tag (length c) in
box_open_detached_afternm k n tg e | {
"file_name": "specs/Spec.Box.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 36,
"end_line": 71,
"start_col": 0,
"start_line": 68
} | module Spec.Box
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.SecretBox
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
(* Constants *)
let size_publickey = 32 (* in bytes *)
let size_secretkey = 32 (* in bytes *)
type publickey = lbytes size_publickey
type secretkey = lbytes size_secretkey
let ecdh (pk:publickey) (sk:secretkey) : option secretkey =
let shared = Spec.Curve25519.scalarmult sk pk in
if not (lbytes_eq shared (create 32 (u8 0))) then
Some shared
else None
let box_beforenm (pk:publickey) (sk:secretkey) : option key =
let shared = ecdh pk sk in
match shared with
| Some shared -> Some (Spec.Salsa20.hsalsa20 shared (create 16 (u8 0)))
| None -> None
let box_detached_afternm (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : tag & c:bytes{length c = length m} =
secretbox_detached k n m
let box_detached (sk:secretkey) (pk:publickey) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : option (tag & c:bytes{length c = length m}) =
let k = box_beforenm pk sk in
match k with
| Some k -> Some (box_detached_afternm k n m)
| None -> None
let box_open_detached_afternm (k:key) (n:nonce) (t:tag) (c:bytes{length c / size_block <= max_size_t}) : option (m:bytes{length m = length c}) =
secretbox_open_detached k n t c
let box_open_detached (pk:publickey) (sk:secretkey) (n:nonce) (t:tag) (c:bytes{length c / size_block <= max_size_t}) : option (m:bytes{length m = length c}) =
let k = box_beforenm pk sk in
match k with
| Some k -> box_open_detached_afternm k n t c
| None -> None
let box_easy_afternm (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : c:bytes{length c = size_tag + length m} =
let (tg, c) = box_detached_afternm k n m in
Seq.append tg c
let box_easy (sk:secretkey) (pk:publickey) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : option (c:bytes{length c = size_tag + length m}) =
let r = box_detached sk pk n m in
match r with
| Some (tg, c) -> Some (Seq.append tg c)
| None -> None | {
"checked_file": "/",
"dependencies": [
"Spec.SecretBox.fst.checked",
"Spec.Salsa20.fst.checked",
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Box.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.SecretBox",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
k: Spec.SecretBox.key ->
n: Spec.SecretBox.nonce ->
c:
Lib.ByteSequence.bytes
{ Lib.Sequence.length c >= Spec.SecretBox.size_tag /\
(Lib.Sequence.length c - Spec.SecretBox.size_tag) / Spec.SecretBox.size_block <=
Lib.IntTypes.max_size_t }
-> FStar.Pervasives.Native.option (m:
Lib.ByteSequence.bytes
{Lib.Sequence.length m = Lib.Sequence.length c - Spec.SecretBox.size_tag}) | Prims.Tot | [
"total"
] | [] | [
"Spec.SecretBox.key",
"Spec.SecretBox.nonce",
"Lib.ByteSequence.bytes",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Lib.Sequence.length",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.SecretBox.size_tag",
"Prims.op_LessThanOrEqual",
"Prims.op_Division",
"Prims.op_Subtraction",
"Spec.SecretBox.size_block",
"Lib.IntTypes.max_size_t",
"Spec.Box.box_open_detached_afternm",
"FStar.Seq.Base.seq",
"Lib.IntTypes.int_t",
"FStar.Seq.Base.slice",
"FStar.Pervasives.Native.option",
"Prims.op_Equality",
"Prims.int"
] | [] | false | false | false | false | false | let box_open_easy_afternm
(k: key)
(n: nonce)
(c: bytes{length c >= size_tag /\ (length c - size_tag) / size_block <= max_size_t})
: option (m: bytes{length m = length c - size_tag}) =
| let tg = Seq.slice c 0 size_tag in
let e = Seq.slice c size_tag (length c) in
box_open_detached_afternm k n tg e | false |
Spec.Box.fst | Spec.Box.box_easy | val box_easy
(sk: secretkey)
(pk: publickey)
(n: nonce)
(m: bytes{length m / size_block <= max_size_t})
: option (c: bytes{length c = size_tag + length m}) | val box_easy
(sk: secretkey)
(pk: publickey)
(n: nonce)
(m: bytes{length m / size_block <= max_size_t})
: option (c: bytes{length c = size_tag + length m}) | let box_easy (sk:secretkey) (pk:publickey) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : option (c:bytes{length c = size_tag + length m}) =
let r = box_detached sk pk n m in
match r with
| Some (tg, c) -> Some (Seq.append tg c)
| None -> None | {
"file_name": "specs/Spec.Box.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 65,
"start_col": 0,
"start_line": 61
} | module Spec.Box
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.SecretBox
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
(* Constants *)
let size_publickey = 32 (* in bytes *)
let size_secretkey = 32 (* in bytes *)
type publickey = lbytes size_publickey
type secretkey = lbytes size_secretkey
let ecdh (pk:publickey) (sk:secretkey) : option secretkey =
let shared = Spec.Curve25519.scalarmult sk pk in
if not (lbytes_eq shared (create 32 (u8 0))) then
Some shared
else None
let box_beforenm (pk:publickey) (sk:secretkey) : option key =
let shared = ecdh pk sk in
match shared with
| Some shared -> Some (Spec.Salsa20.hsalsa20 shared (create 16 (u8 0)))
| None -> None
let box_detached_afternm (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : tag & c:bytes{length c = length m} =
secretbox_detached k n m
let box_detached (sk:secretkey) (pk:publickey) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : option (tag & c:bytes{length c = length m}) =
let k = box_beforenm pk sk in
match k with
| Some k -> Some (box_detached_afternm k n m)
| None -> None
let box_open_detached_afternm (k:key) (n:nonce) (t:tag) (c:bytes{length c / size_block <= max_size_t}) : option (m:bytes{length m = length c}) =
secretbox_open_detached k n t c
let box_open_detached (pk:publickey) (sk:secretkey) (n:nonce) (t:tag) (c:bytes{length c / size_block <= max_size_t}) : option (m:bytes{length m = length c}) =
let k = box_beforenm pk sk in
match k with
| Some k -> box_open_detached_afternm k n t c
| None -> None
let box_easy_afternm (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : c:bytes{length c = size_tag + length m} =
let (tg, c) = box_detached_afternm k n m in
Seq.append tg c | {
"checked_file": "/",
"dependencies": [
"Spec.SecretBox.fst.checked",
"Spec.Salsa20.fst.checked",
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Box.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.SecretBox",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
sk: Spec.Box.secretkey ->
pk: Spec.Box.publickey ->
n: Spec.SecretBox.nonce ->
m:
Lib.ByteSequence.bytes
{Lib.Sequence.length m / Spec.SecretBox.size_block <= Lib.IntTypes.max_size_t}
-> FStar.Pervasives.Native.option (c:
Lib.ByteSequence.bytes
{Lib.Sequence.length c = Spec.SecretBox.size_tag + Lib.Sequence.length m}) | Prims.Tot | [
"total"
] | [] | [
"Spec.Box.secretkey",
"Spec.Box.publickey",
"Spec.SecretBox.nonce",
"Lib.ByteSequence.bytes",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Division",
"Lib.Sequence.length",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.SecretBox.size_block",
"Lib.IntTypes.max_size_t",
"Spec.SecretBox.tag",
"Prims.op_Equality",
"Prims.nat",
"FStar.Pervasives.Native.Some",
"Prims.int",
"Prims.op_Addition",
"Spec.SecretBox.size_tag",
"FStar.Seq.Base.append",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"Lib.Sequence.seq",
"Lib.IntTypes.int_t",
"Spec.Box.box_detached"
] | [] | false | false | false | false | false | let box_easy
(sk: secretkey)
(pk: publickey)
(n: nonce)
(m: bytes{length m / size_block <= max_size_t})
: option (c: bytes{length c = size_tag + length m}) =
| let r = box_detached sk pk n m in
match r with
| Some (tg, c) -> Some (Seq.append tg c)
| None -> None | false |
Vale.AES.X64.GCMdecryptOpt.fst | Vale.AES.X64.GCMdecryptOpt.va_lemma_Gcm_blocks128 | val va_lemma_Gcm_blocks128 : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> in_b:buffer128 ->
out_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> h_LE:quad32
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks128 alg) va_s0 /\ va_get_ok va_s0 /\
(sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b out_b /\
Vale.X64.Decls.buffers_disjoint128 hkeys_b out_b /\ (Vale.X64.Decls.buffers_disjoint128 in_b
out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16
`op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply`
va_get_reg64 rRdx va_s0 < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b)
(Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx
va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\
va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8
va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0)
(va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM ==
va_get_xmm 8 va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b ==
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ (va_get_reg64 rRdx va_s0 > 0 ==>
l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==> FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b)))) /\ va_state_eq va_sM (va_update_flags va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 10 va_sM (va_update_xmm 11 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rR10 va_sM
(va_update_reg64 rR11 va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRbx va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))))))))))))) | val va_lemma_Gcm_blocks128 : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> in_b:buffer128 ->
out_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> h_LE:quad32
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks128 alg) va_s0 /\ va_get_ok va_s0 /\
(sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b out_b /\
Vale.X64.Decls.buffers_disjoint128 hkeys_b out_b /\ (Vale.X64.Decls.buffers_disjoint128 in_b
out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16
`op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply`
va_get_reg64 rRdx va_s0 < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b)
(Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx
va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\
va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8
va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0)
(va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM ==
va_get_xmm 8 va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b ==
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ (va_get_reg64 rRdx va_s0 > 0 ==>
l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==> FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b)))) /\ va_state_eq va_sM (va_update_flags va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 10 va_sM (va_update_xmm 11 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rR10 va_sM
(va_update_reg64 rR11 va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRbx va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))))))))))))) | let va_lemma_Gcm_blocks128 va_b0 va_s0 alg in_b out_b key round_keys keys_b hkeys_b h_LE =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11;
va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm
2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks128 va_mods alg in_b out_b key round_keys keys_b hkeys_b h_LE in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks128 alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 210 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 255 column 53 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 261 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 262 column 45 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0) (va_get_reg64 rRdx
va_s0)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 265 column 93 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM == va_get_xmm 8 va_s0)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b == Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) out_b)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 267 column 131 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRdx va_s0 > 0 ==> l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==>
FStar.Seq.Base.length #Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm
8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2;
va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM) | {
"file_name": "obj/Vale.AES.X64.GCMdecryptOpt.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 403,
"start_col": 0,
"start_line": 366
} | module Vale.AES.X64.GCMdecryptOpt
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open FStar.Seq
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_s
open Vale.AES.GCTR_s
open Vale.AES.GCTR
open Vale.AES.GCM
open Vale.AES.GHash_s
open Vale.AES.GHash
open Vale.AES.GCM_s
open Vale.AES.X64.AES
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.Poly1305.Math
open Vale.AES.GCM_helpers
open Vale.AES.X64.GHash
open Vale.AES.X64.GCTR
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.X64.Stack_i
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.InsBasic
open Vale.X64.InsMem
open Vale.X64.InsVector
open Vale.X64.InsStack
open Vale.X64.InsAes
open Vale.X64.QuickCode
open Vale.X64.QuickCodes
open Vale.AES.X64.GF128_Mul
open Vale.X64.Stack
open Vale.X64.CPU_Features_s
open Vale.Math.Poly2.Bits_s
open Vale.AES.X64.AESopt
open Vale.AES.X64.AESGCM
open Vale.AES.X64.AESopt2
open Vale.Lib.Meta
open Vale.AES.X64.GCMencryptOpt
open Vale.AES.OptPublic
open Vale.Lib.Basic
#reset-options "--z3rlimit 20 --max_ifuel 0"
//-- Gcm_extra_bytes
val va_code_Gcm_extra_bytes : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_extra_bytes alg =
(va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0)
(va_op_reg_opr64_reg64 rRax) 0 Secret) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 10)
(va_op_xmm_xmm 0)) (va_CCons (va_code_Ghash_extra_bytes ()) (va_CCons (va_code_Mov128
(va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_CCons (va_code_Pshufb (va_op_xmm_xmm 0)
(va_op_xmm_xmm 9)) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons (va_code_Pxor
(va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_CCons (va_code_Store128_buffer
(va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret)
(va_CNil ()))))))))))
val va_codegen_success_Gcm_extra_bytes : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_extra_bytes alg =
(va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0)
(va_op_reg_opr64_reg64 rRax) 0 Secret) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm
10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Ghash_extra_bytes ()) (va_pbool_and
(va_codegen_success_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_pbool_and
(va_codegen_success_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and
(va_codegen_success_AESEncryptBlock alg) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm
10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Store128_buffer
(va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret)
(va_ttrue ())))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_extra_bytes (va_mods:va_mods_t) (alg:algorithm) (inout_b:buffer128) (key:(seq
nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat)
(old_hash:quad32) (completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit
(va_code_Gcm_extra_bytes alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (len:(va_int_range
1 1)) = 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 188 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRax) 0 Secret inout_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 189 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (fun (va_s:va_state) _ -> let
(hash_input:quad32) = va_get_xmm 0 va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 193 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_extra_bytes hkeys_b total_bytes old_hash h_LE completed_quads) (fun
(va_s:va_state) _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 194 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.equal #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s)
inout_b) (FStar.Seq.Base.create #quad32 1 hash_input)) (let (snap:(FStar.Seq.Base.seq
Vale.X64.Decls.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 198 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 199 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 200 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AESEncryptBlock alg (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 11 va_s)) key
round_keys keys_b) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 201 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.AES_s.aes_encrypt_LE_reveal ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 204 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 205 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax)
(va_op_xmm_xmm 10) 0 Secret inout_b 0) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 207 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.gctr_partial_reveal ()) (va_QEmpty (()))))))))))))))
val va_lemma_Gcm_extra_bytes : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
inout_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> total_bytes:nat -> old_hash:quad32 -> completed_quads:(seq quad32) ->
h_LE:quad32
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_extra_bytes alg) va_s0 /\ va_get_ok va_s0 /\ (let
(len:(va_int_range 1 1)) = 1 in sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b
inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b inout_b /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax va_s0) inout_b
len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys
keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0
va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32
(Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length
#quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply`
FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes
`op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16
`op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
(Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads =
FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0)
inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes =
Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) /\ va_state_eq va_sM
(va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM (va_update_ok va_sM
(va_update_mem va_sM va_s0))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_extra_bytes va_b0 va_s0 alg inout_b key round_keys keys_b hkeys_b total_bytes
old_hash completed_quads h_LE =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_extra_bytes va_mods alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_extra_bytes alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 121 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (len:(va_int_range 1 1)) = 1 in label va_range1
"***** POSTCONDITION NOT MET AT line 174 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 177 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg len (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0)) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 180 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let raw_quads = FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 181 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 182 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 183 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let input_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 186 column 59 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(l_and (FStar.Seq.Base.length #Vale.Def.Types_s.quad32 input_quads > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE old_hash input_quads)))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm
7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32)
(completed_quads:(seq quad32)) (h_LE:quad32) (va_s0:va_state) (va_k:(va_state -> unit -> Type0))
: Type0 =
(va_get_ok va_s0 /\ (let (len:(va_int_range 1 1)) = 1 in sse_enabled /\
Vale.X64.Decls.buffers_disjoint128 keys_b inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b
inout_b /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax
va_s0) inout_b len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys
keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0
va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32
(Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length
#quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply`
FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes
`op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16
`op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
(Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes) /\ (forall
(va_x_mem:vale_heap) (va_x_rcx:nat64) (va_x_r11:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32)
(va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32)
(va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm10:quad32) (va_x_heap5:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 5
va_x_heap5 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7
(va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3
(va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR11
va_x_r11 (va_upd_reg64 rRcx va_x_rcx (va_upd_mem va_x_mem va_s0)))))))))))))) in va_get_ok
va_sM /\ (let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads =
FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0)
inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes =
Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) ==> va_k va_sM (())))
val va_wpProof_Gcm_extra_bytes : alg:algorithm -> inout_b:buffer128 -> key:(seq nat32) ->
round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> total_bytes:nat ->
old_hash:quad32 -> completed_quads:(seq quad32) -> h_LE: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_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_extra_bytes alg) ([va_Mod_flags;
va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5;
va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11;
va_Mod_reg64 rRcx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash
completed_quads h_LE va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_extra_bytes (va_code_Gcm_extra_bytes alg) va_s0 alg inout_b key
round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10
va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm
7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32)
(completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit (va_code_Gcm_extra_bytes alg)) =
(va_QProc (va_code_Gcm_extra_bytes alg) ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10;
va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm
2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem])
(va_wp_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash
completed_quads h_LE) (va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE))
//--
//-- Gcm_blocks128
val va_code_Gcm_blocks128 : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks128 alg =
(va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi))
(va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_CCons
(va_code_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_CCons
(va_code_Ghash_buffer ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdi)
(va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx)
(va_op_opr64_reg64 rR12)) (va_CCons (va_code_Gctr_blocks128 alg) (va_CNil ())))))))))
val va_codegen_success_Gcm_blocks128 : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks128 alg =
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi))
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx))
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax))
(va_pbool_and (va_codegen_success_Ghash_buffer ()) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_pbool_and
(va_codegen_success_Gctr_blocks128 alg) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks128 (va_mods:va_mods_t) (alg:algorithm) (in_b:buffer128) (out_b:buffer128)
(key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32)
: (va_quickCode unit (va_code_Gcm_blocks128 alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 274 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 275 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 276 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 277 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_buffer hkeys_b in_b h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_old_s))) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 278 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 279 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 280 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gctr_blocks128 alg in_b out_b key round_keys keys_b) (va_QEmpty (()))))))))))
val va_lemma_Gcm_blocks128 : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> in_b:buffer128 ->
out_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> h_LE:quad32
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks128 alg) va_s0 /\ va_get_ok va_s0 /\
(sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b out_b /\
Vale.X64.Decls.buffers_disjoint128 hkeys_b out_b /\ (Vale.X64.Decls.buffers_disjoint128 in_b
out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16
`op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply`
va_get_reg64 rRdx va_s0 < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b)
(Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx
va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\
va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8
va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0)
(va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM ==
va_get_xmm 8 va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b ==
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ (va_get_reg64 rRdx va_s0 > 0 ==>
l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==> FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b)))) /\ va_state_eq va_sM (va_update_flags va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 10 va_sM (va_update_xmm 11 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rR10 va_sM
(va_update_reg64 rR11 va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRbx va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))))))))))))) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Stack.fsti.checked",
"Vale.X64.QuickCodes.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.InsVector.fsti.checked",
"Vale.X64.InsStack.fsti.checked",
"Vale.X64.InsMem.fsti.checked",
"Vale.X64.InsBasic.fsti.checked",
"Vale.X64.InsAes.fsti.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Lib.Meta.fsti.checked",
"Vale.Lib.Basic.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_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",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.X64.GHash.fsti.checked",
"Vale.AES.X64.GF128_Mul.fsti.checked",
"Vale.AES.X64.GCTR.fsti.checked",
"Vale.AES.X64.GCMencryptOpt.fsti.checked",
"Vale.AES.X64.AESopt2.fsti.checked",
"Vale.AES.X64.AESopt.fsti.checked",
"Vale.AES.X64.AESGCM.fsti.checked",
"Vale.AES.X64.AES.fsti.checked",
"Vale.AES.OptPublic.fsti.checked",
"Vale.AES.GHash_s.fst.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_s.fst.checked",
"Vale.AES.GCTR.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"Vale.AES.GCM.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_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.X64.GCMdecryptOpt.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Lib.Basic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"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.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_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": "Vale.Def.Types_s",
"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": "FStar.Seq",
"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.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"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.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_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": "Vale.Def.Types_s",
"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": "FStar.Seq",
"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.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
va_b0: Vale.X64.Decls.va_code ->
va_s0: Vale.X64.Decls.va_state ->
alg: Vale.AES.AES_common_s.algorithm ->
in_b: Vale.X64.Memory.buffer128 ->
out_b: Vale.X64.Memory.buffer128 ->
key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 ->
round_keys: FStar.Seq.Base.seq Vale.X64.Decls.quad32 ->
keys_b: Vale.X64.Memory.buffer128 ->
hkeys_b: Vale.X64.Memory.buffer128 ->
h_LE: Vale.X64.Decls.quad32
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | Prims.Ghost | [] | [] | [
"Vale.X64.Decls.va_code",
"Vale.X64.Decls.va_state",
"Vale.AES.AES_common_s.algorithm",
"Vale.X64.Memory.buffer128",
"FStar.Seq.Base.seq",
"Vale.X64.Memory.nat32",
"Vale.X64.Decls.quad32",
"Vale.X64.QuickCodes.fuel",
"Prims.unit",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Decls.va_fuel",
"Vale.X64.QuickCode.va_lemma_norm_mods",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_Mod_flags",
"Vale.X64.QuickCode.va_Mod_mem_heaplet",
"Vale.X64.QuickCode.va_Mod_xmm",
"Vale.X64.QuickCode.va_Mod_reg64",
"Vale.X64.Machine_s.rR12",
"Vale.X64.Machine_s.rRdx",
"Vale.X64.Machine_s.rR10",
"Vale.X64.Machine_s.rR11",
"Vale.X64.Machine_s.rRdi",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.QuickCode.va_Mod_ok",
"Vale.X64.QuickCode.va_Mod_mem",
"Prims.Nil",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.list",
"Vale.X64.QuickCode.__proj__QProc__item__mods",
"Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_blocks128",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.tuple3",
"Vale.X64.State.vale_state",
"Vale.X64.QuickCodes.va_wp_sound_code_norm",
"Prims.l_and",
"Vale.X64.QuickCodes.label",
"Vale.X64.QuickCodes.va_range1",
"Prims.b2t",
"Vale.X64.Decls.va_get_ok",
"Vale.X64.Decls.modifies_buffer128",
"Vale.X64.Decls.va_get_mem_heaplet",
"Vale.AES.GCTR.gctr_partial",
"Vale.X64.Decls.va_get_reg64",
"Vale.X64.Decls.s128",
"Vale.X64.Decls.va_get_xmm",
"Vale.Def.Types_s.quad32",
"Vale.AES.GCTR.inc32lite",
"Prims.l_imp",
"Prims.int",
"Prims.op_GreaterThan",
"Prims.op_LessThanOrEqual",
"FStar.Seq.Base.length",
"FStar.Seq.Base.slice",
"Vale.Def.Types_s.reverse_bytes_quad32",
"Vale.AES.GHash.ghash_incremental",
"Vale.X64.QuickCode.quickCode",
"Vale.AES.X64.GCMdecryptOpt.va_qcode_Gcm_blocks128"
] | [] | false | false | false | false | false | let va_lemma_Gcm_blocks128 va_b0 va_s0 alg in_b out_b key round_keys keys_b hkeys_b h_LE =
| let va_mods:va_mods_t =
[
va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0;
va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10; va_Mod_reg64 rR11; va_Mod_reg64 rRdi;
va_Mod_reg64 rRbx; va_Mod_ok; va_Mod_mem
]
in
let va_qc = va_qcode_Gcm_blocks128 va_mods alg in_b out_b key round_keys keys_b hkeys_b h_LE in
let va_sM, va_fM, va_g =
va_wp_sound_code_norm (va_code_Gcm_blocks128 alg)
va_qc
va_s0
(fun va_s0 va_sM va_g ->
let () = va_g in
label va_range1
"***** POSTCONDITION NOT MET AT line 210 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\
(label va_range1
"***** POSTCONDITION NOT MET AT line 255 column 53 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out_b
(va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM)) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 261 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg
(va_get_reg64 rRdx va_s0)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b)
key
(va_get_xmm 11 va_s0)) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 262 column 45 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 11 va_sM ==
Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0) (va_get_reg64 rRdx va_s0)) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 265 column 93 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRdx va_s0 == 0 ==>
l_and (va_get_xmm 8 va_sM == va_get_xmm 8 va_s0)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b ==
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 267 column 131 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRdx va_s0 > 0 ==>
l_and (va_get_reg64 rRdx va_s0 <=
FStar.Seq.Base.length #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==>
FStar.Seq.Base.length #Vale.X64.Decls.quad32
(FStar.Seq.Base.slice #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)
0
(va_get_reg64 rRdx va_s0)) >
0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) ==
Vale.AES.GHash.ghash_incremental h_LE
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)))))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([
va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10; va_Mod_reg64 rR11;
va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_ok; va_Mod_mem
])
va_sM
va_s0;
(va_sM, va_fM) | false |
LowStar.Lib.LinkedList.fst | LowStar.Lib.LinkedList.same_cells_same_pointer | val same_cells_same_pointer (#a: _) (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a)
: Lemma
(requires
(well_formed h0 ll0 l0 /\ well_formed h1 ll1 l1 /\ cells h0 ll0 l0 == cells h1 ll1 l1))
(ensures (ll0 == ll1))
[SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1)] | val same_cells_same_pointer (#a: _) (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a)
: Lemma
(requires
(well_formed h0 ll0 l0 /\ well_formed h1 ll1 l1 /\ cells h0 ll0 l0 == cells h1 ll1 l1))
(ensures (ll0 == ll1))
[SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1)] | let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma
(requires (
well_formed h0 ll0 l0 /\
well_formed h1 ll1 l1 /\
cells h0 ll0 l0 == cells h1 ll1 l1))
(ensures (
ll0 == ll1))
[ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ]
=
if B.g_is_null ll0 && B.g_is_null ll1 then begin
B.null_unique ll0;
B.null_unique ll1
end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin
()
end else
false_elim () | {
"file_name": "krmllib/LowStar.Lib.LinkedList.fst",
"git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} | {
"end_col": 17,
"end_line": 120,
"start_col": 0,
"start_line": 105
} | module LowStar.Lib.LinkedList
/// This module, oftentimes referred to as LL1 in other parts of the
/// documentation, provides a low-level view over a linked list. Unless you
/// intend on modifying the structure of the linked list (e.g. removing cells)
/// or iterating over each cell, your are probably better off using LL2.
///
/// This module is intentionally not relying on a tight abstraction, to i) permit
/// direct-style iteration by clients and ii) allow stating some SMTPat lemmas
/// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can
/// happen automatically at the SMT level since LL2 does not have an fsti either).
///
/// Some open questions relative to the design of this module:
/// - should ``v`` be defined directly in terms of ``cells`` rather than have a
/// recursive definition along with an equivalence lemma?
/// - should ``footprint`` be defined directly in terms of ``cells`` rather than
/// have a recursive definition along with an equivalence lemma?
/// - is it worth the trouble defining a footprint? my intuition is that it's
/// fine and allows some clients to do very precise reasoning -- other modules
/// (e.g. AssocList), when establishing abstraction boundaries, can simplify
/// things and get rid of the precise footprint reasoning in favor of a static
/// region-based footprint
///
/// Some remaining work items:
/// - switch to C.Loops.while
open LowStar.BufferOps
module B = LowStar.Buffer
module HS = FStar.HyperStack
module G = FStar.Ghost
module L = FStar.List.Tot
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
open FStar.HyperStack.ST
/// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since
/// everything does recursive list reasoning.
#set-options "--__no_positivity --fuel 1 --ifuel 1"
/// Definition of the Low* type
/// ---------------------------
noeq
type t (a: Type0) =
B.pointer_or_null (cell a)
and cell (a: Type0) = {
next: t a;
data: a;
}
/// Unlike the canonical style that associates a ``v`` function to any stateful
/// representation, we use a relation here. Writing a function is just
/// impossible, since we can't prove termination of ``v`` owing to the fact that
/// there may be an infinite number of cells in the heap.
///
/// LL2 is the module that switches to the function style.
///
/// Note: no need to use erased here for ``l`` since the function is already in ``GTot``.
let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) =
B.live h c /\ (
match l with
| [] ->
B.g_is_null c
| a :: q ->
B.length c == 1 /\ (
let { data=data; next=next } = B.get h c 0 in
a == data /\
well_formed h next (G.hide q)
))
/// Precise reasoning via the cells predicate
/// -----------------------------------------
///
/// The modifies clauses are given either on the footprint of the list, or on a
/// region that includes the footprint of the list (higher up the stack, e.g.
/// LL2). This is good, but does not rule out "stupid" implementations that
/// might re-allocate every single list cell when, say, doing a pop.
///
/// For advanced usages which take pointers directly to individual list cells,
/// it's important to rule out these cases. We thus define the ``cells``
/// predicate for that purpose.
let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a)))
(requires well_formed h c l)
(ensures fun _ -> True)
(decreases l)
=
if B.g_is_null c then
[]
else
c :: cells h (B.deref h c).next (List.Tot.tl l)
/// A missing bit of automated reasoning
/// ------------------------------------
/// This should be absolutely trivial, yet, because there's no pattern on
/// null_unique, we have to do the case analysis and the decomposition
/// ourselves. This is quite tedious, as it usually takes a while (at least it
/// did for me!) to realize that this property does not hold automatically.
///
/// I'm setting an SMTPat on this lemma because it's absolutely impossible to | {
"checked_file": "/",
"dependencies": [
"TestLib.fsti.checked",
"prims.fst.checked",
"LowStar.Failure.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int32.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Lib.LinkedList.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem ->
ll0: LowStar.Lib.LinkedList.t a ->
ll1: LowStar.Lib.LinkedList.t a ->
l0: Prims.list a ->
l1: Prims.list a
-> FStar.Pervasives.Lemma
(requires
LowStar.Lib.LinkedList.well_formed h0 ll0 l0 /\ LowStar.Lib.LinkedList.well_formed h1 ll1 l1 /\
LowStar.Lib.LinkedList.cells h0 ll0 l0 == LowStar.Lib.LinkedList.cells h1 ll1 l1)
(ensures ll0 == ll1)
[
SMTPat (LowStar.Lib.LinkedList.cells h0 ll0 l0);
SMTPat (LowStar.Lib.LinkedList.cells h1 ll1 l1)
] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"LowStar.Lib.LinkedList.t",
"Prims.list",
"Prims.op_AmpAmp",
"LowStar.Monotonic.Buffer.g_is_null",
"LowStar.Lib.LinkedList.cell",
"LowStar.Buffer.trivial_preorder",
"LowStar.Monotonic.Buffer.null_unique",
"Prims.unit",
"Prims.bool",
"Prims.op_Negation",
"FStar.Pervasives.false_elim",
"Prims.l_and",
"LowStar.Lib.LinkedList.well_formed",
"Prims.eq2",
"LowStar.Buffer.pointer",
"LowStar.Lib.LinkedList.cells",
"Prims.squash",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil"
] | [] | false | false | true | false | false | let same_cells_same_pointer
#a
(h0: HS.mem)
(h1: HS.mem)
(ll0: t a)
(ll1: t a)
(l0: list a)
(l1: list a)
: Lemma
(requires
(well_formed h0 ll0 l0 /\ well_formed h1 ll1 l1 /\ cells h0 ll0 l0 == cells h1 ll1 l1))
(ensures (ll0 == ll1))
[SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1)] =
| if B.g_is_null ll0 && B.g_is_null ll1
then
(B.null_unique ll0;
B.null_unique ll1)
else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then () else false_elim () | false |
LowStar.Lib.LinkedList.fst | LowStar.Lib.LinkedList.gfold_right | val gfold_right (#a #b: _) (f: (b -> a -> GTot b)) (xs: list a) (acc: b)
: Ghost b (requires True) (ensures fun _ -> True) (decreases xs) | val gfold_right (#a #b: _) (f: (b -> a -> GTot b)) (xs: list a) (acc: b)
: Ghost b (requires True) (ensures fun _ -> True) (decreases xs) | let rec gfold_right #a #b (f: b -> a -> GTot b) (xs: list a) (acc: b): Ghost b
(requires True)
(ensures fun _ -> True)
(decreases xs)
=
match xs with
| [] -> acc
| x :: xs -> f (gfold_right f xs acc) x | {
"file_name": "krmllib/LowStar.Lib.LinkedList.fst",
"git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} | {
"end_col": 41,
"end_line": 264,
"start_col": 0,
"start_line": 257
} | module LowStar.Lib.LinkedList
/// This module, oftentimes referred to as LL1 in other parts of the
/// documentation, provides a low-level view over a linked list. Unless you
/// intend on modifying the structure of the linked list (e.g. removing cells)
/// or iterating over each cell, your are probably better off using LL2.
///
/// This module is intentionally not relying on a tight abstraction, to i) permit
/// direct-style iteration by clients and ii) allow stating some SMTPat lemmas
/// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can
/// happen automatically at the SMT level since LL2 does not have an fsti either).
///
/// Some open questions relative to the design of this module:
/// - should ``v`` be defined directly in terms of ``cells`` rather than have a
/// recursive definition along with an equivalence lemma?
/// - should ``footprint`` be defined directly in terms of ``cells`` rather than
/// have a recursive definition along with an equivalence lemma?
/// - is it worth the trouble defining a footprint? my intuition is that it's
/// fine and allows some clients to do very precise reasoning -- other modules
/// (e.g. AssocList), when establishing abstraction boundaries, can simplify
/// things and get rid of the precise footprint reasoning in favor of a static
/// region-based footprint
///
/// Some remaining work items:
/// - switch to C.Loops.while
open LowStar.BufferOps
module B = LowStar.Buffer
module HS = FStar.HyperStack
module G = FStar.Ghost
module L = FStar.List.Tot
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
open FStar.HyperStack.ST
/// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since
/// everything does recursive list reasoning.
#set-options "--__no_positivity --fuel 1 --ifuel 1"
/// Definition of the Low* type
/// ---------------------------
noeq
type t (a: Type0) =
B.pointer_or_null (cell a)
and cell (a: Type0) = {
next: t a;
data: a;
}
/// Unlike the canonical style that associates a ``v`` function to any stateful
/// representation, we use a relation here. Writing a function is just
/// impossible, since we can't prove termination of ``v`` owing to the fact that
/// there may be an infinite number of cells in the heap.
///
/// LL2 is the module that switches to the function style.
///
/// Note: no need to use erased here for ``l`` since the function is already in ``GTot``.
let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) =
B.live h c /\ (
match l with
| [] ->
B.g_is_null c
| a :: q ->
B.length c == 1 /\ (
let { data=data; next=next } = B.get h c 0 in
a == data /\
well_formed h next (G.hide q)
))
/// Precise reasoning via the cells predicate
/// -----------------------------------------
///
/// The modifies clauses are given either on the footprint of the list, or on a
/// region that includes the footprint of the list (higher up the stack, e.g.
/// LL2). This is good, but does not rule out "stupid" implementations that
/// might re-allocate every single list cell when, say, doing a pop.
///
/// For advanced usages which take pointers directly to individual list cells,
/// it's important to rule out these cases. We thus define the ``cells``
/// predicate for that purpose.
let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a)))
(requires well_formed h c l)
(ensures fun _ -> True)
(decreases l)
=
if B.g_is_null c then
[]
else
c :: cells h (B.deref h c).next (List.Tot.tl l)
/// A missing bit of automated reasoning
/// ------------------------------------
/// This should be absolutely trivial, yet, because there's no pattern on
/// null_unique, we have to do the case analysis and the decomposition
/// ourselves. This is quite tedious, as it usually takes a while (at least it
/// did for me!) to realize that this property does not hold automatically.
///
/// I'm setting an SMTPat on this lemma because it's absolutely impossible to
/// get any work done without it.
let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma
(requires (
well_formed h0 ll0 l0 /\
well_formed h1 ll1 l1 /\
cells h0 ll0 l0 == cells h1 ll1 l1))
(ensures (
ll0 == ll1))
[ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ]
=
if B.g_is_null ll0 && B.g_is_null ll1 then begin
B.null_unique ll0;
B.null_unique ll1
end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin
()
end else
false_elim ()
/// Classic stateful reasoning lemmas
/// ---------------------------------
///
/// This essentially follows ``stateful``, the type class of a mutable piece of
/// state defined using the modifies-theory of Low*v2 and equipped with the
/// right lemmas to enable usage by clients. See
/// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context.
val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc
(requires (well_formed h l n))
(ensures (fun refs -> True))
(decreases n)
let rec footprint #a h l n =
if B.g_is_null l
then B.loc_none
else
let {next = next} = B.get h l 0 in
let refs = footprint h next (G.hide (L.tl n)) in
B.loc_union (B.loc_addr_of_buffer l) refs
/// Departing from LinkedList4 here. I prefer to bolt these into the invariant
/// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to
/// deduce these.
val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_pairwise_disjoint #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\
cells_pairwise_disjoint h next (L.tl n)
val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_live_freeable #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.live h l /\ B.freeable l /\
cells_live_freeable h next (L.tl n)
val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let invariant #a h l n =
cells_live_freeable h l n /\ cells_pairwise_disjoint h l n
/// Normally this would be automatic and writing a custom lemma for that stuff
/// would be needed only when writing an fsti, however, as stated earlier,
/// recursion makes everything more difficult and this absolutely needs to be in
/// scope otherwise the modifies-clause theory cannot deduce disjointness of
/// fresh allocations w.r.t. the footprint.
let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a): Lemma
(requires well_formed h l n)
(ensures B.loc_in (footprint h l n) h)
(decreases n)
[ SMTPat (invariant h l n) ]
=
if B.g_is_null l then
()
else
let next = (B.deref h l).next in
invariant_loc_in_footprint h next (L.tl n)
/// Another absolutely essential lemma, for which interestingly the pattern
/// "invariant h1 l n" does not work, but well_formed does... I guess that's
/// alright.
let rec frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem): Lemma
(requires (
well_formed h0 l n /\
invariant h0 l n /\
B.loc_disjoint r (footprint h0 l n) /\
B.modifies r h0 h1
))
(ensures (
well_formed h1 l n /\
footprint h1 l n == footprint h0 l n /\
cells h1 l n == cells h0 l n /\
invariant h1 l n
))
(decreases n)
[ SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1) ]
=
if B.g_is_null l then
()
else
frame (B.deref h0 l).next (L.tl n) r h0 h1
/// Lemmas for working with linked lists
/// ------------------------------------
///
/// Since it's a recursive data structure, a lot of the automated reasoning from
/// LowStar.Buffer doesn't work since it requires inductions. Some helpful
/// properties are therefore proved here.
let rec length_functional #a (h: HS.mem) (c: t a) (l1 l2: list a):
Lemma
(requires (well_formed h c l1 /\ well_formed h c l2))
(ensures (l1 == l2))
(decreases (G.reveal l1))
[ SMTPat (well_formed h c l1); SMTPat (well_formed h c l2) ] =
if B.g_is_null c
then ()
else
let { next=next } = B.get h c 0 in
length_functional h next (G.hide (L.tl l1)) (G.hide (L.tl l2))
/// The footprint is based on loc_addr_of_buffer so that we can write a free
/// operation that operates on the footprint. However, this invalidates most of
/// the helper lemmas for disjointness that were present in the previous
/// iteration of this module, named LinkedList4.fst. It's ok, we bake
/// disjointness directly onto the invariant and it works just as well.
/// Connection between ``cells`` and ``v``
/// --------------------------------------
/// Redefining some helpers.
#push-options "--ifuel 1"
let rec gmap #a #b (f: a -> GTot b) (xs: list a): GTot (list b) =
match xs with
| [] -> []
| x :: xs -> f x :: gmap f xs
/// "As we all know", right folds are the easiest to work with because they | {
"checked_file": "/",
"dependencies": [
"TestLib.fsti.checked",
"prims.fst.checked",
"LowStar.Failure.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int32.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Lib.LinkedList.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | f: (_: b -> _: a -> Prims.GTot b) -> xs: Prims.list a -> acc: b -> Prims.Ghost b | Prims.Ghost | [
""
] | [] | [
"Prims.list",
"LowStar.Lib.LinkedList.gfold_right",
"Prims.l_True"
] | [
"recursion"
] | false | false | false | false | false | let rec gfold_right #a #b (f: (b -> a -> GTot b)) (xs: list a) (acc: b)
: Ghost b (requires True) (ensures fun _ -> True) (decreases xs) =
| match xs with
| [] -> acc
| x :: xs -> f (gfold_right f xs acc) x | false |
Spec.Box.fst | Spec.Box.box_open_easy | val box_open_easy
(pk: secretkey)
(sk: publickey)
(n: nonce)
(c: bytes{length c >= size_tag /\ (length c - size_tag) / size_block <= max_size_t})
: option (m: bytes{length m = length c - size_tag}) | val box_open_easy
(pk: secretkey)
(sk: publickey)
(n: nonce)
(c: bytes{length c >= size_tag /\ (length c - size_tag) / size_block <= max_size_t})
: option (m: bytes{length m = length c - size_tag}) | let box_open_easy (pk:secretkey) (sk:publickey) (n:nonce) (c:bytes{length c >= size_tag /\ (length c - size_tag) / size_block <= max_size_t}) : option (m:bytes{length m = length c - size_tag}) =
let tg = Seq.slice c 0 size_tag in
let e = Seq.slice c size_tag (length c) in
box_open_detached pk sk n tg e | {
"file_name": "specs/Spec.Box.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 32,
"end_line": 77,
"start_col": 0,
"start_line": 74
} | module Spec.Box
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
open Spec.SecretBox
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
(* Constants *)
let size_publickey = 32 (* in bytes *)
let size_secretkey = 32 (* in bytes *)
type publickey = lbytes size_publickey
type secretkey = lbytes size_secretkey
let ecdh (pk:publickey) (sk:secretkey) : option secretkey =
let shared = Spec.Curve25519.scalarmult sk pk in
if not (lbytes_eq shared (create 32 (u8 0))) then
Some shared
else None
let box_beforenm (pk:publickey) (sk:secretkey) : option key =
let shared = ecdh pk sk in
match shared with
| Some shared -> Some (Spec.Salsa20.hsalsa20 shared (create 16 (u8 0)))
| None -> None
let box_detached_afternm (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : tag & c:bytes{length c = length m} =
secretbox_detached k n m
let box_detached (sk:secretkey) (pk:publickey) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : option (tag & c:bytes{length c = length m}) =
let k = box_beforenm pk sk in
match k with
| Some k -> Some (box_detached_afternm k n m)
| None -> None
let box_open_detached_afternm (k:key) (n:nonce) (t:tag) (c:bytes{length c / size_block <= max_size_t}) : option (m:bytes{length m = length c}) =
secretbox_open_detached k n t c
let box_open_detached (pk:publickey) (sk:secretkey) (n:nonce) (t:tag) (c:bytes{length c / size_block <= max_size_t}) : option (m:bytes{length m = length c}) =
let k = box_beforenm pk sk in
match k with
| Some k -> box_open_detached_afternm k n t c
| None -> None
let box_easy_afternm (k:key) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : c:bytes{length c = size_tag + length m} =
let (tg, c) = box_detached_afternm k n m in
Seq.append tg c
let box_easy (sk:secretkey) (pk:publickey) (n:nonce) (m:bytes{length m / size_block <= max_size_t}) : option (c:bytes{length c = size_tag + length m}) =
let r = box_detached sk pk n m in
match r with
| Some (tg, c) -> Some (Seq.append tg c)
| None -> None
let box_open_easy_afternm (k:key) (n:nonce) (c:bytes{length c >= size_tag /\ (length c - size_tag) / size_block <= max_size_t}) : option (m:bytes{length m = length c - size_tag}) =
let tg = Seq.slice c 0 size_tag in
let e = Seq.slice c size_tag (length c) in
box_open_detached_afternm k n tg e | {
"checked_file": "/",
"dependencies": [
"Spec.SecretBox.fst.checked",
"Spec.Salsa20.fst.checked",
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Box.fst"
} | [
{
"abbrev": false,
"full_module": "Spec.SecretBox",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
pk: Spec.Box.secretkey ->
sk: Spec.Box.publickey ->
n: Spec.SecretBox.nonce ->
c:
Lib.ByteSequence.bytes
{ Lib.Sequence.length c >= Spec.SecretBox.size_tag /\
(Lib.Sequence.length c - Spec.SecretBox.size_tag) / Spec.SecretBox.size_block <=
Lib.IntTypes.max_size_t }
-> FStar.Pervasives.Native.option (m:
Lib.ByteSequence.bytes
{Lib.Sequence.length m = Lib.Sequence.length c - Spec.SecretBox.size_tag}) | Prims.Tot | [
"total"
] | [] | [
"Spec.Box.secretkey",
"Spec.Box.publickey",
"Spec.SecretBox.nonce",
"Lib.ByteSequence.bytes",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Lib.Sequence.length",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.SecretBox.size_tag",
"Prims.op_LessThanOrEqual",
"Prims.op_Division",
"Prims.op_Subtraction",
"Spec.SecretBox.size_block",
"Lib.IntTypes.max_size_t",
"Spec.Box.box_open_detached",
"FStar.Seq.Base.seq",
"Lib.IntTypes.int_t",
"FStar.Seq.Base.slice",
"FStar.Pervasives.Native.option",
"Prims.op_Equality",
"Prims.int"
] | [] | false | false | false | false | false | let box_open_easy
(pk: secretkey)
(sk: publickey)
(n: nonce)
(c: bytes{length c >= size_tag /\ (length c - size_tag) / size_block <= max_size_t})
: option (m: bytes{length m = length c - size_tag}) =
| let tg = Seq.slice c 0 size_tag in
let e = Seq.slice c size_tag (length c) in
box_open_detached pk sk n tg e | false |
LowStar.Lib.LinkedList.fst | LowStar.Lib.LinkedList.footprint_via_cells_is_footprint | val footprint_via_cells_is_footprint (#a: _) (h: HS.mem) (ll: t a) (l: list a)
: Lemma (requires well_formed h ll l)
(ensures
footprint h ll l ==
(gfold_right B.loc_union (gmap B.loc_addr_of_buffer (cells h ll l)) B.loc_none))
(decreases l) | val footprint_via_cells_is_footprint (#a: _) (h: HS.mem) (ll: t a) (l: list a)
: Lemma (requires well_formed h ll l)
(ensures
footprint h ll l ==
(gfold_right B.loc_union (gmap B.loc_addr_of_buffer (cells h ll l)) B.loc_none))
(decreases l) | let rec footprint_via_cells_is_footprint #a (h: HS.mem) (ll: t a) (l: list a): Lemma
(requires well_formed h ll l)
(ensures
footprint h ll l == (gfold_right B.loc_union (gmap B.loc_addr_of_buffer (cells h ll l)) B.loc_none))
(decreases l)
=
if B.g_is_null ll then
()
else
footprint_via_cells_is_footprint h (B.deref h ll).next (List.Tot.tl l) | {
"file_name": "krmllib/LowStar.Lib.LinkedList.fst",
"git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} | {
"end_col": 74,
"end_line": 313,
"start_col": 0,
"start_line": 304
} | module LowStar.Lib.LinkedList
/// This module, oftentimes referred to as LL1 in other parts of the
/// documentation, provides a low-level view over a linked list. Unless you
/// intend on modifying the structure of the linked list (e.g. removing cells)
/// or iterating over each cell, your are probably better off using LL2.
///
/// This module is intentionally not relying on a tight abstraction, to i) permit
/// direct-style iteration by clients and ii) allow stating some SMTPat lemmas
/// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can
/// happen automatically at the SMT level since LL2 does not have an fsti either).
///
/// Some open questions relative to the design of this module:
/// - should ``v`` be defined directly in terms of ``cells`` rather than have a
/// recursive definition along with an equivalence lemma?
/// - should ``footprint`` be defined directly in terms of ``cells`` rather than
/// have a recursive definition along with an equivalence lemma?
/// - is it worth the trouble defining a footprint? my intuition is that it's
/// fine and allows some clients to do very precise reasoning -- other modules
/// (e.g. AssocList), when establishing abstraction boundaries, can simplify
/// things and get rid of the precise footprint reasoning in favor of a static
/// region-based footprint
///
/// Some remaining work items:
/// - switch to C.Loops.while
open LowStar.BufferOps
module B = LowStar.Buffer
module HS = FStar.HyperStack
module G = FStar.Ghost
module L = FStar.List.Tot
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
open FStar.HyperStack.ST
/// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since
/// everything does recursive list reasoning.
#set-options "--__no_positivity --fuel 1 --ifuel 1"
/// Definition of the Low* type
/// ---------------------------
noeq
type t (a: Type0) =
B.pointer_or_null (cell a)
and cell (a: Type0) = {
next: t a;
data: a;
}
/// Unlike the canonical style that associates a ``v`` function to any stateful
/// representation, we use a relation here. Writing a function is just
/// impossible, since we can't prove termination of ``v`` owing to the fact that
/// there may be an infinite number of cells in the heap.
///
/// LL2 is the module that switches to the function style.
///
/// Note: no need to use erased here for ``l`` since the function is already in ``GTot``.
let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) =
B.live h c /\ (
match l with
| [] ->
B.g_is_null c
| a :: q ->
B.length c == 1 /\ (
let { data=data; next=next } = B.get h c 0 in
a == data /\
well_formed h next (G.hide q)
))
/// Precise reasoning via the cells predicate
/// -----------------------------------------
///
/// The modifies clauses are given either on the footprint of the list, or on a
/// region that includes the footprint of the list (higher up the stack, e.g.
/// LL2). This is good, but does not rule out "stupid" implementations that
/// might re-allocate every single list cell when, say, doing a pop.
///
/// For advanced usages which take pointers directly to individual list cells,
/// it's important to rule out these cases. We thus define the ``cells``
/// predicate for that purpose.
let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a)))
(requires well_formed h c l)
(ensures fun _ -> True)
(decreases l)
=
if B.g_is_null c then
[]
else
c :: cells h (B.deref h c).next (List.Tot.tl l)
/// A missing bit of automated reasoning
/// ------------------------------------
/// This should be absolutely trivial, yet, because there's no pattern on
/// null_unique, we have to do the case analysis and the decomposition
/// ourselves. This is quite tedious, as it usually takes a while (at least it
/// did for me!) to realize that this property does not hold automatically.
///
/// I'm setting an SMTPat on this lemma because it's absolutely impossible to
/// get any work done without it.
let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma
(requires (
well_formed h0 ll0 l0 /\
well_formed h1 ll1 l1 /\
cells h0 ll0 l0 == cells h1 ll1 l1))
(ensures (
ll0 == ll1))
[ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ]
=
if B.g_is_null ll0 && B.g_is_null ll1 then begin
B.null_unique ll0;
B.null_unique ll1
end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin
()
end else
false_elim ()
/// Classic stateful reasoning lemmas
/// ---------------------------------
///
/// This essentially follows ``stateful``, the type class of a mutable piece of
/// state defined using the modifies-theory of Low*v2 and equipped with the
/// right lemmas to enable usage by clients. See
/// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context.
val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc
(requires (well_formed h l n))
(ensures (fun refs -> True))
(decreases n)
let rec footprint #a h l n =
if B.g_is_null l
then B.loc_none
else
let {next = next} = B.get h l 0 in
let refs = footprint h next (G.hide (L.tl n)) in
B.loc_union (B.loc_addr_of_buffer l) refs
/// Departing from LinkedList4 here. I prefer to bolt these into the invariant
/// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to
/// deduce these.
val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_pairwise_disjoint #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\
cells_pairwise_disjoint h next (L.tl n)
val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_live_freeable #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.live h l /\ B.freeable l /\
cells_live_freeable h next (L.tl n)
val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let invariant #a h l n =
cells_live_freeable h l n /\ cells_pairwise_disjoint h l n
/// Normally this would be automatic and writing a custom lemma for that stuff
/// would be needed only when writing an fsti, however, as stated earlier,
/// recursion makes everything more difficult and this absolutely needs to be in
/// scope otherwise the modifies-clause theory cannot deduce disjointness of
/// fresh allocations w.r.t. the footprint.
let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a): Lemma
(requires well_formed h l n)
(ensures B.loc_in (footprint h l n) h)
(decreases n)
[ SMTPat (invariant h l n) ]
=
if B.g_is_null l then
()
else
let next = (B.deref h l).next in
invariant_loc_in_footprint h next (L.tl n)
/// Another absolutely essential lemma, for which interestingly the pattern
/// "invariant h1 l n" does not work, but well_formed does... I guess that's
/// alright.
let rec frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem): Lemma
(requires (
well_formed h0 l n /\
invariant h0 l n /\
B.loc_disjoint r (footprint h0 l n) /\
B.modifies r h0 h1
))
(ensures (
well_formed h1 l n /\
footprint h1 l n == footprint h0 l n /\
cells h1 l n == cells h0 l n /\
invariant h1 l n
))
(decreases n)
[ SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1) ]
=
if B.g_is_null l then
()
else
frame (B.deref h0 l).next (L.tl n) r h0 h1
/// Lemmas for working with linked lists
/// ------------------------------------
///
/// Since it's a recursive data structure, a lot of the automated reasoning from
/// LowStar.Buffer doesn't work since it requires inductions. Some helpful
/// properties are therefore proved here.
let rec length_functional #a (h: HS.mem) (c: t a) (l1 l2: list a):
Lemma
(requires (well_formed h c l1 /\ well_formed h c l2))
(ensures (l1 == l2))
(decreases (G.reveal l1))
[ SMTPat (well_formed h c l1); SMTPat (well_formed h c l2) ] =
if B.g_is_null c
then ()
else
let { next=next } = B.get h c 0 in
length_functional h next (G.hide (L.tl l1)) (G.hide (L.tl l2))
/// The footprint is based on loc_addr_of_buffer so that we can write a free
/// operation that operates on the footprint. However, this invalidates most of
/// the helper lemmas for disjointness that were present in the previous
/// iteration of this module, named LinkedList4.fst. It's ok, we bake
/// disjointness directly onto the invariant and it works just as well.
/// Connection between ``cells`` and ``v``
/// --------------------------------------
/// Redefining some helpers.
#push-options "--ifuel 1"
let rec gmap #a #b (f: a -> GTot b) (xs: list a): GTot (list b) =
match xs with
| [] -> []
| x :: xs -> f x :: gmap f xs
/// "As we all know", right folds are the easiest to work with because they
/// follow the natural structure of recursion (left-folds are evil).
let rec gfold_right #a #b (f: b -> a -> GTot b) (xs: list a) (acc: b): Ghost b
(requires True)
(ensures fun _ -> True)
(decreases xs)
=
match xs with
| [] -> acc
| x :: xs -> f (gfold_right f xs acc) x
#pop-options
/// Connecting ``v`` and ``cells``.
///
/// See ``tests/Wireguard.fst`` for why going through gmap is important and how
/// to structure your definitions (should you need to reason about ``cells``) in
/// a way that will make your life easier.
let deref_data #a (h: HS.mem) (c: B.pointer (cell a)): GTot a =
(B.deref h c).data
#push-options "--fuel 1 --ifuel 1"
let rec deref_cells_is_v #a (h: HS.mem) (ll: t a) (l: list a): Lemma
(requires
well_formed h ll l /\
invariant h ll l)
(ensures
gmap (deref_data h) (cells h ll l) == l)
(decreases l)
[ SMTPat (well_formed h ll l) ]
=
if B.g_is_null ll then
()
else
deref_cells_is_v h (B.deref h ll).next (List.Tot.tl l)
#pop-options
/// Connecting ``footprint`` and ``cells``.
///
/// This allows conveniently switching to a low-level representation of the
/// footprint in case clients want to do some ultra-precise reasoning about
/// what's happening with the list spine. However, the fact that all
/// operations from this module specify things in terms of ``cells`` along with
/// ``same_cells_same_pointer`` should cover most common cases. (This predates
/// the introduction of ``same_cells_same_pointer``.)
///
/// So, no SMTPat here. Note, I also used the same trick as above with
/// higher-order combinators to isolate the use of the argument ``h`` to a
/// single sub-term rather than having it passed down the recursive calls. | {
"checked_file": "/",
"dependencies": [
"TestLib.fsti.checked",
"prims.fst.checked",
"LowStar.Failure.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int32.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Lib.LinkedList.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 2,
"max_fuel": 2,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> ll: LowStar.Lib.LinkedList.t a -> l: Prims.list a
-> FStar.Pervasives.Lemma (requires LowStar.Lib.LinkedList.well_formed h ll l)
(ensures
LowStar.Lib.LinkedList.footprint h ll l ==
LowStar.Lib.LinkedList.gfold_right LowStar.Monotonic.Buffer.loc_union
(LowStar.Lib.LinkedList.gmap LowStar.Monotonic.Buffer.loc_addr_of_buffer
(LowStar.Lib.LinkedList.cells h ll l))
LowStar.Monotonic.Buffer.loc_none)
(decreases l) | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"LowStar.Lib.LinkedList.t",
"Prims.list",
"LowStar.Monotonic.Buffer.g_is_null",
"LowStar.Lib.LinkedList.cell",
"LowStar.Buffer.trivial_preorder",
"Prims.bool",
"LowStar.Lib.LinkedList.footprint_via_cells_is_footprint",
"LowStar.Lib.LinkedList.__proj__Mkcell__item__next",
"LowStar.Monotonic.Buffer.deref",
"FStar.List.Tot.Base.tl",
"Prims.unit",
"LowStar.Lib.LinkedList.well_formed",
"Prims.squash",
"Prims.eq2",
"LowStar.Monotonic.Buffer.loc",
"LowStar.Lib.LinkedList.footprint",
"LowStar.Lib.LinkedList.gfold_right",
"LowStar.Monotonic.Buffer.loc_union",
"LowStar.Lib.LinkedList.gmap",
"LowStar.Buffer.pointer",
"LowStar.Monotonic.Buffer.loc_addr_of_buffer",
"LowStar.Lib.LinkedList.cells",
"LowStar.Monotonic.Buffer.loc_none",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec footprint_via_cells_is_footprint #a (h: HS.mem) (ll: t a) (l: list a)
: Lemma (requires well_formed h ll l)
(ensures
footprint h ll l ==
(gfold_right B.loc_union (gmap B.loc_addr_of_buffer (cells h ll l)) B.loc_none))
(decreases l) =
| if B.g_is_null ll
then ()
else footprint_via_cells_is_footprint h (B.deref h ll).next (List.Tot.tl l) | false |
LowStar.Lib.LinkedList.fst | LowStar.Lib.LinkedList.cells_live_freeable | val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n) | val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n) | let rec cells_live_freeable #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.live h l /\ B.freeable l /\
cells_live_freeable h next (L.tl n) | {
"file_name": "krmllib/LowStar.Lib.LinkedList.fst",
"git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} | {
"end_col": 39,
"end_line": 170,
"start_col": 0,
"start_line": 164
} | module LowStar.Lib.LinkedList
/// This module, oftentimes referred to as LL1 in other parts of the
/// documentation, provides a low-level view over a linked list. Unless you
/// intend on modifying the structure of the linked list (e.g. removing cells)
/// or iterating over each cell, your are probably better off using LL2.
///
/// This module is intentionally not relying on a tight abstraction, to i) permit
/// direct-style iteration by clients and ii) allow stating some SMTPat lemmas
/// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can
/// happen automatically at the SMT level since LL2 does not have an fsti either).
///
/// Some open questions relative to the design of this module:
/// - should ``v`` be defined directly in terms of ``cells`` rather than have a
/// recursive definition along with an equivalence lemma?
/// - should ``footprint`` be defined directly in terms of ``cells`` rather than
/// have a recursive definition along with an equivalence lemma?
/// - is it worth the trouble defining a footprint? my intuition is that it's
/// fine and allows some clients to do very precise reasoning -- other modules
/// (e.g. AssocList), when establishing abstraction boundaries, can simplify
/// things and get rid of the precise footprint reasoning in favor of a static
/// region-based footprint
///
/// Some remaining work items:
/// - switch to C.Loops.while
open LowStar.BufferOps
module B = LowStar.Buffer
module HS = FStar.HyperStack
module G = FStar.Ghost
module L = FStar.List.Tot
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
open FStar.HyperStack.ST
/// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since
/// everything does recursive list reasoning.
#set-options "--__no_positivity --fuel 1 --ifuel 1"
/// Definition of the Low* type
/// ---------------------------
noeq
type t (a: Type0) =
B.pointer_or_null (cell a)
and cell (a: Type0) = {
next: t a;
data: a;
}
/// Unlike the canonical style that associates a ``v`` function to any stateful
/// representation, we use a relation here. Writing a function is just
/// impossible, since we can't prove termination of ``v`` owing to the fact that
/// there may be an infinite number of cells in the heap.
///
/// LL2 is the module that switches to the function style.
///
/// Note: no need to use erased here for ``l`` since the function is already in ``GTot``.
let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) =
B.live h c /\ (
match l with
| [] ->
B.g_is_null c
| a :: q ->
B.length c == 1 /\ (
let { data=data; next=next } = B.get h c 0 in
a == data /\
well_formed h next (G.hide q)
))
/// Precise reasoning via the cells predicate
/// -----------------------------------------
///
/// The modifies clauses are given either on the footprint of the list, or on a
/// region that includes the footprint of the list (higher up the stack, e.g.
/// LL2). This is good, but does not rule out "stupid" implementations that
/// might re-allocate every single list cell when, say, doing a pop.
///
/// For advanced usages which take pointers directly to individual list cells,
/// it's important to rule out these cases. We thus define the ``cells``
/// predicate for that purpose.
let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a)))
(requires well_formed h c l)
(ensures fun _ -> True)
(decreases l)
=
if B.g_is_null c then
[]
else
c :: cells h (B.deref h c).next (List.Tot.tl l)
/// A missing bit of automated reasoning
/// ------------------------------------
/// This should be absolutely trivial, yet, because there's no pattern on
/// null_unique, we have to do the case analysis and the decomposition
/// ourselves. This is quite tedious, as it usually takes a while (at least it
/// did for me!) to realize that this property does not hold automatically.
///
/// I'm setting an SMTPat on this lemma because it's absolutely impossible to
/// get any work done without it.
let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma
(requires (
well_formed h0 ll0 l0 /\
well_formed h1 ll1 l1 /\
cells h0 ll0 l0 == cells h1 ll1 l1))
(ensures (
ll0 == ll1))
[ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ]
=
if B.g_is_null ll0 && B.g_is_null ll1 then begin
B.null_unique ll0;
B.null_unique ll1
end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin
()
end else
false_elim ()
/// Classic stateful reasoning lemmas
/// ---------------------------------
///
/// This essentially follows ``stateful``, the type class of a mutable piece of
/// state defined using the modifies-theory of Low*v2 and equipped with the
/// right lemmas to enable usage by clients. See
/// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context.
val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc
(requires (well_formed h l n))
(ensures (fun refs -> True))
(decreases n)
let rec footprint #a h l n =
if B.g_is_null l
then B.loc_none
else
let {next = next} = B.get h l 0 in
let refs = footprint h next (G.hide (L.tl n)) in
B.loc_union (B.loc_addr_of_buffer l) refs
/// Departing from LinkedList4 here. I prefer to bolt these into the invariant
/// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to
/// deduce these.
val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_pairwise_disjoint #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\
cells_pairwise_disjoint h next (L.tl n)
val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n) | {
"checked_file": "/",
"dependencies": [
"TestLib.fsti.checked",
"prims.fst.checked",
"LowStar.Failure.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int32.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Lib.LinkedList.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> l: LowStar.Lib.LinkedList.t a -> n: Prims.list a
-> Prims.Ghost Type0 | Prims.Ghost | [
""
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"LowStar.Lib.LinkedList.t",
"Prims.list",
"LowStar.Monotonic.Buffer.g_is_null",
"LowStar.Lib.LinkedList.cell",
"LowStar.Buffer.trivial_preorder",
"Prims.l_True",
"Prims.bool",
"Prims.l_and",
"LowStar.Monotonic.Buffer.live",
"LowStar.Monotonic.Buffer.freeable",
"LowStar.Lib.LinkedList.cells_live_freeable",
"FStar.List.Tot.Base.tl",
"LowStar.Buffer.pointer_or_null",
"LowStar.Lib.LinkedList.__proj__Mkcell__item__next",
"LowStar.Monotonic.Buffer.deref"
] | [
"recursion"
] | false | false | false | false | true | let rec cells_live_freeable #_ h l n =
| if B.g_is_null l
then True
else
let next = (B.deref h l).next in
B.live h l /\ B.freeable l /\ cells_live_freeable h next (L.tl n) | false |
LowStar.Lib.LinkedList.fst | LowStar.Lib.LinkedList.length | val length (#a: Type) (gn: G.erased (list a)) (l: t a): Stack UInt32.t
(requires (fun h -> well_formed h l gn))
(ensures (fun h0 n h1 ->
h0 == h1 /\
U32.v n = L.length (G.reveal gn)
)) | val length (#a: Type) (gn: G.erased (list a)) (l: t a): Stack UInt32.t
(requires (fun h -> well_formed h l gn))
(ensures (fun h0 n h1 ->
h0 == h1 /\
U32.v n = L.length (G.reveal gn)
)) | let rec length #a gn l =
if B.is_null l then
0ul
else
let open U32 in
let c = !* l in
let next = c.next in
let n = length (G.hide (L.tail (G.reveal gn))) next in
if n = 0xfffffffful then begin
LowStar.Failure.failwith "Integer overflow in LowStar.LinkedList.length"
end else
n +^ 1ul | {
"file_name": "krmllib/LowStar.Lib.LinkedList.fst",
"git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} | {
"end_col": 14,
"end_line": 471,
"start_col": 0,
"start_line": 460
} | module LowStar.Lib.LinkedList
/// This module, oftentimes referred to as LL1 in other parts of the
/// documentation, provides a low-level view over a linked list. Unless you
/// intend on modifying the structure of the linked list (e.g. removing cells)
/// or iterating over each cell, your are probably better off using LL2.
///
/// This module is intentionally not relying on a tight abstraction, to i) permit
/// direct-style iteration by clients and ii) allow stating some SMTPat lemmas
/// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can
/// happen automatically at the SMT level since LL2 does not have an fsti either).
///
/// Some open questions relative to the design of this module:
/// - should ``v`` be defined directly in terms of ``cells`` rather than have a
/// recursive definition along with an equivalence lemma?
/// - should ``footprint`` be defined directly in terms of ``cells`` rather than
/// have a recursive definition along with an equivalence lemma?
/// - is it worth the trouble defining a footprint? my intuition is that it's
/// fine and allows some clients to do very precise reasoning -- other modules
/// (e.g. AssocList), when establishing abstraction boundaries, can simplify
/// things and get rid of the precise footprint reasoning in favor of a static
/// region-based footprint
///
/// Some remaining work items:
/// - switch to C.Loops.while
open LowStar.BufferOps
module B = LowStar.Buffer
module HS = FStar.HyperStack
module G = FStar.Ghost
module L = FStar.List.Tot
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
open FStar.HyperStack.ST
/// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since
/// everything does recursive list reasoning.
#set-options "--__no_positivity --fuel 1 --ifuel 1"
/// Definition of the Low* type
/// ---------------------------
noeq
type t (a: Type0) =
B.pointer_or_null (cell a)
and cell (a: Type0) = {
next: t a;
data: a;
}
/// Unlike the canonical style that associates a ``v`` function to any stateful
/// representation, we use a relation here. Writing a function is just
/// impossible, since we can't prove termination of ``v`` owing to the fact that
/// there may be an infinite number of cells in the heap.
///
/// LL2 is the module that switches to the function style.
///
/// Note: no need to use erased here for ``l`` since the function is already in ``GTot``.
let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) =
B.live h c /\ (
match l with
| [] ->
B.g_is_null c
| a :: q ->
B.length c == 1 /\ (
let { data=data; next=next } = B.get h c 0 in
a == data /\
well_formed h next (G.hide q)
))
/// Precise reasoning via the cells predicate
/// -----------------------------------------
///
/// The modifies clauses are given either on the footprint of the list, or on a
/// region that includes the footprint of the list (higher up the stack, e.g.
/// LL2). This is good, but does not rule out "stupid" implementations that
/// might re-allocate every single list cell when, say, doing a pop.
///
/// For advanced usages which take pointers directly to individual list cells,
/// it's important to rule out these cases. We thus define the ``cells``
/// predicate for that purpose.
let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a)))
(requires well_formed h c l)
(ensures fun _ -> True)
(decreases l)
=
if B.g_is_null c then
[]
else
c :: cells h (B.deref h c).next (List.Tot.tl l)
/// A missing bit of automated reasoning
/// ------------------------------------
/// This should be absolutely trivial, yet, because there's no pattern on
/// null_unique, we have to do the case analysis and the decomposition
/// ourselves. This is quite tedious, as it usually takes a while (at least it
/// did for me!) to realize that this property does not hold automatically.
///
/// I'm setting an SMTPat on this lemma because it's absolutely impossible to
/// get any work done without it.
let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma
(requires (
well_formed h0 ll0 l0 /\
well_formed h1 ll1 l1 /\
cells h0 ll0 l0 == cells h1 ll1 l1))
(ensures (
ll0 == ll1))
[ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ]
=
if B.g_is_null ll0 && B.g_is_null ll1 then begin
B.null_unique ll0;
B.null_unique ll1
end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin
()
end else
false_elim ()
/// Classic stateful reasoning lemmas
/// ---------------------------------
///
/// This essentially follows ``stateful``, the type class of a mutable piece of
/// state defined using the modifies-theory of Low*v2 and equipped with the
/// right lemmas to enable usage by clients. See
/// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context.
val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc
(requires (well_formed h l n))
(ensures (fun refs -> True))
(decreases n)
let rec footprint #a h l n =
if B.g_is_null l
then B.loc_none
else
let {next = next} = B.get h l 0 in
let refs = footprint h next (G.hide (L.tl n)) in
B.loc_union (B.loc_addr_of_buffer l) refs
/// Departing from LinkedList4 here. I prefer to bolt these into the invariant
/// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to
/// deduce these.
val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_pairwise_disjoint #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\
cells_pairwise_disjoint h next (L.tl n)
val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_live_freeable #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.live h l /\ B.freeable l /\
cells_live_freeable h next (L.tl n)
val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let invariant #a h l n =
cells_live_freeable h l n /\ cells_pairwise_disjoint h l n
/// Normally this would be automatic and writing a custom lemma for that stuff
/// would be needed only when writing an fsti, however, as stated earlier,
/// recursion makes everything more difficult and this absolutely needs to be in
/// scope otherwise the modifies-clause theory cannot deduce disjointness of
/// fresh allocations w.r.t. the footprint.
let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a): Lemma
(requires well_formed h l n)
(ensures B.loc_in (footprint h l n) h)
(decreases n)
[ SMTPat (invariant h l n) ]
=
if B.g_is_null l then
()
else
let next = (B.deref h l).next in
invariant_loc_in_footprint h next (L.tl n)
/// Another absolutely essential lemma, for which interestingly the pattern
/// "invariant h1 l n" does not work, but well_formed does... I guess that's
/// alright.
let rec frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem): Lemma
(requires (
well_formed h0 l n /\
invariant h0 l n /\
B.loc_disjoint r (footprint h0 l n) /\
B.modifies r h0 h1
))
(ensures (
well_formed h1 l n /\
footprint h1 l n == footprint h0 l n /\
cells h1 l n == cells h0 l n /\
invariant h1 l n
))
(decreases n)
[ SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1) ]
=
if B.g_is_null l then
()
else
frame (B.deref h0 l).next (L.tl n) r h0 h1
/// Lemmas for working with linked lists
/// ------------------------------------
///
/// Since it's a recursive data structure, a lot of the automated reasoning from
/// LowStar.Buffer doesn't work since it requires inductions. Some helpful
/// properties are therefore proved here.
let rec length_functional #a (h: HS.mem) (c: t a) (l1 l2: list a):
Lemma
(requires (well_formed h c l1 /\ well_formed h c l2))
(ensures (l1 == l2))
(decreases (G.reveal l1))
[ SMTPat (well_formed h c l1); SMTPat (well_formed h c l2) ] =
if B.g_is_null c
then ()
else
let { next=next } = B.get h c 0 in
length_functional h next (G.hide (L.tl l1)) (G.hide (L.tl l2))
/// The footprint is based on loc_addr_of_buffer so that we can write a free
/// operation that operates on the footprint. However, this invalidates most of
/// the helper lemmas for disjointness that were present in the previous
/// iteration of this module, named LinkedList4.fst. It's ok, we bake
/// disjointness directly onto the invariant and it works just as well.
/// Connection between ``cells`` and ``v``
/// --------------------------------------
/// Redefining some helpers.
#push-options "--ifuel 1"
let rec gmap #a #b (f: a -> GTot b) (xs: list a): GTot (list b) =
match xs with
| [] -> []
| x :: xs -> f x :: gmap f xs
/// "As we all know", right folds are the easiest to work with because they
/// follow the natural structure of recursion (left-folds are evil).
let rec gfold_right #a #b (f: b -> a -> GTot b) (xs: list a) (acc: b): Ghost b
(requires True)
(ensures fun _ -> True)
(decreases xs)
=
match xs with
| [] -> acc
| x :: xs -> f (gfold_right f xs acc) x
#pop-options
/// Connecting ``v`` and ``cells``.
///
/// See ``tests/Wireguard.fst`` for why going through gmap is important and how
/// to structure your definitions (should you need to reason about ``cells``) in
/// a way that will make your life easier.
let deref_data #a (h: HS.mem) (c: B.pointer (cell a)): GTot a =
(B.deref h c).data
#push-options "--fuel 1 --ifuel 1"
let rec deref_cells_is_v #a (h: HS.mem) (ll: t a) (l: list a): Lemma
(requires
well_formed h ll l /\
invariant h ll l)
(ensures
gmap (deref_data h) (cells h ll l) == l)
(decreases l)
[ SMTPat (well_formed h ll l) ]
=
if B.g_is_null ll then
()
else
deref_cells_is_v h (B.deref h ll).next (List.Tot.tl l)
#pop-options
/// Connecting ``footprint`` and ``cells``.
///
/// This allows conveniently switching to a low-level representation of the
/// footprint in case clients want to do some ultra-precise reasoning about
/// what's happening with the list spine. However, the fact that all
/// operations from this module specify things in terms of ``cells`` along with
/// ``same_cells_same_pointer`` should cover most common cases. (This predates
/// the introduction of ``same_cells_same_pointer``.)
///
/// So, no SMTPat here. Note, I also used the same trick as above with
/// higher-order combinators to isolate the use of the argument ``h`` to a
/// single sub-term rather than having it passed down the recursive calls.
#push-options "--fuel 2 --ifuel 2"
let rec footprint_via_cells_is_footprint #a (h: HS.mem) (ll: t a) (l: list a): Lemma
(requires well_formed h ll l)
(ensures
footprint h ll l == (gfold_right B.loc_union (gmap B.loc_addr_of_buffer (cells h ll l)) B.loc_none))
(decreases l)
=
if B.g_is_null ll then
()
else
footprint_via_cells_is_footprint h (B.deref h ll).next (List.Tot.tl l)
#pop-options
/// Stateful operations
/// -------------------
///
/// One thing to note: we pass the region `r` explicitly, which is certainly not
/// very convenient, but that's alright, another layer of abstraction will take
/// care of adding existentials and extra machinery to make this more pleasant
/// to use.
///
/// All of the operations below are low-level (in the sense that they rely on
/// the predicate). I expect clients to use exclusively the variants of these
/// functions present in LL2.
val push: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) -> (x: a) ->
ST unit
(requires (fun h ->
let l = B.deref h pl in
B.live h pl /\
well_formed h l n /\
invariant h l n /\
ST.is_eternal_region r /\
B.(loc_includes (loc_region_only true r) (footprint h l n)) /\
B.(loc_disjoint (loc_buffer pl) (loc_region_only true r))
))
(ensures (fun h0 _ h1 ->
let n' = G.hide (x :: G.reveal n) in
let l = B.deref h1 pl in
// Style note: I don't repeat ``B.live pl`` in the post-condition since
// ``B.modifies (loc_buffer pl) h0 h1`` implies that ``B.live h1 pl``.
B.modifies (B.loc_buffer pl) h0 h1 /\
well_formed h1 l n' /\
invariant h1 l n' /\
B.(loc_includes (loc_region_only true r) (footprint h1 l n') /\
Cons? (cells h1 l n') /\ List.Tot.tail (cells h1 l n') == cells h0 (B.deref h0 pl) n /\
B.fresh_loc (B.loc_addr_of_buffer (List.Tot.hd (cells h1 l n'))) h0 h1)
))
let push #a r n pl x =
(**) let h0 = ST.get () in
let l = !* pl in
let c = { data = x; next = l } in
let pc: B.pointer (cell a) = B.malloc r c 1ul in
(**) let h1 = ST.get () in
(**) B.(modifies_only_not_unused_in loc_none h0 h1);
(**) assert B.(loc_disjoint (loc_buffer pc) (footprint h0 l n));
pl *= pc;
(**) let h2 = ST.get () in
(**) let n' = G.hide (x :: G.reveal n) in
(**) B.(modifies_trans loc_none h0 h1 (loc_buffer pl) h2);
(**) assert (well_formed h2 (B.deref h2 pl) n');
(**) assert (invariant h2 (B.deref h2 pl) n');
(**) assert ((B.deref h2 (B.deref h2 pl)).next == l);
()
val pop: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) ->
ST a
(requires (fun h ->
let l = B.deref h pl in
B.live h pl /\
well_formed h l n /\
invariant h l n /\
ST.is_eternal_region r /\
B.(loc_includes (loc_region_only true r) (footprint h l n)) /\
B.loc_disjoint (B.loc_buffer pl) (footprint h l n) /\
Cons? n
))
(ensures (fun h0 x h1 ->
let l = B.deref h1 pl in
let n' = L.tl n in
x == L.hd n /\
// Introducing a super precise modifies clause (e.g. loc_addr_of_buffer
// (B.deref h0 pl)) here is not useful and prevents trigger-based
// reasoning, while also requiring clients to unroll footprint. There's a
// tension here between revealing that ``pop`` does nothing stupid (e.g.
// re-allocating all the list cells) and providing an abstract enough
// predicate to work with.
B.(modifies (loc_buffer pl `loc_union` footprint h0 (B.deref h0 pl) n) h0 h1) /\
well_formed h1 l n' /\
invariant h1 l n' /\
B.(loc_includes (loc_region_only true r) (footprint h1 l n')) /\
List.Tot.tail (cells h0 (B.deref h0 pl) n) == cells h1 l n'))
let pop #a r n pl =
let l = !* pl in
let r = (!*l).data in
let next = (!*l).next in
(**) let h1 = ST.get () in
(**) assert (cells h1 l n == l :: cells h1 next (List.Tot.tl n));
(**) assert B.(loc_disjoint (loc_buffer pl) (footprint h1 l n));
(**) assert B.(loc_disjoint (loc_buffer pl) (footprint h1 next (List.Tot.tl n)));
pl *= next;
B.free l;
r
val free_: (#a: Type) -> (#n: G.erased (list a)) -> (l: t a) ->
ST unit
(requires (fun h ->
well_formed h l n /\
invariant h l n
))
(ensures (fun h0 _ h1 ->
B.(modifies (footprint h0 l n) h0 h1)))
let rec free_ #a #n l =
if B.is_null l then
()
else begin
let tl: G.erased (list a) = G.hide (L.tl (G.reveal n)) in
free_ #_ #tl (!*l).next;
B.free l
end
val free: (#a: Type) -> (#n: G.erased (list a)) -> (pl: B.pointer (t a)) ->
ST unit
(requires (fun h ->
let l = B.deref h pl in
B.live h pl /\
well_formed h l n /\
invariant h l n /\
B.loc_disjoint (B.loc_buffer pl) (footprint h l n)
))
(ensures (fun h0 _ h1 ->
let l = B.deref h1 pl in
well_formed h1 l [] /\
invariant h1 l [] /\
footprint h1 l [] == B.loc_none /\
cells h1 l [] == [] /\
B.(modifies (footprint h0 (B.deref h0 pl) n `loc_union` loc_buffer pl) h0 h1)))
let free #a #n pl =
free_ #_ #n !*pl;
pl *= B.null
val length (#a: Type) (gn: G.erased (list a)) (l: t a): Stack UInt32.t
(requires (fun h -> well_formed h l gn))
(ensures (fun h0 n h1 ->
h0 == h1 /\
U32.v n = L.length (G.reveal gn)
)) | {
"checked_file": "/",
"dependencies": [
"TestLib.fsti.checked",
"prims.fst.checked",
"LowStar.Failure.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int32.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Lib.LinkedList.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | gn: FStar.Ghost.erased (Prims.list a) -> l: LowStar.Lib.LinkedList.t a
-> FStar.HyperStack.ST.Stack FStar.UInt32.t | FStar.HyperStack.ST.Stack | [] | [] | [
"FStar.Ghost.erased",
"Prims.list",
"LowStar.Lib.LinkedList.t",
"FStar.UInt32.__uint_to_t",
"FStar.UInt32.t",
"Prims.bool",
"Prims.op_Equality",
"LowStar.Failure.failwith",
"FStar.UInt32.op_Plus_Hat",
"LowStar.Lib.LinkedList.length",
"FStar.Ghost.hide",
"FStar.List.Tot.Base.tail",
"FStar.Ghost.reveal",
"LowStar.Buffer.pointer_or_null",
"LowStar.Lib.LinkedList.cell",
"LowStar.Lib.LinkedList.__proj__Mkcell__item__next",
"LowStar.BufferOps.op_Bang_Star",
"LowStar.Buffer.trivial_preorder",
"LowStar.Monotonic.Buffer.is_null"
] | [
"recursion"
] | false | true | false | false | false | let rec length #a gn l =
| if B.is_null l
then 0ul
else
let open U32 in
let c = !*l in
let next = c.next in
let n = length (G.hide (L.tail (G.reveal gn))) next in
if n = 0xfffffffful
then LowStar.Failure.failwith "Integer overflow in LowStar.LinkedList.length"
else n +^ 1ul | false |
LowStar.Lib.LinkedList.fst | LowStar.Lib.LinkedList.gmap | val gmap (#a #b: _) (f: (a -> GTot b)) (xs: list a) : GTot (list b) | val gmap (#a #b: _) (f: (a -> GTot b)) (xs: list a) : GTot (list b) | let rec gmap #a #b (f: a -> GTot b) (xs: list a): GTot (list b) =
match xs with
| [] -> []
| x :: xs -> f x :: gmap f xs | {
"file_name": "krmllib/LowStar.Lib.LinkedList.fst",
"git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} | {
"end_col": 31,
"end_line": 253,
"start_col": 0,
"start_line": 250
} | module LowStar.Lib.LinkedList
/// This module, oftentimes referred to as LL1 in other parts of the
/// documentation, provides a low-level view over a linked list. Unless you
/// intend on modifying the structure of the linked list (e.g. removing cells)
/// or iterating over each cell, your are probably better off using LL2.
///
/// This module is intentionally not relying on a tight abstraction, to i) permit
/// direct-style iteration by clients and ii) allow stating some SMTPat lemmas
/// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can
/// happen automatically at the SMT level since LL2 does not have an fsti either).
///
/// Some open questions relative to the design of this module:
/// - should ``v`` be defined directly in terms of ``cells`` rather than have a
/// recursive definition along with an equivalence lemma?
/// - should ``footprint`` be defined directly in terms of ``cells`` rather than
/// have a recursive definition along with an equivalence lemma?
/// - is it worth the trouble defining a footprint? my intuition is that it's
/// fine and allows some clients to do very precise reasoning -- other modules
/// (e.g. AssocList), when establishing abstraction boundaries, can simplify
/// things and get rid of the precise footprint reasoning in favor of a static
/// region-based footprint
///
/// Some remaining work items:
/// - switch to C.Loops.while
open LowStar.BufferOps
module B = LowStar.Buffer
module HS = FStar.HyperStack
module G = FStar.Ghost
module L = FStar.List.Tot
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
open FStar.HyperStack.ST
/// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since
/// everything does recursive list reasoning.
#set-options "--__no_positivity --fuel 1 --ifuel 1"
/// Definition of the Low* type
/// ---------------------------
noeq
type t (a: Type0) =
B.pointer_or_null (cell a)
and cell (a: Type0) = {
next: t a;
data: a;
}
/// Unlike the canonical style that associates a ``v`` function to any stateful
/// representation, we use a relation here. Writing a function is just
/// impossible, since we can't prove termination of ``v`` owing to the fact that
/// there may be an infinite number of cells in the heap.
///
/// LL2 is the module that switches to the function style.
///
/// Note: no need to use erased here for ``l`` since the function is already in ``GTot``.
let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) =
B.live h c /\ (
match l with
| [] ->
B.g_is_null c
| a :: q ->
B.length c == 1 /\ (
let { data=data; next=next } = B.get h c 0 in
a == data /\
well_formed h next (G.hide q)
))
/// Precise reasoning via the cells predicate
/// -----------------------------------------
///
/// The modifies clauses are given either on the footprint of the list, or on a
/// region that includes the footprint of the list (higher up the stack, e.g.
/// LL2). This is good, but does not rule out "stupid" implementations that
/// might re-allocate every single list cell when, say, doing a pop.
///
/// For advanced usages which take pointers directly to individual list cells,
/// it's important to rule out these cases. We thus define the ``cells``
/// predicate for that purpose.
let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a)))
(requires well_formed h c l)
(ensures fun _ -> True)
(decreases l)
=
if B.g_is_null c then
[]
else
c :: cells h (B.deref h c).next (List.Tot.tl l)
/// A missing bit of automated reasoning
/// ------------------------------------
/// This should be absolutely trivial, yet, because there's no pattern on
/// null_unique, we have to do the case analysis and the decomposition
/// ourselves. This is quite tedious, as it usually takes a while (at least it
/// did for me!) to realize that this property does not hold automatically.
///
/// I'm setting an SMTPat on this lemma because it's absolutely impossible to
/// get any work done without it.
let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma
(requires (
well_formed h0 ll0 l0 /\
well_formed h1 ll1 l1 /\
cells h0 ll0 l0 == cells h1 ll1 l1))
(ensures (
ll0 == ll1))
[ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ]
=
if B.g_is_null ll0 && B.g_is_null ll1 then begin
B.null_unique ll0;
B.null_unique ll1
end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin
()
end else
false_elim ()
/// Classic stateful reasoning lemmas
/// ---------------------------------
///
/// This essentially follows ``stateful``, the type class of a mutable piece of
/// state defined using the modifies-theory of Low*v2 and equipped with the
/// right lemmas to enable usage by clients. See
/// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context.
val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc
(requires (well_formed h l n))
(ensures (fun refs -> True))
(decreases n)
let rec footprint #a h l n =
if B.g_is_null l
then B.loc_none
else
let {next = next} = B.get h l 0 in
let refs = footprint h next (G.hide (L.tl n)) in
B.loc_union (B.loc_addr_of_buffer l) refs
/// Departing from LinkedList4 here. I prefer to bolt these into the invariant
/// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to
/// deduce these.
val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_pairwise_disjoint #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\
cells_pairwise_disjoint h next (L.tl n)
val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_live_freeable #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.live h l /\ B.freeable l /\
cells_live_freeable h next (L.tl n)
val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let invariant #a h l n =
cells_live_freeable h l n /\ cells_pairwise_disjoint h l n
/// Normally this would be automatic and writing a custom lemma for that stuff
/// would be needed only when writing an fsti, however, as stated earlier,
/// recursion makes everything more difficult and this absolutely needs to be in
/// scope otherwise the modifies-clause theory cannot deduce disjointness of
/// fresh allocations w.r.t. the footprint.
let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a): Lemma
(requires well_formed h l n)
(ensures B.loc_in (footprint h l n) h)
(decreases n)
[ SMTPat (invariant h l n) ]
=
if B.g_is_null l then
()
else
let next = (B.deref h l).next in
invariant_loc_in_footprint h next (L.tl n)
/// Another absolutely essential lemma, for which interestingly the pattern
/// "invariant h1 l n" does not work, but well_formed does... I guess that's
/// alright.
let rec frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem): Lemma
(requires (
well_formed h0 l n /\
invariant h0 l n /\
B.loc_disjoint r (footprint h0 l n) /\
B.modifies r h0 h1
))
(ensures (
well_formed h1 l n /\
footprint h1 l n == footprint h0 l n /\
cells h1 l n == cells h0 l n /\
invariant h1 l n
))
(decreases n)
[ SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1) ]
=
if B.g_is_null l then
()
else
frame (B.deref h0 l).next (L.tl n) r h0 h1
/// Lemmas for working with linked lists
/// ------------------------------------
///
/// Since it's a recursive data structure, a lot of the automated reasoning from
/// LowStar.Buffer doesn't work since it requires inductions. Some helpful
/// properties are therefore proved here.
let rec length_functional #a (h: HS.mem) (c: t a) (l1 l2: list a):
Lemma
(requires (well_formed h c l1 /\ well_formed h c l2))
(ensures (l1 == l2))
(decreases (G.reveal l1))
[ SMTPat (well_formed h c l1); SMTPat (well_formed h c l2) ] =
if B.g_is_null c
then ()
else
let { next=next } = B.get h c 0 in
length_functional h next (G.hide (L.tl l1)) (G.hide (L.tl l2))
/// The footprint is based on loc_addr_of_buffer so that we can write a free
/// operation that operates on the footprint. However, this invalidates most of
/// the helper lemmas for disjointness that were present in the previous
/// iteration of this module, named LinkedList4.fst. It's ok, we bake
/// disjointness directly onto the invariant and it works just as well.
/// Connection between ``cells`` and ``v``
/// --------------------------------------
/// Redefining some helpers. | {
"checked_file": "/",
"dependencies": [
"TestLib.fsti.checked",
"prims.fst.checked",
"LowStar.Failure.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int32.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Lib.LinkedList.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | f: (_: a -> Prims.GTot b) -> xs: Prims.list a -> Prims.GTot (Prims.list b) | Prims.GTot | [
"sometrivial"
] | [] | [
"Prims.list",
"Prims.Nil",
"Prims.Cons",
"LowStar.Lib.LinkedList.gmap"
] | [
"recursion"
] | false | false | false | false | false | let rec gmap #a #b (f: (a -> GTot b)) (xs: list a) : GTot (list b) =
| match xs with
| [] -> []
| x :: xs -> f x :: gmap f xs | false |
Hacl.Impl.RSAPSS.fst | Hacl.Impl.RSAPSS.rsapss_pkey_verify | val rsapss_pkey_verify:
#t:limb_t
-> ke:BE.exp t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t
-> rsapss_load_pkey:RK.rsapss_load_pkey_st t ke modBits
-> rsapss_verify:rsapss_verify_st t ke a modBits ->
rsapss_pkey_verify_st t ke a modBits | val rsapss_pkey_verify:
#t:limb_t
-> ke:BE.exp t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t
-> rsapss_load_pkey:RK.rsapss_load_pkey_st t ke modBits
-> rsapss_verify:rsapss_verify_st t ke a modBits ->
rsapss_pkey_verify_st t ke a modBits | let rsapss_pkey_verify #t ke a modBits rsapss_load_pkey rsapss_verify eBits nb eb saltLen sgntLen sgnt msgLen msg =
push_frame ();
[@inline_let] let bits = size (bits t) in
let pkey = create (2ul *! blocks modBits bits +! blocks eBits bits) (uint #t 0) in
let h0 = ST.get () in
let b = rsapss_load_pkey eBits nb eb pkey in
LS.rsapss_load_pkey_lemma #t (v modBits) (v eBits) (as_seq h0 nb) (as_seq h0 eb);
let res =
if b then
rsapss_verify eBits pkey saltLen sgntLen sgnt msgLen msg
else
false in
pop_frame ();
let h1 = ST.get () in
assert (res == LS.rsapss_pkey_verify #t a (v modBits) (v eBits) (as_seq h0 nb) (as_seq h0 eb)
(v saltLen) (v sgntLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg));
res | {
"file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 5,
"end_line": 622,
"start_col": 0,
"start_line": 605
} | module Hacl.Impl.RSAPSS
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
module ST = FStar.HyperStack.ST
module Hash = Spec.Agile.Hash
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
module SD = Hacl.Spec.Bignum.Definitions
module SM = Hacl.Spec.Bignum.Montgomery
module SE = Hacl.Spec.Bignum.Exponentiation
module BN = Hacl.Bignum
module BE = Hacl.Bignum.Exponentiation
module BM = Hacl.Bignum.Montgomery
module S = Spec.RSAPSS
module LS = Hacl.Spec.RSAPSS
module LSeq = Lib.Sequence
module RP = Hacl.Impl.RSAPSS.Padding
module RM = Hacl.Impl.RSAPSS.MGF
module RK = Hacl.Impl.RSAPSS.Keys
#reset-options "--z3rlimit 150 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t}
inline_for_extraction noextract
let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t
-> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)}
-> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t)))
-> m:lbignum t len
-> m':lbignum t len
-> s:lbignum t len ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h skey /\ live h m /\ live h s /\ live h m' /\
disjoint s m /\ disjoint s skey /\ disjoint m skey /\
disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\
LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\
bn_v h m < bn_v h (gsub skey 0ul len))
(ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\
(r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m))
inline_for_extraction noextract
val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits
let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s =
[@inline_let] let bits : size_pos = bits t in
let nLen = blocks modBits (size bits) in
let eLen = blocks eBits (size bits) in
let dLen = blocks dBits (size bits) in
let n = sub skey 0ul nLen in
let r2 = sub skey nLen nLen in
let e = sub skey (nLen +! nLen) eLen in
let d = sub skey (nLen +! nLen +! eLen) dLen in
Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits);
let h0 = ST.get () in
SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n);
BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s;
BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m';
let h1 = ST.get () in
SD.bn_eval_inj (v nLen) (as_seq h1 s)
(SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2)
(as_seq h0 m) (v dBits) (as_seq h0 d));
SD.bn_eval_inj (v nLen) (as_seq h1 m')
(SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2)
(as_seq h1 s) (v eBits) (as_seq h0 e));
let eq_m = BN.bn_eq_mask nLen m m' in
mapT nLen s (logand eq_m) s;
BB.unsafe_bool_of_limb eq_m
inline_for_extraction noextract
let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
saltLen:size_t
-> salt:lbuffer uint8 saltLen
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen
-> m:lbignum t len ->
Stack unit
(requires fun h ->
live h salt /\ live h msg /\ live h m /\
disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\
as_seq h m == LSeq.create (v len) (uint #t 0) /\
LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg))
(ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\
as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg))
inline_for_extraction noextract
val rsapss_sign_msg_to_bn:
#t:limb_t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_sign_msg_to_bn_st t a modBits
let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m =
push_frame ();
[@inline_let] let bits : size_pos = bits t in
[@inline_let] let numb : size_pos = numbytes t in
let nLen = blocks modBits (size bits) in
let emBits = modBits -! 1ul in
let emLen = blocks emBits 8ul in
[@inline_let] let mLen = blocks emLen (size numb) in
let em = create emLen (u8 0) in
RP.pss_encode a saltLen salt msgLen msg emBits em;
LS.blocks_bits_lemma t (v emBits);
LS.blocks_numb_lemma t (v emBits);
assert (SD.blocks (v emBits) bits = v mLen);
assert (numb * v mLen <= max_size_t);
assert (v mLen <= v nLen);
let h' = ST.get () in
update_sub_f h' m 0ul mLen
(fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em))
(fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen));
pop_frame ()
inline_for_extraction noextract
let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t
-> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)}
-> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t)))
-> m:lbignum t len
-> sgnt:lbuffer uint8 (blocks modBits 8ul) ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h sgnt /\ live h skey /\ live h m /\
disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\
LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\
bn_v h m < bn_v h (gsub skey 0ul len))
(ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\
(eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m))
inline_for_extraction noextract
val rsapss_sign_compute_sgnt:
#t:limb_t
-> ke:BE.exp t
-> modBits:modBits_t t ->
rsapss_sign_compute_sgnt_st t ke modBits
let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt =
push_frame ();
let h_init = ST.get () in
[@inline_let] let bits : size_pos = bits t in
[@inline_let] let numb : size_pos = numbytes t in
let nLen = blocks modBits (size bits) in
let k = blocks modBits 8ul in
let s = create nLen (uint #t 0) in
let m' = create nLen (uint #t 0) in
let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in
LS.blocks_bits_lemma t (v modBits);
LS.blocks_numb_lemma t (v modBits);
assert (SD.blocks (v k) numb == v nLen);
assert (numb * v nLen <= max_size_t);
BN.bn_to_bytes_be k s sgnt;
pop_frame ();
eq_b
inline_for_extraction noextract
let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t
-> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)}
-> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t)))
-> saltLen:size_t
-> salt:lbuffer uint8 saltLen
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen
-> sgnt:lbuffer uint8 (blocks modBits 8ul) ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h salt /\ live h msg /\ live h sgnt /\ live h skey /\
disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\
disjoint salt msg /\
LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\
LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg))
(ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\
(eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits)
(as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg))
inline_for_extraction noextract
val rsapss_sign_:
#t:limb_t
-> ke:BE.exp t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_sign_st1 t ke a modBits
let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt =
push_frame ();
[@inline_let] let bits : size_pos = bits t in
let nLen = blocks modBits (size bits) in
let m = create nLen (uint #t 0) in
rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m;
let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in
pop_frame ();
eq_b
inline_for_extraction noextract
let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t
-> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)}
-> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t)))
-> saltLen:size_t
-> salt:lbuffer uint8 saltLen
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen
-> sgnt:lbuffer uint8 (blocks modBits 8ul) ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h salt /\ live h msg /\ live h sgnt /\ live h skey /\
disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\
disjoint salt msg /\
LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey))
(ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\
(b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits)
(as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt))
inline_for_extraction noextract
val rsapss_sign:
#t:limb_t
-> ke:BE.exp t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_sign_st t ke a modBits
let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt =
let hLen = RM.hash_len a in
Math.Lemmas.pow2_lt_compat 61 32;
Math.Lemmas.pow2_lt_compat 125 32;
//assert (max_size_t < Hash.max_input_length a);
let b =
saltLen <=. 0xfffffffful -! hLen -! 8ul &&
saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in
if b then
rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt
else
false
inline_for_extraction noextract
val bn_lt_pow2:
#t:limb_t
-> modBits:size_t{1 < v modBits}
-> m:lbignum t (blocks modBits (size (bits t))) ->
Stack bool
(requires fun h -> live h m)
(ensures fun h0 r h1 -> h0 == h1 /\
r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m))
let bn_lt_pow2 #t modBits m =
if not ((modBits -! 1ul) %. 8ul =. 0ul) then true
else begin
let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in
BB.unsafe_bool_of_limb0 get_bit end
inline_for_extraction noextract
let rsapss_verify_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)}
-> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t)))
-> m_def:lbignum t len
-> s:lbignum t len ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h pkey /\ live h m_def /\ live h s /\
disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\
LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey))
(ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\
(r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s))
inline_for_extraction noextract
val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits
let rsapss_verify_bn #t ke modBits eBits pkey m_def s =
[@inline_let] let bits = size (bits t) in
let nLen = blocks modBits bits in
let eLen = blocks eBits bits in
let n = sub pkey 0ul nLen in
let r2 = sub pkey nLen nLen in
let e = sub pkey (nLen +! nLen) eLen in
let mask = BN.bn_lt_mask nLen s n in
let h = ST.get () in
SB.bn_lt_mask_lemma (as_seq h s) (as_seq h n);
let res =
if BB.unsafe_bool_of_limb mask then begin
Math.Lemmas.pow2_le_compat (v bits * v nLen) (v modBits);
SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h n);
let h0 = ST.get () in
BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m_def;
let h1 = ST.get () in
SD.bn_eval_inj (v nLen) (as_seq h1 m_def)
(SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2)
(as_seq h1 s) (v eBits) (as_seq h0 e));
if bn_lt_pow2 modBits m_def then true
else false end
else false in
res
inline_for_extraction noextract
let rsapss_verify_bn_to_msg_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
saltLen:size_t
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen
-> m:lbignum t (blocks modBits (size (bits t))) ->
Stack bool
(requires fun h ->
live h msg /\ live h m /\ disjoint m msg /\
LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg))
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == LS.rsapss_verify_bn_to_msg a (v modBits) (v saltLen) (v msgLen) (as_seq h0 msg) (as_seq h0 m))
inline_for_extraction noextract
val rsapss_verify_bn_to_msg:
#t:limb_t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_verify_bn_to_msg_st t a modBits
let rsapss_verify_bn_to_msg #t a modBits saltLen msgLen msg m =
push_frame ();
[@inline_let] let bits : size_pos = bits t in
[@inline_let] let numb : size_pos = numbytes t in
let nLen = blocks modBits (size bits) in
let emBits = modBits -! 1ul in
let emLen = blocks emBits 8ul in
[@inline_let] let mLen = blocks emLen (size numb) in
let em = create emLen (u8 0) in
LS.blocks_bits_lemma t (v emBits);
LS.blocks_numb_lemma t (v emBits);
assert (SD.blocks (v emBits) bits == v mLen);
assert (numb * v mLen <= max_size_t);
assert (v mLen <= v nLen);
let m1 = sub m 0ul mLen in
BN.bn_to_bytes_be emLen m1 em;
let res = RP.pss_verify a saltLen msgLen msg emBits em in
pop_frame ();
res
inline_for_extraction noextract
let rsapss_verify_compute_msg_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)}
-> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t)))
-> sgnt:lbuffer uint8 (blocks modBits 8ul)
-> m:lbignum t len ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h sgnt /\ live h pkey /\ live h m /\
disjoint m sgnt /\ disjoint m pkey /\
as_seq h m == LSeq.create (v len) (uint #t 0) /\
LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey))
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(r, as_seq h1 m) == LS.rsapss_verify_compute_msg (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 sgnt))
inline_for_extraction noextract
val rsapss_verify_compute_msg:
#t:limb_t
-> ke:BE.exp t
-> modBits:modBits_t t ->
rsapss_verify_compute_msg_st t ke modBits
let rsapss_verify_compute_msg #t ke modBits eBits pkey sgnt m =
push_frame ();
[@inline_let] let bits : size_pos = bits t in
[@inline_let] let numb : size_pos = numbytes t in
let nLen = blocks modBits (size bits) in
let k = blocks modBits 8ul in
let s = create nLen (uint #t 0) in
LS.blocks_bits_lemma t (v modBits);
LS.blocks_numb_lemma t (v modBits);
assert (SD.blocks (v k) numb == v nLen);
assert (numb * v nLen <= max_size_t);
BN.bn_from_bytes_be k sgnt s;
let b = rsapss_verify_bn #t ke modBits eBits pkey m s in
pop_frame ();
b
inline_for_extraction noextract
let rsapss_verify_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)}
-> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t)))
-> saltLen:size_t
-> sgnt:lbuffer uint8 (blocks modBits 8ul)
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h msg /\ live h sgnt /\ live h pkey /\
disjoint msg sgnt /\ disjoint msg pkey /\
LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey) /\
LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg))
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == LS.rsapss_verify_ a (v modBits) (v eBits) (as_seq h0 pkey)
(v saltLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg))
inline_for_extraction noextract
val rsapss_verify_:
#t:limb_t
-> ke:BE.exp t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_verify_st1 t ke a modBits
let rsapss_verify_ #t ke a modBits eBits pkey saltLen sgnt msgLen msg =
push_frame ();
[@inline_let] let bits : size_pos = bits t in
let nLen = blocks modBits (size bits) in
let m = create nLen (uint #t 0) in
let b = rsapss_verify_compute_msg ke modBits eBits pkey sgnt m in
let res = if b then rsapss_verify_bn_to_msg a modBits saltLen msgLen msg m else false in
pop_frame ();
res
inline_for_extraction noextract
let rsapss_verify_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)}
-> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t)))
-> saltLen:size_t
-> sgntLen:size_t
-> sgnt:lbuffer uint8 sgntLen
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h msg /\ live h sgnt /\ live h pkey /\
disjoint msg sgnt /\ disjoint msg pkey /\
LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey))
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == LS.rsapss_verify a (v modBits) (v eBits) (as_seq h0 pkey)
(v saltLen) (v sgntLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg))
inline_for_extraction noextract
val rsapss_verify:
#t:limb_t
-> ke:BE.exp t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_verify_st t ke a modBits
let rsapss_verify #t ke a modBits eBits pkey saltLen sgntLen sgnt msgLen msg =
let hLen = RM.hash_len a in
Math.Lemmas.pow2_lt_compat 61 32;
Math.Lemmas.pow2_lt_compat 125 32;
//assert (max_size_t < Hash.max_input_length a);
assert (v msgLen <= max_size_t);
assert (v hLen + 8 < max_size_t);
let b =
saltLen <=. 0xfffffffful -! hLen -! 8ul &&
sgntLen =. blocks modBits 8ul in
if b then
rsapss_verify_ ke a modBits eBits pkey saltLen sgnt msgLen msg
else
false
inline_for_extraction noextract
let rsapss_skey_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:size_t) =
eBits:size_t
-> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)}
-> nb:lbuffer uint8 (blocks modBits 8ul)
-> eb:lbuffer uint8 (blocks eBits 8ul)
-> db:lbuffer uint8 (blocks dBits 8ul)
-> saltLen:size_t
-> salt:lbuffer uint8 saltLen
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen
-> sgnt:lbuffer uint8 (blocks modBits 8ul) ->
Stack bool
(requires fun h ->
blocks modBits (size (bits t)) == ke.BE.bn.BN.len /\
live h salt /\ live h msg /\ live h sgnt /\
live h nb /\ live h eb /\ live h db /\
disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\
disjoint sgnt nb /\ disjoint sgnt eb /\ disjoint sgnt db /\
disjoint salt msg)
(ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\
(let sgnt_s = S.rsapss_skey_sign a (v modBits) (v eBits) (v dBits)
(as_seq h0 nb) (as_seq h0 eb) (as_seq h0 db) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) in
if b then Some? sgnt_s /\ as_seq h1 sgnt == Some?.v sgnt_s else None? sgnt_s))
inline_for_extraction noextract
val rsapss_skey_sign:
#t:limb_t
-> ke:BE.exp t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t
-> rsapss_load_skey:RK.rsapss_load_skey_st t ke modBits
-> rsapss_sign:rsapss_sign_st t ke a modBits ->
rsapss_skey_sign_st t ke a modBits
let rsapss_skey_sign #t ke a modBits rsapss_load_skey rsapss_sign eBits dBits nb eb db saltLen salt msgLen msg sgnt =
[@inline_let] let bits = size (bits t) in
let h0 = ST.get () in
push_frame ();
let skey = create (2ul *! blocks modBits bits +! blocks eBits bits +! blocks dBits bits) (uint #t 0) in
let b = rsapss_load_skey eBits dBits nb eb db skey in
LS.rsapss_load_skey_lemma #t (v modBits) (v eBits) (v dBits) (as_seq h0 nb) (as_seq h0 eb) (as_seq h0 db);
let res =
if b then
rsapss_sign eBits dBits skey saltLen salt msgLen msg sgnt
else
false in
pop_frame ();
let h1 = ST.get () in
assert ((res, as_seq h1 sgnt) == LS.rsapss_skey_sign #t a (v modBits) (v eBits) (v dBits)
(as_seq h0 nb) (as_seq h0 eb) (as_seq h0 db) (v saltLen) (as_seq h0 salt)
(v msgLen) (as_seq h0 msg) (as_seq h0 sgnt));
res
inline_for_extraction noextract
let rsapss_pkey_verify_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:size_t) =
eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)}
-> nb:lbuffer uint8 (blocks modBits 8ul)
-> eb:lbuffer uint8 (blocks eBits 8ul)
-> saltLen:size_t
-> sgntLen:size_t
-> sgnt:lbuffer uint8 sgntLen
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen ->
Stack bool
(requires fun h ->
blocks modBits (size (bits t)) == ke.BE.bn.BN.len /\
live h msg /\ live h sgnt /\ live h nb /\ live h eb /\
disjoint msg sgnt /\ disjoint nb eb /\ disjoint sgnt nb /\
disjoint sgnt eb /\ disjoint msg nb /\ disjoint msg eb)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.rsapss_pkey_verify a (v modBits) (v eBits) (as_seq h0 nb) (as_seq h0 eb)
(v saltLen) (v sgntLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg))
inline_for_extraction noextract
val rsapss_pkey_verify:
#t:limb_t
-> ke:BE.exp t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t
-> rsapss_load_pkey:RK.rsapss_load_pkey_st t ke modBits
-> rsapss_verify:rsapss_verify_st t ke a modBits ->
rsapss_pkey_verify_st t ke a modBits | {
"checked_file": "/",
"dependencies": [
"Spec.RSAPSS.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.RSAPSS.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Exponentiation.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Impl.RSAPSS.Padding.fst.checked",
"Hacl.Impl.RSAPSS.MGF.fst.checked",
"Hacl.Impl.RSAPSS.Keys.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.RSAPSS.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.RSAPSS.Keys",
"short_module": "RK"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.RSAPSS.MGF",
"short_module": "RM"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.RSAPSS.Padding",
"short_module": "RP"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.RSAPSS",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.RSAPSS",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 150,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
ke: Hacl.Bignum.Exponentiation.exp t ->
a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} ->
modBits: Hacl.Impl.RSAPSS.modBits_t t ->
rsapss_load_pkey: Hacl.Impl.RSAPSS.Keys.rsapss_load_pkey_st t ke modBits ->
rsapss_verify: Hacl.Impl.RSAPSS.rsapss_verify_st t ke a modBits
-> Hacl.Impl.RSAPSS.rsapss_pkey_verify_st t ke a modBits | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.Exponentiation.exp",
"Spec.Hash.Definitions.hash_alg",
"Prims.b2t",
"Spec.RSAPSS.hash_is_supported",
"Hacl.Impl.RSAPSS.modBits_t",
"Hacl.Impl.RSAPSS.Keys.rsapss_load_pkey_st",
"Hacl.Impl.RSAPSS.rsapss_verify_st",
"Lib.IntTypes.size_t",
"Hacl.Spec.RSAPSS.pkey_len_pre",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Hacl.Bignum.Definitions.blocks",
"FStar.UInt32.__uint_to_t",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Prims.bool",
"Hacl.Spec.RSAPSS.rsapss_pkey_verify",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"FStar.HyperStack.ST.pop_frame",
"Hacl.Spec.RSAPSS.rsapss_load_pkey_lemma",
"Lib.Buffer.lbuffer_t",
"Hacl.Bignum.Definitions.limb",
"Lib.IntTypes.add",
"Lib.IntTypes.mul",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.create",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.uint",
"Lib.IntTypes.SEC",
"Lib.IntTypes.int_t",
"Lib.IntTypes.size",
"Lib.IntTypes.bits",
"FStar.HyperStack.ST.push_frame"
] | [] | false | false | false | false | false | let rsapss_pkey_verify
#t
ke
a
modBits
rsapss_load_pkey
rsapss_verify
eBits
nb
eb
saltLen
sgntLen
sgnt
msgLen
msg
=
| push_frame ();
[@@ inline_let ]let bits = size (bits t) in
let pkey = create (2ul *! blocks modBits bits +! blocks eBits bits) (uint #t 0) in
let h0 = ST.get () in
let b = rsapss_load_pkey eBits nb eb pkey in
LS.rsapss_load_pkey_lemma #t (v modBits) (v eBits) (as_seq h0 nb) (as_seq h0 eb);
let res = if b then rsapss_verify eBits pkey saltLen sgntLen sgnt msgLen msg else false in
pop_frame ();
let h1 = ST.get () in
assert (res ==
LS.rsapss_pkey_verify #t a (v modBits) (v eBits) (as_seq h0 nb) (as_seq h0 eb) (v saltLen)
(v sgntLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg));
res | false |
LowStar.Lib.LinkedList.fst | LowStar.Lib.LinkedList.length_functional | val length_functional (#a: _) (h: HS.mem) (c: t a) (l1 l2: list a)
: Lemma (requires (well_formed h c l1 /\ well_formed h c l2))
(ensures (l1 == l2))
(decreases (G.reveal l1))
[SMTPat (well_formed h c l1); SMTPat (well_formed h c l2)] | val length_functional (#a: _) (h: HS.mem) (c: t a) (l1 l2: list a)
: Lemma (requires (well_formed h c l1 /\ well_formed h c l2))
(ensures (l1 == l2))
(decreases (G.reveal l1))
[SMTPat (well_formed h c l1); SMTPat (well_formed h c l2)] | let rec length_functional #a (h: HS.mem) (c: t a) (l1 l2: list a):
Lemma
(requires (well_formed h c l1 /\ well_formed h c l2))
(ensures (l1 == l2))
(decreases (G.reveal l1))
[ SMTPat (well_formed h c l1); SMTPat (well_formed h c l2) ] =
if B.g_is_null c
then ()
else
let { next=next } = B.get h c 0 in
length_functional h next (G.hide (L.tl l1)) (G.hide (L.tl l2)) | {
"file_name": "krmllib/LowStar.Lib.LinkedList.fst",
"git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} | {
"end_col": 66,
"end_line": 237,
"start_col": 0,
"start_line": 227
} | module LowStar.Lib.LinkedList
/// This module, oftentimes referred to as LL1 in other parts of the
/// documentation, provides a low-level view over a linked list. Unless you
/// intend on modifying the structure of the linked list (e.g. removing cells)
/// or iterating over each cell, your are probably better off using LL2.
///
/// This module is intentionally not relying on a tight abstraction, to i) permit
/// direct-style iteration by clients and ii) allow stating some SMTPat lemmas
/// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can
/// happen automatically at the SMT level since LL2 does not have an fsti either).
///
/// Some open questions relative to the design of this module:
/// - should ``v`` be defined directly in terms of ``cells`` rather than have a
/// recursive definition along with an equivalence lemma?
/// - should ``footprint`` be defined directly in terms of ``cells`` rather than
/// have a recursive definition along with an equivalence lemma?
/// - is it worth the trouble defining a footprint? my intuition is that it's
/// fine and allows some clients to do very precise reasoning -- other modules
/// (e.g. AssocList), when establishing abstraction boundaries, can simplify
/// things and get rid of the precise footprint reasoning in favor of a static
/// region-based footprint
///
/// Some remaining work items:
/// - switch to C.Loops.while
open LowStar.BufferOps
module B = LowStar.Buffer
module HS = FStar.HyperStack
module G = FStar.Ghost
module L = FStar.List.Tot
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
open FStar.HyperStack.ST
/// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since
/// everything does recursive list reasoning.
#set-options "--__no_positivity --fuel 1 --ifuel 1"
/// Definition of the Low* type
/// ---------------------------
noeq
type t (a: Type0) =
B.pointer_or_null (cell a)
and cell (a: Type0) = {
next: t a;
data: a;
}
/// Unlike the canonical style that associates a ``v`` function to any stateful
/// representation, we use a relation here. Writing a function is just
/// impossible, since we can't prove termination of ``v`` owing to the fact that
/// there may be an infinite number of cells in the heap.
///
/// LL2 is the module that switches to the function style.
///
/// Note: no need to use erased here for ``l`` since the function is already in ``GTot``.
let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) =
B.live h c /\ (
match l with
| [] ->
B.g_is_null c
| a :: q ->
B.length c == 1 /\ (
let { data=data; next=next } = B.get h c 0 in
a == data /\
well_formed h next (G.hide q)
))
/// Precise reasoning via the cells predicate
/// -----------------------------------------
///
/// The modifies clauses are given either on the footprint of the list, or on a
/// region that includes the footprint of the list (higher up the stack, e.g.
/// LL2). This is good, but does not rule out "stupid" implementations that
/// might re-allocate every single list cell when, say, doing a pop.
///
/// For advanced usages which take pointers directly to individual list cells,
/// it's important to rule out these cases. We thus define the ``cells``
/// predicate for that purpose.
let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a)))
(requires well_formed h c l)
(ensures fun _ -> True)
(decreases l)
=
if B.g_is_null c then
[]
else
c :: cells h (B.deref h c).next (List.Tot.tl l)
/// A missing bit of automated reasoning
/// ------------------------------------
/// This should be absolutely trivial, yet, because there's no pattern on
/// null_unique, we have to do the case analysis and the decomposition
/// ourselves. This is quite tedious, as it usually takes a while (at least it
/// did for me!) to realize that this property does not hold automatically.
///
/// I'm setting an SMTPat on this lemma because it's absolutely impossible to
/// get any work done without it.
let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma
(requires (
well_formed h0 ll0 l0 /\
well_formed h1 ll1 l1 /\
cells h0 ll0 l0 == cells h1 ll1 l1))
(ensures (
ll0 == ll1))
[ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ]
=
if B.g_is_null ll0 && B.g_is_null ll1 then begin
B.null_unique ll0;
B.null_unique ll1
end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin
()
end else
false_elim ()
/// Classic stateful reasoning lemmas
/// ---------------------------------
///
/// This essentially follows ``stateful``, the type class of a mutable piece of
/// state defined using the modifies-theory of Low*v2 and equipped with the
/// right lemmas to enable usage by clients. See
/// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context.
val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc
(requires (well_formed h l n))
(ensures (fun refs -> True))
(decreases n)
let rec footprint #a h l n =
if B.g_is_null l
then B.loc_none
else
let {next = next} = B.get h l 0 in
let refs = footprint h next (G.hide (L.tl n)) in
B.loc_union (B.loc_addr_of_buffer l) refs
/// Departing from LinkedList4 here. I prefer to bolt these into the invariant
/// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to
/// deduce these.
val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_pairwise_disjoint #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\
cells_pairwise_disjoint h next (L.tl n)
val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_live_freeable #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.live h l /\ B.freeable l /\
cells_live_freeable h next (L.tl n)
val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let invariant #a h l n =
cells_live_freeable h l n /\ cells_pairwise_disjoint h l n
/// Normally this would be automatic and writing a custom lemma for that stuff
/// would be needed only when writing an fsti, however, as stated earlier,
/// recursion makes everything more difficult and this absolutely needs to be in
/// scope otherwise the modifies-clause theory cannot deduce disjointness of
/// fresh allocations w.r.t. the footprint.
let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a): Lemma
(requires well_formed h l n)
(ensures B.loc_in (footprint h l n) h)
(decreases n)
[ SMTPat (invariant h l n) ]
=
if B.g_is_null l then
()
else
let next = (B.deref h l).next in
invariant_loc_in_footprint h next (L.tl n)
/// Another absolutely essential lemma, for which interestingly the pattern
/// "invariant h1 l n" does not work, but well_formed does... I guess that's
/// alright.
let rec frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem): Lemma
(requires (
well_formed h0 l n /\
invariant h0 l n /\
B.loc_disjoint r (footprint h0 l n) /\
B.modifies r h0 h1
))
(ensures (
well_formed h1 l n /\
footprint h1 l n == footprint h0 l n /\
cells h1 l n == cells h0 l n /\
invariant h1 l n
))
(decreases n)
[ SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1) ]
=
if B.g_is_null l then
()
else
frame (B.deref h0 l).next (L.tl n) r h0 h1
/// Lemmas for working with linked lists
/// ------------------------------------
///
/// Since it's a recursive data structure, a lot of the automated reasoning from
/// LowStar.Buffer doesn't work since it requires inductions. Some helpful
/// properties are therefore proved here. | {
"checked_file": "/",
"dependencies": [
"TestLib.fsti.checked",
"prims.fst.checked",
"LowStar.Failure.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int32.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Lib.LinkedList.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
h: FStar.Monotonic.HyperStack.mem ->
c: LowStar.Lib.LinkedList.t a ->
l1: Prims.list a ->
l2: Prims.list a
-> FStar.Pervasives.Lemma
(requires
LowStar.Lib.LinkedList.well_formed h c l1 /\ LowStar.Lib.LinkedList.well_formed h c l2)
(ensures l1 == l2)
(decreases FStar.Ghost.reveal (FStar.Ghost.hide l1))
[
SMTPat (LowStar.Lib.LinkedList.well_formed h c l1);
SMTPat (LowStar.Lib.LinkedList.well_formed h c l2)
] | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"LowStar.Lib.LinkedList.t",
"Prims.list",
"LowStar.Monotonic.Buffer.g_is_null",
"LowStar.Lib.LinkedList.cell",
"LowStar.Buffer.trivial_preorder",
"Prims.bool",
"LowStar.Buffer.pointer_or_null",
"LowStar.Lib.LinkedList.length_functional",
"FStar.List.Tot.Base.tl",
"Prims.unit",
"LowStar.Monotonic.Buffer.get",
"Prims.l_and",
"LowStar.Lib.LinkedList.well_formed",
"Prims.squash",
"Prims.eq2",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil"
] | [
"recursion"
] | false | false | true | false | false | let rec length_functional #a (h: HS.mem) (c: t a) (l1: list a) (l2: list a)
: Lemma (requires (well_formed h c l1 /\ well_formed h c l2))
(ensures (l1 == l2))
(decreases (G.reveal l1))
[SMTPat (well_formed h c l1); SMTPat (well_formed h c l2)] =
| if B.g_is_null c
then ()
else
let { next = next } = B.get h c 0 in
length_functional h next (G.hide (L.tl l1)) (G.hide (L.tl l2)) | false |
LowStar.Lib.LinkedList.fst | LowStar.Lib.LinkedList.invariant_loc_in_footprint | val invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a)
: Lemma (requires well_formed h l n)
(ensures B.loc_in (footprint h l n) h)
(decreases n)
[SMTPat (invariant h l n)] | val invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a)
: Lemma (requires well_formed h l n)
(ensures B.loc_in (footprint h l n) h)
(decreases n)
[SMTPat (invariant h l n)] | let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a): Lemma
(requires well_formed h l n)
(ensures B.loc_in (footprint h l n) h)
(decreases n)
[ SMTPat (invariant h l n) ]
=
if B.g_is_null l then
()
else
let next = (B.deref h l).next in
invariant_loc_in_footprint h next (L.tl n) | {
"file_name": "krmllib/LowStar.Lib.LinkedList.fst",
"git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} | {
"end_col": 46,
"end_line": 194,
"start_col": 0,
"start_line": 184
} | module LowStar.Lib.LinkedList
/// This module, oftentimes referred to as LL1 in other parts of the
/// documentation, provides a low-level view over a linked list. Unless you
/// intend on modifying the structure of the linked list (e.g. removing cells)
/// or iterating over each cell, your are probably better off using LL2.
///
/// This module is intentionally not relying on a tight abstraction, to i) permit
/// direct-style iteration by clients and ii) allow stating some SMTPat lemmas
/// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can
/// happen automatically at the SMT level since LL2 does not have an fsti either).
///
/// Some open questions relative to the design of this module:
/// - should ``v`` be defined directly in terms of ``cells`` rather than have a
/// recursive definition along with an equivalence lemma?
/// - should ``footprint`` be defined directly in terms of ``cells`` rather than
/// have a recursive definition along with an equivalence lemma?
/// - is it worth the trouble defining a footprint? my intuition is that it's
/// fine and allows some clients to do very precise reasoning -- other modules
/// (e.g. AssocList), when establishing abstraction boundaries, can simplify
/// things and get rid of the precise footprint reasoning in favor of a static
/// region-based footprint
///
/// Some remaining work items:
/// - switch to C.Loops.while
open LowStar.BufferOps
module B = LowStar.Buffer
module HS = FStar.HyperStack
module G = FStar.Ghost
module L = FStar.List.Tot
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
open FStar.HyperStack.ST
/// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since
/// everything does recursive list reasoning.
#set-options "--__no_positivity --fuel 1 --ifuel 1"
/// Definition of the Low* type
/// ---------------------------
noeq
type t (a: Type0) =
B.pointer_or_null (cell a)
and cell (a: Type0) = {
next: t a;
data: a;
}
/// Unlike the canonical style that associates a ``v`` function to any stateful
/// representation, we use a relation here. Writing a function is just
/// impossible, since we can't prove termination of ``v`` owing to the fact that
/// there may be an infinite number of cells in the heap.
///
/// LL2 is the module that switches to the function style.
///
/// Note: no need to use erased here for ``l`` since the function is already in ``GTot``.
let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) =
B.live h c /\ (
match l with
| [] ->
B.g_is_null c
| a :: q ->
B.length c == 1 /\ (
let { data=data; next=next } = B.get h c 0 in
a == data /\
well_formed h next (G.hide q)
))
/// Precise reasoning via the cells predicate
/// -----------------------------------------
///
/// The modifies clauses are given either on the footprint of the list, or on a
/// region that includes the footprint of the list (higher up the stack, e.g.
/// LL2). This is good, but does not rule out "stupid" implementations that
/// might re-allocate every single list cell when, say, doing a pop.
///
/// For advanced usages which take pointers directly to individual list cells,
/// it's important to rule out these cases. We thus define the ``cells``
/// predicate for that purpose.
let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a)))
(requires well_formed h c l)
(ensures fun _ -> True)
(decreases l)
=
if B.g_is_null c then
[]
else
c :: cells h (B.deref h c).next (List.Tot.tl l)
/// A missing bit of automated reasoning
/// ------------------------------------
/// This should be absolutely trivial, yet, because there's no pattern on
/// null_unique, we have to do the case analysis and the decomposition
/// ourselves. This is quite tedious, as it usually takes a while (at least it
/// did for me!) to realize that this property does not hold automatically.
///
/// I'm setting an SMTPat on this lemma because it's absolutely impossible to
/// get any work done without it.
let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma
(requires (
well_formed h0 ll0 l0 /\
well_formed h1 ll1 l1 /\
cells h0 ll0 l0 == cells h1 ll1 l1))
(ensures (
ll0 == ll1))
[ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ]
=
if B.g_is_null ll0 && B.g_is_null ll1 then begin
B.null_unique ll0;
B.null_unique ll1
end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin
()
end else
false_elim ()
/// Classic stateful reasoning lemmas
/// ---------------------------------
///
/// This essentially follows ``stateful``, the type class of a mutable piece of
/// state defined using the modifies-theory of Low*v2 and equipped with the
/// right lemmas to enable usage by clients. See
/// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context.
val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc
(requires (well_formed h l n))
(ensures (fun refs -> True))
(decreases n)
let rec footprint #a h l n =
if B.g_is_null l
then B.loc_none
else
let {next = next} = B.get h l 0 in
let refs = footprint h next (G.hide (L.tl n)) in
B.loc_union (B.loc_addr_of_buffer l) refs
/// Departing from LinkedList4 here. I prefer to bolt these into the invariant
/// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to
/// deduce these.
val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_pairwise_disjoint #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\
cells_pairwise_disjoint h next (L.tl n)
val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_live_freeable #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.live h l /\ B.freeable l /\
cells_live_freeable h next (L.tl n)
val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let invariant #a h l n =
cells_live_freeable h l n /\ cells_pairwise_disjoint h l n
/// Normally this would be automatic and writing a custom lemma for that stuff
/// would be needed only when writing an fsti, however, as stated earlier,
/// recursion makes everything more difficult and this absolutely needs to be in
/// scope otherwise the modifies-clause theory cannot deduce disjointness of | {
"checked_file": "/",
"dependencies": [
"TestLib.fsti.checked",
"prims.fst.checked",
"LowStar.Failure.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int32.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Lib.LinkedList.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> l: LowStar.Lib.LinkedList.t a -> n: Prims.list a
-> FStar.Pervasives.Lemma (requires LowStar.Lib.LinkedList.well_formed h l n)
(ensures LowStar.Monotonic.Buffer.loc_in (LowStar.Lib.LinkedList.footprint h l n) h)
(decreases n)
[SMTPat (LowStar.Lib.LinkedList.invariant h l n)] | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"LowStar.Lib.LinkedList.t",
"Prims.list",
"LowStar.Monotonic.Buffer.g_is_null",
"LowStar.Lib.LinkedList.cell",
"LowStar.Buffer.trivial_preorder",
"Prims.bool",
"LowStar.Lib.LinkedList.invariant_loc_in_footprint",
"FStar.List.Tot.Base.tl",
"LowStar.Buffer.pointer_or_null",
"LowStar.Lib.LinkedList.__proj__Mkcell__item__next",
"LowStar.Monotonic.Buffer.deref",
"Prims.unit",
"LowStar.Lib.LinkedList.well_formed",
"Prims.squash",
"LowStar.Monotonic.Buffer.loc_in",
"LowStar.Lib.LinkedList.footprint",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"LowStar.Lib.LinkedList.invariant",
"Prims.Nil"
] | [
"recursion"
] | false | false | true | false | false | let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a)
: Lemma (requires well_formed h l n)
(ensures B.loc_in (footprint h l n) h)
(decreases n)
[SMTPat (invariant h l n)] =
| if B.g_is_null l
then ()
else
let next = (B.deref h l).next in
invariant_loc_in_footprint h next (L.tl n) | false |
LowStar.Lib.LinkedList.fst | LowStar.Lib.LinkedList.deref_cells_is_v | val deref_cells_is_v (#a: _) (h: HS.mem) (ll: t a) (l: list a)
: Lemma (requires well_formed h ll l /\ invariant h ll l)
(ensures gmap (deref_data h) (cells h ll l) == l)
(decreases l)
[SMTPat (well_formed h ll l)] | val deref_cells_is_v (#a: _) (h: HS.mem) (ll: t a) (l: list a)
: Lemma (requires well_formed h ll l /\ invariant h ll l)
(ensures gmap (deref_data h) (cells h ll l) == l)
(decreases l)
[SMTPat (well_formed h ll l)] | let rec deref_cells_is_v #a (h: HS.mem) (ll: t a) (l: list a): Lemma
(requires
well_formed h ll l /\
invariant h ll l)
(ensures
gmap (deref_data h) (cells h ll l) == l)
(decreases l)
[ SMTPat (well_formed h ll l) ]
=
if B.g_is_null ll then
()
else
deref_cells_is_v h (B.deref h ll).next (List.Tot.tl l) | {
"file_name": "krmllib/LowStar.Lib.LinkedList.fst",
"git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} | {
"end_col": 58,
"end_line": 288,
"start_col": 0,
"start_line": 276
} | module LowStar.Lib.LinkedList
/// This module, oftentimes referred to as LL1 in other parts of the
/// documentation, provides a low-level view over a linked list. Unless you
/// intend on modifying the structure of the linked list (e.g. removing cells)
/// or iterating over each cell, your are probably better off using LL2.
///
/// This module is intentionally not relying on a tight abstraction, to i) permit
/// direct-style iteration by clients and ii) allow stating some SMTPat lemmas
/// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can
/// happen automatically at the SMT level since LL2 does not have an fsti either).
///
/// Some open questions relative to the design of this module:
/// - should ``v`` be defined directly in terms of ``cells`` rather than have a
/// recursive definition along with an equivalence lemma?
/// - should ``footprint`` be defined directly in terms of ``cells`` rather than
/// have a recursive definition along with an equivalence lemma?
/// - is it worth the trouble defining a footprint? my intuition is that it's
/// fine and allows some clients to do very precise reasoning -- other modules
/// (e.g. AssocList), when establishing abstraction boundaries, can simplify
/// things and get rid of the precise footprint reasoning in favor of a static
/// region-based footprint
///
/// Some remaining work items:
/// - switch to C.Loops.while
open LowStar.BufferOps
module B = LowStar.Buffer
module HS = FStar.HyperStack
module G = FStar.Ghost
module L = FStar.List.Tot
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
open FStar.HyperStack.ST
/// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since
/// everything does recursive list reasoning.
#set-options "--__no_positivity --fuel 1 --ifuel 1"
/// Definition of the Low* type
/// ---------------------------
noeq
type t (a: Type0) =
B.pointer_or_null (cell a)
and cell (a: Type0) = {
next: t a;
data: a;
}
/// Unlike the canonical style that associates a ``v`` function to any stateful
/// representation, we use a relation here. Writing a function is just
/// impossible, since we can't prove termination of ``v`` owing to the fact that
/// there may be an infinite number of cells in the heap.
///
/// LL2 is the module that switches to the function style.
///
/// Note: no need to use erased here for ``l`` since the function is already in ``GTot``.
let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) =
B.live h c /\ (
match l with
| [] ->
B.g_is_null c
| a :: q ->
B.length c == 1 /\ (
let { data=data; next=next } = B.get h c 0 in
a == data /\
well_formed h next (G.hide q)
))
/// Precise reasoning via the cells predicate
/// -----------------------------------------
///
/// The modifies clauses are given either on the footprint of the list, or on a
/// region that includes the footprint of the list (higher up the stack, e.g.
/// LL2). This is good, but does not rule out "stupid" implementations that
/// might re-allocate every single list cell when, say, doing a pop.
///
/// For advanced usages which take pointers directly to individual list cells,
/// it's important to rule out these cases. We thus define the ``cells``
/// predicate for that purpose.
let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a)))
(requires well_formed h c l)
(ensures fun _ -> True)
(decreases l)
=
if B.g_is_null c then
[]
else
c :: cells h (B.deref h c).next (List.Tot.tl l)
/// A missing bit of automated reasoning
/// ------------------------------------
/// This should be absolutely trivial, yet, because there's no pattern on
/// null_unique, we have to do the case analysis and the decomposition
/// ourselves. This is quite tedious, as it usually takes a while (at least it
/// did for me!) to realize that this property does not hold automatically.
///
/// I'm setting an SMTPat on this lemma because it's absolutely impossible to
/// get any work done without it.
let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma
(requires (
well_formed h0 ll0 l0 /\
well_formed h1 ll1 l1 /\
cells h0 ll0 l0 == cells h1 ll1 l1))
(ensures (
ll0 == ll1))
[ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ]
=
if B.g_is_null ll0 && B.g_is_null ll1 then begin
B.null_unique ll0;
B.null_unique ll1
end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin
()
end else
false_elim ()
/// Classic stateful reasoning lemmas
/// ---------------------------------
///
/// This essentially follows ``stateful``, the type class of a mutable piece of
/// state defined using the modifies-theory of Low*v2 and equipped with the
/// right lemmas to enable usage by clients. See
/// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context.
val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc
(requires (well_formed h l n))
(ensures (fun refs -> True))
(decreases n)
let rec footprint #a h l n =
if B.g_is_null l
then B.loc_none
else
let {next = next} = B.get h l 0 in
let refs = footprint h next (G.hide (L.tl n)) in
B.loc_union (B.loc_addr_of_buffer l) refs
/// Departing from LinkedList4 here. I prefer to bolt these into the invariant
/// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to
/// deduce these.
val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_pairwise_disjoint #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\
cells_pairwise_disjoint h next (L.tl n)
val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_live_freeable #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.live h l /\ B.freeable l /\
cells_live_freeable h next (L.tl n)
val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let invariant #a h l n =
cells_live_freeable h l n /\ cells_pairwise_disjoint h l n
/// Normally this would be automatic and writing a custom lemma for that stuff
/// would be needed only when writing an fsti, however, as stated earlier,
/// recursion makes everything more difficult and this absolutely needs to be in
/// scope otherwise the modifies-clause theory cannot deduce disjointness of
/// fresh allocations w.r.t. the footprint.
let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a): Lemma
(requires well_formed h l n)
(ensures B.loc_in (footprint h l n) h)
(decreases n)
[ SMTPat (invariant h l n) ]
=
if B.g_is_null l then
()
else
let next = (B.deref h l).next in
invariant_loc_in_footprint h next (L.tl n)
/// Another absolutely essential lemma, for which interestingly the pattern
/// "invariant h1 l n" does not work, but well_formed does... I guess that's
/// alright.
let rec frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem): Lemma
(requires (
well_formed h0 l n /\
invariant h0 l n /\
B.loc_disjoint r (footprint h0 l n) /\
B.modifies r h0 h1
))
(ensures (
well_formed h1 l n /\
footprint h1 l n == footprint h0 l n /\
cells h1 l n == cells h0 l n /\
invariant h1 l n
))
(decreases n)
[ SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1) ]
=
if B.g_is_null l then
()
else
frame (B.deref h0 l).next (L.tl n) r h0 h1
/// Lemmas for working with linked lists
/// ------------------------------------
///
/// Since it's a recursive data structure, a lot of the automated reasoning from
/// LowStar.Buffer doesn't work since it requires inductions. Some helpful
/// properties are therefore proved here.
let rec length_functional #a (h: HS.mem) (c: t a) (l1 l2: list a):
Lemma
(requires (well_formed h c l1 /\ well_formed h c l2))
(ensures (l1 == l2))
(decreases (G.reveal l1))
[ SMTPat (well_formed h c l1); SMTPat (well_formed h c l2) ] =
if B.g_is_null c
then ()
else
let { next=next } = B.get h c 0 in
length_functional h next (G.hide (L.tl l1)) (G.hide (L.tl l2))
/// The footprint is based on loc_addr_of_buffer so that we can write a free
/// operation that operates on the footprint. However, this invalidates most of
/// the helper lemmas for disjointness that were present in the previous
/// iteration of this module, named LinkedList4.fst. It's ok, we bake
/// disjointness directly onto the invariant and it works just as well.
/// Connection between ``cells`` and ``v``
/// --------------------------------------
/// Redefining some helpers.
#push-options "--ifuel 1"
let rec gmap #a #b (f: a -> GTot b) (xs: list a): GTot (list b) =
match xs with
| [] -> []
| x :: xs -> f x :: gmap f xs
/// "As we all know", right folds are the easiest to work with because they
/// follow the natural structure of recursion (left-folds are evil).
let rec gfold_right #a #b (f: b -> a -> GTot b) (xs: list a) (acc: b): Ghost b
(requires True)
(ensures fun _ -> True)
(decreases xs)
=
match xs with
| [] -> acc
| x :: xs -> f (gfold_right f xs acc) x
#pop-options
/// Connecting ``v`` and ``cells``.
///
/// See ``tests/Wireguard.fst`` for why going through gmap is important and how
/// to structure your definitions (should you need to reason about ``cells``) in
/// a way that will make your life easier.
let deref_data #a (h: HS.mem) (c: B.pointer (cell a)): GTot a =
(B.deref h c).data | {
"checked_file": "/",
"dependencies": [
"TestLib.fsti.checked",
"prims.fst.checked",
"LowStar.Failure.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int32.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Lib.LinkedList.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: FStar.Monotonic.HyperStack.mem -> ll: LowStar.Lib.LinkedList.t a -> l: Prims.list a
-> FStar.Pervasives.Lemma
(requires LowStar.Lib.LinkedList.well_formed h ll l /\ LowStar.Lib.LinkedList.invariant h ll l
)
(ensures
LowStar.Lib.LinkedList.gmap (LowStar.Lib.LinkedList.deref_data h)
(LowStar.Lib.LinkedList.cells h ll l) ==
l)
(decreases l)
[SMTPat (LowStar.Lib.LinkedList.well_formed h ll l)] | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"FStar.Monotonic.HyperStack.mem",
"LowStar.Lib.LinkedList.t",
"Prims.list",
"LowStar.Monotonic.Buffer.g_is_null",
"LowStar.Lib.LinkedList.cell",
"LowStar.Buffer.trivial_preorder",
"Prims.bool",
"LowStar.Lib.LinkedList.deref_cells_is_v",
"LowStar.Lib.LinkedList.__proj__Mkcell__item__next",
"LowStar.Monotonic.Buffer.deref",
"FStar.List.Tot.Base.tl",
"Prims.unit",
"Prims.l_and",
"LowStar.Lib.LinkedList.well_formed",
"LowStar.Lib.LinkedList.invariant",
"Prims.squash",
"Prims.eq2",
"LowStar.Lib.LinkedList.gmap",
"LowStar.Buffer.pointer",
"LowStar.Lib.LinkedList.deref_data",
"LowStar.Lib.LinkedList.cells",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil"
] | [
"recursion"
] | false | false | true | false | false | let rec deref_cells_is_v #a (h: HS.mem) (ll: t a) (l: list a)
: Lemma (requires well_formed h ll l /\ invariant h ll l)
(ensures gmap (deref_data h) (cells h ll l) == l)
(decreases l)
[SMTPat (well_formed h ll l)] =
| if B.g_is_null ll then () else deref_cells_is_v h (B.deref h ll).next (List.Tot.tl l) | false |
LowStar.Lib.LinkedList.fst | LowStar.Lib.LinkedList.free_ | val free_: (#a: Type) -> (#n: G.erased (list a)) -> (l: t a) ->
ST unit
(requires (fun h ->
well_formed h l n /\
invariant h l n
))
(ensures (fun h0 _ h1 ->
B.(modifies (footprint h0 l n) h0 h1))) | val free_: (#a: Type) -> (#n: G.erased (list a)) -> (l: t a) ->
ST unit
(requires (fun h ->
well_formed h l n /\
invariant h l n
))
(ensures (fun h0 _ h1 ->
B.(modifies (footprint h0 l n) h0 h1))) | let rec free_ #a #n l =
if B.is_null l then
()
else begin
let tl: G.erased (list a) = G.hide (L.tl (G.reveal n)) in
free_ #_ #tl (!*l).next;
B.free l
end | {
"file_name": "krmllib/LowStar.Lib.LinkedList.fst",
"git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} | {
"end_col": 5,
"end_line": 430,
"start_col": 0,
"start_line": 423
} | module LowStar.Lib.LinkedList
/// This module, oftentimes referred to as LL1 in other parts of the
/// documentation, provides a low-level view over a linked list. Unless you
/// intend on modifying the structure of the linked list (e.g. removing cells)
/// or iterating over each cell, your are probably better off using LL2.
///
/// This module is intentionally not relying on a tight abstraction, to i) permit
/// direct-style iteration by clients and ii) allow stating some SMTPat lemmas
/// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can
/// happen automatically at the SMT level since LL2 does not have an fsti either).
///
/// Some open questions relative to the design of this module:
/// - should ``v`` be defined directly in terms of ``cells`` rather than have a
/// recursive definition along with an equivalence lemma?
/// - should ``footprint`` be defined directly in terms of ``cells`` rather than
/// have a recursive definition along with an equivalence lemma?
/// - is it worth the trouble defining a footprint? my intuition is that it's
/// fine and allows some clients to do very precise reasoning -- other modules
/// (e.g. AssocList), when establishing abstraction boundaries, can simplify
/// things and get rid of the precise footprint reasoning in favor of a static
/// region-based footprint
///
/// Some remaining work items:
/// - switch to C.Loops.while
open LowStar.BufferOps
module B = LowStar.Buffer
module HS = FStar.HyperStack
module G = FStar.Ghost
module L = FStar.List.Tot
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
open FStar.HyperStack.ST
/// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since
/// everything does recursive list reasoning.
#set-options "--__no_positivity --fuel 1 --ifuel 1"
/// Definition of the Low* type
/// ---------------------------
noeq
type t (a: Type0) =
B.pointer_or_null (cell a)
and cell (a: Type0) = {
next: t a;
data: a;
}
/// Unlike the canonical style that associates a ``v`` function to any stateful
/// representation, we use a relation here. Writing a function is just
/// impossible, since we can't prove termination of ``v`` owing to the fact that
/// there may be an infinite number of cells in the heap.
///
/// LL2 is the module that switches to the function style.
///
/// Note: no need to use erased here for ``l`` since the function is already in ``GTot``.
let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) =
B.live h c /\ (
match l with
| [] ->
B.g_is_null c
| a :: q ->
B.length c == 1 /\ (
let { data=data; next=next } = B.get h c 0 in
a == data /\
well_formed h next (G.hide q)
))
/// Precise reasoning via the cells predicate
/// -----------------------------------------
///
/// The modifies clauses are given either on the footprint of the list, or on a
/// region that includes the footprint of the list (higher up the stack, e.g.
/// LL2). This is good, but does not rule out "stupid" implementations that
/// might re-allocate every single list cell when, say, doing a pop.
///
/// For advanced usages which take pointers directly to individual list cells,
/// it's important to rule out these cases. We thus define the ``cells``
/// predicate for that purpose.
let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a)))
(requires well_formed h c l)
(ensures fun _ -> True)
(decreases l)
=
if B.g_is_null c then
[]
else
c :: cells h (B.deref h c).next (List.Tot.tl l)
/// A missing bit of automated reasoning
/// ------------------------------------
/// This should be absolutely trivial, yet, because there's no pattern on
/// null_unique, we have to do the case analysis and the decomposition
/// ourselves. This is quite tedious, as it usually takes a while (at least it
/// did for me!) to realize that this property does not hold automatically.
///
/// I'm setting an SMTPat on this lemma because it's absolutely impossible to
/// get any work done without it.
let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma
(requires (
well_formed h0 ll0 l0 /\
well_formed h1 ll1 l1 /\
cells h0 ll0 l0 == cells h1 ll1 l1))
(ensures (
ll0 == ll1))
[ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ]
=
if B.g_is_null ll0 && B.g_is_null ll1 then begin
B.null_unique ll0;
B.null_unique ll1
end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin
()
end else
false_elim ()
/// Classic stateful reasoning lemmas
/// ---------------------------------
///
/// This essentially follows ``stateful``, the type class of a mutable piece of
/// state defined using the modifies-theory of Low*v2 and equipped with the
/// right lemmas to enable usage by clients. See
/// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context.
val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc
(requires (well_formed h l n))
(ensures (fun refs -> True))
(decreases n)
let rec footprint #a h l n =
if B.g_is_null l
then B.loc_none
else
let {next = next} = B.get h l 0 in
let refs = footprint h next (G.hide (L.tl n)) in
B.loc_union (B.loc_addr_of_buffer l) refs
/// Departing from LinkedList4 here. I prefer to bolt these into the invariant
/// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to
/// deduce these.
val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_pairwise_disjoint #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\
cells_pairwise_disjoint h next (L.tl n)
val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_live_freeable #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.live h l /\ B.freeable l /\
cells_live_freeable h next (L.tl n)
val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let invariant #a h l n =
cells_live_freeable h l n /\ cells_pairwise_disjoint h l n
/// Normally this would be automatic and writing a custom lemma for that stuff
/// would be needed only when writing an fsti, however, as stated earlier,
/// recursion makes everything more difficult and this absolutely needs to be in
/// scope otherwise the modifies-clause theory cannot deduce disjointness of
/// fresh allocations w.r.t. the footprint.
let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a): Lemma
(requires well_formed h l n)
(ensures B.loc_in (footprint h l n) h)
(decreases n)
[ SMTPat (invariant h l n) ]
=
if B.g_is_null l then
()
else
let next = (B.deref h l).next in
invariant_loc_in_footprint h next (L.tl n)
/// Another absolutely essential lemma, for which interestingly the pattern
/// "invariant h1 l n" does not work, but well_formed does... I guess that's
/// alright.
let rec frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem): Lemma
(requires (
well_formed h0 l n /\
invariant h0 l n /\
B.loc_disjoint r (footprint h0 l n) /\
B.modifies r h0 h1
))
(ensures (
well_formed h1 l n /\
footprint h1 l n == footprint h0 l n /\
cells h1 l n == cells h0 l n /\
invariant h1 l n
))
(decreases n)
[ SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1) ]
=
if B.g_is_null l then
()
else
frame (B.deref h0 l).next (L.tl n) r h0 h1
/// Lemmas for working with linked lists
/// ------------------------------------
///
/// Since it's a recursive data structure, a lot of the automated reasoning from
/// LowStar.Buffer doesn't work since it requires inductions. Some helpful
/// properties are therefore proved here.
let rec length_functional #a (h: HS.mem) (c: t a) (l1 l2: list a):
Lemma
(requires (well_formed h c l1 /\ well_formed h c l2))
(ensures (l1 == l2))
(decreases (G.reveal l1))
[ SMTPat (well_formed h c l1); SMTPat (well_formed h c l2) ] =
if B.g_is_null c
then ()
else
let { next=next } = B.get h c 0 in
length_functional h next (G.hide (L.tl l1)) (G.hide (L.tl l2))
/// The footprint is based on loc_addr_of_buffer so that we can write a free
/// operation that operates on the footprint. However, this invalidates most of
/// the helper lemmas for disjointness that were present in the previous
/// iteration of this module, named LinkedList4.fst. It's ok, we bake
/// disjointness directly onto the invariant and it works just as well.
/// Connection between ``cells`` and ``v``
/// --------------------------------------
/// Redefining some helpers.
#push-options "--ifuel 1"
let rec gmap #a #b (f: a -> GTot b) (xs: list a): GTot (list b) =
match xs with
| [] -> []
| x :: xs -> f x :: gmap f xs
/// "As we all know", right folds are the easiest to work with because they
/// follow the natural structure of recursion (left-folds are evil).
let rec gfold_right #a #b (f: b -> a -> GTot b) (xs: list a) (acc: b): Ghost b
(requires True)
(ensures fun _ -> True)
(decreases xs)
=
match xs with
| [] -> acc
| x :: xs -> f (gfold_right f xs acc) x
#pop-options
/// Connecting ``v`` and ``cells``.
///
/// See ``tests/Wireguard.fst`` for why going through gmap is important and how
/// to structure your definitions (should you need to reason about ``cells``) in
/// a way that will make your life easier.
let deref_data #a (h: HS.mem) (c: B.pointer (cell a)): GTot a =
(B.deref h c).data
#push-options "--fuel 1 --ifuel 1"
let rec deref_cells_is_v #a (h: HS.mem) (ll: t a) (l: list a): Lemma
(requires
well_formed h ll l /\
invariant h ll l)
(ensures
gmap (deref_data h) (cells h ll l) == l)
(decreases l)
[ SMTPat (well_formed h ll l) ]
=
if B.g_is_null ll then
()
else
deref_cells_is_v h (B.deref h ll).next (List.Tot.tl l)
#pop-options
/// Connecting ``footprint`` and ``cells``.
///
/// This allows conveniently switching to a low-level representation of the
/// footprint in case clients want to do some ultra-precise reasoning about
/// what's happening with the list spine. However, the fact that all
/// operations from this module specify things in terms of ``cells`` along with
/// ``same_cells_same_pointer`` should cover most common cases. (This predates
/// the introduction of ``same_cells_same_pointer``.)
///
/// So, no SMTPat here. Note, I also used the same trick as above with
/// higher-order combinators to isolate the use of the argument ``h`` to a
/// single sub-term rather than having it passed down the recursive calls.
#push-options "--fuel 2 --ifuel 2"
let rec footprint_via_cells_is_footprint #a (h: HS.mem) (ll: t a) (l: list a): Lemma
(requires well_formed h ll l)
(ensures
footprint h ll l == (gfold_right B.loc_union (gmap B.loc_addr_of_buffer (cells h ll l)) B.loc_none))
(decreases l)
=
if B.g_is_null ll then
()
else
footprint_via_cells_is_footprint h (B.deref h ll).next (List.Tot.tl l)
#pop-options
/// Stateful operations
/// -------------------
///
/// One thing to note: we pass the region `r` explicitly, which is certainly not
/// very convenient, but that's alright, another layer of abstraction will take
/// care of adding existentials and extra machinery to make this more pleasant
/// to use.
///
/// All of the operations below are low-level (in the sense that they rely on
/// the predicate). I expect clients to use exclusively the variants of these
/// functions present in LL2.
val push: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) -> (x: a) ->
ST unit
(requires (fun h ->
let l = B.deref h pl in
B.live h pl /\
well_formed h l n /\
invariant h l n /\
ST.is_eternal_region r /\
B.(loc_includes (loc_region_only true r) (footprint h l n)) /\
B.(loc_disjoint (loc_buffer pl) (loc_region_only true r))
))
(ensures (fun h0 _ h1 ->
let n' = G.hide (x :: G.reveal n) in
let l = B.deref h1 pl in
// Style note: I don't repeat ``B.live pl`` in the post-condition since
// ``B.modifies (loc_buffer pl) h0 h1`` implies that ``B.live h1 pl``.
B.modifies (B.loc_buffer pl) h0 h1 /\
well_formed h1 l n' /\
invariant h1 l n' /\
B.(loc_includes (loc_region_only true r) (footprint h1 l n') /\
Cons? (cells h1 l n') /\ List.Tot.tail (cells h1 l n') == cells h0 (B.deref h0 pl) n /\
B.fresh_loc (B.loc_addr_of_buffer (List.Tot.hd (cells h1 l n'))) h0 h1)
))
let push #a r n pl x =
(**) let h0 = ST.get () in
let l = !* pl in
let c = { data = x; next = l } in
let pc: B.pointer (cell a) = B.malloc r c 1ul in
(**) let h1 = ST.get () in
(**) B.(modifies_only_not_unused_in loc_none h0 h1);
(**) assert B.(loc_disjoint (loc_buffer pc) (footprint h0 l n));
pl *= pc;
(**) let h2 = ST.get () in
(**) let n' = G.hide (x :: G.reveal n) in
(**) B.(modifies_trans loc_none h0 h1 (loc_buffer pl) h2);
(**) assert (well_formed h2 (B.deref h2 pl) n');
(**) assert (invariant h2 (B.deref h2 pl) n');
(**) assert ((B.deref h2 (B.deref h2 pl)).next == l);
()
val pop: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) ->
ST a
(requires (fun h ->
let l = B.deref h pl in
B.live h pl /\
well_formed h l n /\
invariant h l n /\
ST.is_eternal_region r /\
B.(loc_includes (loc_region_only true r) (footprint h l n)) /\
B.loc_disjoint (B.loc_buffer pl) (footprint h l n) /\
Cons? n
))
(ensures (fun h0 x h1 ->
let l = B.deref h1 pl in
let n' = L.tl n in
x == L.hd n /\
// Introducing a super precise modifies clause (e.g. loc_addr_of_buffer
// (B.deref h0 pl)) here is not useful and prevents trigger-based
// reasoning, while also requiring clients to unroll footprint. There's a
// tension here between revealing that ``pop`` does nothing stupid (e.g.
// re-allocating all the list cells) and providing an abstract enough
// predicate to work with.
B.(modifies (loc_buffer pl `loc_union` footprint h0 (B.deref h0 pl) n) h0 h1) /\
well_formed h1 l n' /\
invariant h1 l n' /\
B.(loc_includes (loc_region_only true r) (footprint h1 l n')) /\
List.Tot.tail (cells h0 (B.deref h0 pl) n) == cells h1 l n'))
let pop #a r n pl =
let l = !* pl in
let r = (!*l).data in
let next = (!*l).next in
(**) let h1 = ST.get () in
(**) assert (cells h1 l n == l :: cells h1 next (List.Tot.tl n));
(**) assert B.(loc_disjoint (loc_buffer pl) (footprint h1 l n));
(**) assert B.(loc_disjoint (loc_buffer pl) (footprint h1 next (List.Tot.tl n)));
pl *= next;
B.free l;
r
val free_: (#a: Type) -> (#n: G.erased (list a)) -> (l: t a) ->
ST unit
(requires (fun h ->
well_formed h l n /\
invariant h l n
))
(ensures (fun h0 _ h1 ->
B.(modifies (footprint h0 l n) h0 h1))) | {
"checked_file": "/",
"dependencies": [
"TestLib.fsti.checked",
"prims.fst.checked",
"LowStar.Failure.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int32.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Lib.LinkedList.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l: LowStar.Lib.LinkedList.t a -> FStar.HyperStack.ST.ST Prims.unit | FStar.HyperStack.ST.ST | [] | [] | [
"FStar.Ghost.erased",
"Prims.list",
"LowStar.Lib.LinkedList.t",
"Prims.unit",
"Prims.bool",
"LowStar.Monotonic.Buffer.free",
"LowStar.Lib.LinkedList.cell",
"LowStar.Buffer.trivial_preorder",
"LowStar.Lib.LinkedList.free_",
"LowStar.Lib.LinkedList.__proj__Mkcell__item__next",
"LowStar.BufferOps.op_Bang_Star",
"FStar.Ghost.hide",
"FStar.List.Tot.Base.tl",
"FStar.Ghost.reveal",
"LowStar.Monotonic.Buffer.is_null"
] | [
"recursion"
] | false | true | false | false | false | let rec free_ #a #n l =
| if B.is_null l
then ()
else
let tl:G.erased (list a) = G.hide (L.tl (G.reveal n)) in
free_ #_ #tl (!*l).next;
B.free l | false |
Vale.AES.X64.GCMdecryptOpt.fst | Vale.AES.X64.GCMdecryptOpt.va_wpProof_Gcm_blocks_wrapped | val va_wpProof_Gcm_blocks_wrapped : alg:algorithm -> offset:int -> auth_b:buffer128 ->
abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 -> in128_b:buffer128 ->
out128_b:buffer128 -> inout_b:buffer128 -> iv_b:buffer128 -> iv:supported_iv_LE ->
scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> expected_tag:(seq nat8) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gcm_blocks_wrapped alg offset auth_b abytes_b in128x6_b
out128x6_b in128_b out128_b inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b
expected_tag va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks_wrapped alg offset)
([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3;
va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) | val va_wpProof_Gcm_blocks_wrapped : alg:algorithm -> offset:int -> auth_b:buffer128 ->
abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 -> in128_b:buffer128 ->
out128_b:buffer128 -> inout_b:buffer128 -> iv_b:buffer128 -> iv:supported_iv_LE ->
scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> expected_tag:(seq nat8) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gcm_blocks_wrapped alg offset auth_b abytes_b in128x6_b
out128x6_b in128_b out128_b inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b
expected_tag va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks_wrapped alg offset)
([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3;
va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) | let va_wpProof_Gcm_blocks_wrapped alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b
inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b expected_tag va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_blocks_wrapped (va_code_Gcm_blocks_wrapped alg offset) va_s0
alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b iv scratch_b key
round_keys keys_b hkeys_b expected_tag in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM
(va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm
13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm
9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM
(va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM
(va_update_reg64 rRbp va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))))))))))))))))))))))))))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | {
"file_name": "obj/Vale.AES.X64.GCMdecryptOpt.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 1889,
"start_col": 0,
"start_line": 1861
} | module Vale.AES.X64.GCMdecryptOpt
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open FStar.Seq
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_s
open Vale.AES.GCTR_s
open Vale.AES.GCTR
open Vale.AES.GCM
open Vale.AES.GHash_s
open Vale.AES.GHash
open Vale.AES.GCM_s
open Vale.AES.X64.AES
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.Poly1305.Math
open Vale.AES.GCM_helpers
open Vale.AES.X64.GHash
open Vale.AES.X64.GCTR
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.X64.Stack_i
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.InsBasic
open Vale.X64.InsMem
open Vale.X64.InsVector
open Vale.X64.InsStack
open Vale.X64.InsAes
open Vale.X64.QuickCode
open Vale.X64.QuickCodes
open Vale.AES.X64.GF128_Mul
open Vale.X64.Stack
open Vale.X64.CPU_Features_s
open Vale.Math.Poly2.Bits_s
open Vale.AES.X64.AESopt
open Vale.AES.X64.AESGCM
open Vale.AES.X64.AESopt2
open Vale.Lib.Meta
open Vale.AES.X64.GCMencryptOpt
open Vale.AES.OptPublic
open Vale.Lib.Basic
#reset-options "--z3rlimit 20 --max_ifuel 0"
//-- Gcm_extra_bytes
val va_code_Gcm_extra_bytes : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_extra_bytes alg =
(va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0)
(va_op_reg_opr64_reg64 rRax) 0 Secret) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 10)
(va_op_xmm_xmm 0)) (va_CCons (va_code_Ghash_extra_bytes ()) (va_CCons (va_code_Mov128
(va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_CCons (va_code_Pshufb (va_op_xmm_xmm 0)
(va_op_xmm_xmm 9)) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons (va_code_Pxor
(va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_CCons (va_code_Store128_buffer
(va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret)
(va_CNil ()))))))))))
val va_codegen_success_Gcm_extra_bytes : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_extra_bytes alg =
(va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0)
(va_op_reg_opr64_reg64 rRax) 0 Secret) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm
10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Ghash_extra_bytes ()) (va_pbool_and
(va_codegen_success_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_pbool_and
(va_codegen_success_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and
(va_codegen_success_AESEncryptBlock alg) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm
10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Store128_buffer
(va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret)
(va_ttrue ())))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_extra_bytes (va_mods:va_mods_t) (alg:algorithm) (inout_b:buffer128) (key:(seq
nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat)
(old_hash:quad32) (completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit
(va_code_Gcm_extra_bytes alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (len:(va_int_range
1 1)) = 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 188 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRax) 0 Secret inout_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 189 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (fun (va_s:va_state) _ -> let
(hash_input:quad32) = va_get_xmm 0 va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 193 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_extra_bytes hkeys_b total_bytes old_hash h_LE completed_quads) (fun
(va_s:va_state) _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 194 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.equal #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s)
inout_b) (FStar.Seq.Base.create #quad32 1 hash_input)) (let (snap:(FStar.Seq.Base.seq
Vale.X64.Decls.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 198 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 199 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 200 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AESEncryptBlock alg (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 11 va_s)) key
round_keys keys_b) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 201 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.AES_s.aes_encrypt_LE_reveal ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 204 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 205 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax)
(va_op_xmm_xmm 10) 0 Secret inout_b 0) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 207 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.gctr_partial_reveal ()) (va_QEmpty (()))))))))))))))
val va_lemma_Gcm_extra_bytes : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
inout_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> total_bytes:nat -> old_hash:quad32 -> completed_quads:(seq quad32) ->
h_LE:quad32
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_extra_bytes alg) va_s0 /\ va_get_ok va_s0 /\ (let
(len:(va_int_range 1 1)) = 1 in sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b
inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b inout_b /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax va_s0) inout_b
len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys
keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0
va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32
(Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length
#quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply`
FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes
`op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16
`op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
(Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads =
FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0)
inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes =
Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) /\ va_state_eq va_sM
(va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM (va_update_ok va_sM
(va_update_mem va_sM va_s0))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_extra_bytes va_b0 va_s0 alg inout_b key round_keys keys_b hkeys_b total_bytes
old_hash completed_quads h_LE =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_extra_bytes va_mods alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_extra_bytes alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 121 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (len:(va_int_range 1 1)) = 1 in label va_range1
"***** POSTCONDITION NOT MET AT line 174 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 177 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg len (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0)) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 180 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let raw_quads = FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 181 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 182 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 183 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let input_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 186 column 59 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(l_and (FStar.Seq.Base.length #Vale.Def.Types_s.quad32 input_quads > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE old_hash input_quads)))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm
7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32)
(completed_quads:(seq quad32)) (h_LE:quad32) (va_s0:va_state) (va_k:(va_state -> unit -> Type0))
: Type0 =
(va_get_ok va_s0 /\ (let (len:(va_int_range 1 1)) = 1 in sse_enabled /\
Vale.X64.Decls.buffers_disjoint128 keys_b inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b
inout_b /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax
va_s0) inout_b len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys
keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0
va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32
(Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length
#quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply`
FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes
`op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16
`op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
(Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes) /\ (forall
(va_x_mem:vale_heap) (va_x_rcx:nat64) (va_x_r11:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32)
(va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32)
(va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm10:quad32) (va_x_heap5:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 5
va_x_heap5 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7
(va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3
(va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR11
va_x_r11 (va_upd_reg64 rRcx va_x_rcx (va_upd_mem va_x_mem va_s0)))))))))))))) in va_get_ok
va_sM /\ (let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads =
FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0)
inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes =
Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) ==> va_k va_sM (())))
val va_wpProof_Gcm_extra_bytes : alg:algorithm -> inout_b:buffer128 -> key:(seq nat32) ->
round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> total_bytes:nat ->
old_hash:quad32 -> completed_quads:(seq quad32) -> h_LE: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_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_extra_bytes alg) ([va_Mod_flags;
va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5;
va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11;
va_Mod_reg64 rRcx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash
completed_quads h_LE va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_extra_bytes (va_code_Gcm_extra_bytes alg) va_s0 alg inout_b key
round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10
va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm
7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32)
(completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit (va_code_Gcm_extra_bytes alg)) =
(va_QProc (va_code_Gcm_extra_bytes alg) ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10;
va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm
2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem])
(va_wp_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash
completed_quads h_LE) (va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE))
//--
//-- Gcm_blocks128
val va_code_Gcm_blocks128 : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks128 alg =
(va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi))
(va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_CCons
(va_code_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_CCons
(va_code_Ghash_buffer ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdi)
(va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx)
(va_op_opr64_reg64 rR12)) (va_CCons (va_code_Gctr_blocks128 alg) (va_CNil ())))))))))
val va_codegen_success_Gcm_blocks128 : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks128 alg =
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi))
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx))
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax))
(va_pbool_and (va_codegen_success_Ghash_buffer ()) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_pbool_and
(va_codegen_success_Gctr_blocks128 alg) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks128 (va_mods:va_mods_t) (alg:algorithm) (in_b:buffer128) (out_b:buffer128)
(key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32)
: (va_quickCode unit (va_code_Gcm_blocks128 alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 274 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 275 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 276 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 277 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_buffer hkeys_b in_b h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_old_s))) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 278 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 279 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 280 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gctr_blocks128 alg in_b out_b key round_keys keys_b) (va_QEmpty (()))))))))))
val va_lemma_Gcm_blocks128 : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> in_b:buffer128 ->
out_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> h_LE:quad32
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks128 alg) va_s0 /\ va_get_ok va_s0 /\
(sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b out_b /\
Vale.X64.Decls.buffers_disjoint128 hkeys_b out_b /\ (Vale.X64.Decls.buffers_disjoint128 in_b
out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16
`op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply`
va_get_reg64 rRdx va_s0 < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b)
(Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx
va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\
va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8
va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0)
(va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM ==
va_get_xmm 8 va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b ==
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ (va_get_reg64 rRdx va_s0 > 0 ==>
l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==> FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b)))) /\ va_state_eq va_sM (va_update_flags va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 10 va_sM (va_update_xmm 11 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rR10 va_sM
(va_update_reg64 rR11 va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRbx va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_blocks128 va_b0 va_s0 alg in_b out_b key round_keys keys_b hkeys_b h_LE =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11;
va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm
2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks128 va_mods alg in_b out_b key round_keys keys_b hkeys_b h_LE in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks128 alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 210 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 255 column 53 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 261 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 262 column 45 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0) (va_get_reg64 rRdx
va_s0)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 265 column 93 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM == va_get_xmm 8 va_s0)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b == Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) out_b)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 267 column 131 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRdx va_s0 > 0 ==> l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==>
FStar.Seq.Base.length #Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm
8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2;
va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_blocks128 (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32) (va_s0:va_state)
(va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b out_b /\
Vale.X64.Decls.buffers_disjoint128 hkeys_b out_b /\ (Vale.X64.Decls.buffers_disjoint128 in_b
out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16
`op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply`
va_get_reg64 rRdx va_s0 < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b)
(Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx
va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\
va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8
va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret) /\ (forall (va_x_mem:vale_heap) (va_x_rbx:nat64) (va_x_rdi:nat64) (va_x_r11:nat64)
(va_x_r10:nat64) (va_x_rdx:nat64) (va_x_r12:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32)
(va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32)
(va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm11:quad32) (va_x_xmm10:quad32)
(va_x_heap1:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 11 va_x_xmm11
(va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5
(va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1
(va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64
rR10 va_x_r10 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRbx
va_x_rbx (va_upd_mem va_x_mem va_s0))))))))))))))))))) in va_get_ok va_sM /\
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0)
(va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM ==
va_get_xmm 8 va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b ==
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ (va_get_reg64 rRdx va_s0 > 0 ==>
l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==> FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b)))) ==> va_k va_sM (())))
val va_wpProof_Gcm_blocks128 : alg:algorithm -> in_b:buffer128 -> out_b:buffer128 -> key:(seq
nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> h_LE: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_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b
h_LE va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks128 alg) ([va_Mod_flags;
va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6;
va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0;
va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10; va_Mod_reg64 rR11; va_Mod_reg64 rRdi;
va_Mod_reg64 rRbx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_blocks128 (va_code_Gcm_blocks128 alg) va_s0 alg in_b out_b key
round_keys keys_b hkeys_b h_LE in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 1 va_sM (va_update_xmm 10
va_sM (va_update_xmm 11 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6
va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2
va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR12 va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rRdi va_sM (va_update_reg64 rRbx va_sM (va_update_ok va_sM (va_update_mem
va_sM va_s0))))))))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm
8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2;
va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_blocks128 (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32) : (va_quickCode
unit (va_code_Gcm_blocks128 alg)) =
(va_QProc (va_code_Gcm_blocks128 alg) ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10;
va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm
3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64
rR10; va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_mem])
(va_wp_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE)
(va_wpProof_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE))
//--
//-- Gcm_blocks
#push-options "--z3rlimit 1000"
val va_code_Gcm_blocks : alg:algorithm -> offset:int -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks alg offset =
(va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx))
(va_CCons (va_code_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9) (va_const_opr64
32)) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRsp)
(offset + 0)) (va_CCons (va_code_Gcm_blocks_auth ()) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8)) (va_CCons
(va_code_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp) (offset + 16))
(va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp)
(offset + 24)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13))
(va_CCons (va_code_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64
rR8) 0 Public) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_reg_opr64_reg64 rRbp) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_Load_one_lsb
(va_op_xmm_xmm 10)) (va_CCons (va_code_VPaddd (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)
(va_op_xmm_xmm 10)) (va_CCons (va_code_AES_GCM_decrypt_6mult alg) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11) (va_op_reg_opr64_reg64
rRbp) 32 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx))
(va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp)
(offset + 32)) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRdi)
(va_op_reg_opr64_reg64 rRsp) (offset + 40)) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 48)) (va_CCons
(va_code_Mov64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRdx)) (va_CCons
(va_code_InitPshufbMask (va_op_xmm_xmm 9) (va_op_reg_opr64_reg64 rR12)) (va_CCons
(va_code_Pshufb (va_op_xmm_xmm 11) (va_op_xmm_xmm 9)) (va_CCons (va_code_Gcm_blocks128 alg)
(va_CCons (va_code_Stack_lemma ()) (va_CCons (va_code_Add64 (va_op_dst_opr64_reg64 rR14)
(va_opr_code_Stack (va_op_reg64_reg64 rRsp) (offset + 24) Public)) (va_CCons (va_code_IMul64
(va_op_dst_opr64_reg64 rR14) (va_const_opr64 16)) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rR13) (va_op_reg_opr64_reg64 rRsp) (offset + 64)) (va_CCons (va_IfElse
(va_cmp_gt (va_op_cmp_reg64 rR13) (va_op_cmp_reg64 rR14)) (va_Block (va_CCons
(va_code_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 56))
(va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR13)) (va_CCons
(va_code_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 15)) (va_CCons
(va_code_Gcm_extra_bytes alg) (va_CCons (va_Block (va_CNil ())) (va_CNil ()))))))) (va_Block
(va_CNil ()))) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15))
(va_CCons (va_code_Gcm_make_length_quad ()) (va_CCons (va_code_Ghash_register ()) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRbp) 0 Secret) (va_CCons (va_code_Gctr_register alg) (va_CCons (va_Block (va_CNil ()))
(va_CNil ()))))))))))))))))))))))))))))))))))))
val va_codegen_success_Gcm_blocks : alg:algorithm -> offset:int -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks alg offset =
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx))
(va_pbool_and (va_codegen_success_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9)
(va_const_opr64 32)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64
rRbx) (va_op_reg_opr64_reg64 rRsp) (offset + 0)) (va_pbool_and
(va_codegen_success_Gcm_blocks_auth ()) (va_pbool_and (va_codegen_success_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8)) (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp)
(offset + 16)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRdx)
(va_op_reg_opr64_reg64 rRsp) (offset + 24)) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13)) (va_pbool_and (va_codegen_success_Mov128
(va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_Load128_buffer
(va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rR8) 0 Public)
(va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_reg_opr64_reg64 rRbp) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and
(va_codegen_success_Load_one_lsb (va_op_xmm_xmm 10)) (va_pbool_and (va_codegen_success_VPaddd
(va_op_xmm_xmm 1) (va_op_xmm_xmm 1) (va_op_xmm_xmm 10)) (va_pbool_and
(va_codegen_success_AES_GCM_decrypt_6mult alg) (va_pbool_and (va_codegen_success_Load128_buffer
(va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11) (va_op_reg_opr64_reg64 rRbp) 32 Secret)
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx))
(va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRax)
(va_op_reg_opr64_reg64 rRsp) (offset + 32)) (va_pbool_and (va_codegen_success_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 40)) (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp)
(offset + 48)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR14)
(va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_InitPshufbMask (va_op_xmm_xmm 9)
(va_op_reg_opr64_reg64 rR12)) (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 11)
(va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_Gcm_blocks128 alg) (va_pbool_and
(va_codegen_success_Stack_lemma ()) (va_pbool_and (va_codegen_success_Add64
(va_op_dst_opr64_reg64 rR14) (va_opr_code_Stack (va_op_reg64_reg64 rRsp) (offset + 24) Public))
(va_pbool_and (va_codegen_success_IMul64 (va_op_dst_opr64_reg64 rR14) (va_const_opr64 16))
(va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rR13)
(va_op_reg_opr64_reg64 rRsp) (offset + 64)) (va_pbool_and (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp)
(offset + 56)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR10)
(va_op_opr64_reg64 rR13)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rR10)
(va_const_opr64 15)) (va_codegen_success_Gcm_extra_bytes alg)))) (va_pbool_and
(va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15)) (va_pbool_and
(va_codegen_success_Gcm_make_length_quad ()) (va_pbool_and (va_codegen_success_Ghash_register
()) (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRbp) 0 Secret) (va_pbool_and
(va_codegen_success_Gctr_register alg) (va_ttrue ()))))))))))))))))))))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks (va_mods:va_mods_t) (alg:algorithm) (offset:int) (auth_b:buffer128)
(abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128)
(out128_b:buffer128) (inout_b:buffer128) (iv_b:buffer128) (scratch_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit
(va_code_Gcm_blocks alg offset)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 0) (va_get_stack va_s) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 8) (va_get_stack va_s) in let
(out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 16) (va_get_stack va_s) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 24) (va_get_stack va_s) in let
(in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 32) (va_get_stack va_s) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 40) (va_get_stack va_s) in let
(len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset
+ 48) (va_get_stack va_s) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 56) (va_get_stack va_s) in let
(plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s
+ offset + 64) (va_get_stack va_s) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_old_s)) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 463 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 464 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9) (va_const_opr64 32))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 465 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRsp) (offset + 0))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 466 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks_auth auth_b abytes_b hkeys_b h_LE) (fun (va_s:va_state)
(auth_quad_seq:(seq quad32)) -> let (y_0:quad32) = Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 0 0 0 0 in let (y_auth_bytes:quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 473 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 474 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp) (offset + 16))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 475 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 24))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 476 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 477 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (fun (va_s:va_state) _ -> let
(iv_BE:Vale.X64.Decls.quad32) = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2
va_old_s) in let (ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32
iv_BE 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 483 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64
rR8) 0 Public iv_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 485 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_reg_opr64_reg64 rRbp)
(va_op_xmm_xmm 1) 0 Secret scratch_b 0) (fun (va_s:va_state) _ -> let (j0:quad32) = va_get_xmm
1 va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 487 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load_one_lsb (va_op_xmm_xmm 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 489 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_VPaddd (va_op_xmm_xmm 1) (va_op_xmm_xmm 1) (va_op_xmm_xmm 10)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 491 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AES_GCM_decrypt_6mult alg h_LE iv_b in128x6_b out128x6_b scratch_b key round_keys
keys_b hkeys_b) (fun (va_s:va_state) _ -> let (y_cipher128x6:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in let (auth_in:(seq quad32)) =
auth_quad_seq in let (va_arg138:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) =
Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b in let
(va_arg137:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg136:Vale.Def.Types_s.quad32) = y_auth_bytes in let (va_arg135:Vale.Def.Types_s.quad32) =
y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 494 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_ghash_incremental0_append h_LE va_arg135 va_arg136
y_cipher128x6 va_arg137 va_arg138) (let auth_in = FStar.Seq.Base.append #quad32 auth_in
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 498 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11)
(va_op_reg_opr64_reg64 rRbp) 32 Secret scratch_b 2) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 499 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 500 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 32))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 501 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 40))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 502 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 48))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 503 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 504 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_InitPshufbMask (va_op_xmm_xmm 9) (va_op_reg_opr64_reg64 rR12)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 505 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pshufb (va_op_xmm_xmm 11) (va_op_xmm_xmm 9)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 506 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks128 alg in128_b out128_b key round_keys keys_b hkeys_b h_LE) (fun
(va_s:va_state) _ -> let (y_cipher128:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in let (va_arg134:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b in let
(va_arg133:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg132:Vale.Def.Types_s.quad32) = y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 508 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_ghash_incremental0_append h_LE va_arg132 y_cipher128x6
y_cipher128 va_arg133 va_arg134) (let auth_in = FStar.Seq.Base.append #quad32 auth_in
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 512 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Stack_lemma (va_op_reg64_reg64 rRsp) (offset + 24) Public) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 512 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Add64 (va_op_dst_opr64_reg64 rR14) (va_opr_code_Stack (va_op_reg64_reg64 rRsp)
(offset + 24) Public)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 513 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_IMul64 (va_op_dst_opr64_reg64 rR14) (va_const_opr64 16)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 514 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rR13) (va_op_reg_opr64_reg64 rRsp) (offset + 64))
(fun (va_s:va_state) _ -> let (y_inout:Vale.Def.Types_s.quad32) = y_cipher128 in let
(plain_byte_seq:(seq quad32)) = empty_seq_quad32 in let (cipher_byte_seq:(seq quad32)) =
empty_seq_quad32 in let (va_arg131:Vale.Def.Types_s.quad32) = va_get_xmm 11 va_s in let
(va_arg130:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in let
(va_arg129:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = cipher_byte_seq in let
(va_arg128:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = plain_byte_seq in let
(va_arg127:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 519 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.gctr_partial_opaque_init va_arg127 va_arg128 va_arg129 va_arg130
va_arg131) (let (total_bytes:(va_int_at_least 0)) = FStar.Seq.Base.length #quad32 auth_quad_seq
`op_Multiply` 16 + plain_num_bytes in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 523 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_qIf va_mods (Cmp_gt (va_op_cmp_reg64 rR13) (va_op_cmp_reg64 rR14)) (qblock va_mods (fun
(va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 525 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 56))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 526 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR13)) (fun (va_s:va_state) _
-> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 527 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.Poly1305.Math.lemma_poly_bits64 ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 528 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 15)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 532 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes y_0 auth_in
h_LE) (fun (va_s:va_state) _ -> let y_inout = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm
8 va_s) in let (raw_auth_quads:(FStar.Seq.Base.seq quad32)) = FStar.Seq.Base.append #quad32
auth_in (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b) in va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 536 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun a_1906 (s_1907:(FStar.Seq.Base.seq a_1906)) (i_1908:Prims.nat) (j_1909:Prims.nat) -> let
(j_1869:Prims.nat) = j_1909 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1908
j_1869) (Prims.op_LessThanOrEqual j_1869 (FStar.Seq.Base.length #a_1906 s_1907))))
Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 total_bytes)
(fun _ -> let (auth_input_bytes:(FStar.Seq.Base.seq Vale.Def.Types_s.nat8)) =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
raw_auth_quads) 0 total_bytes in let (padded_auth_bytes:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in let auth_in =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes in let plain_byte_seq =
Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b in let cipher_byte_seq =
Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b in va_QEmpty ((auth_in,
cipher_byte_seq, plain_byte_seq, y_inout)))))))))) (qblock va_mods (fun (va_s:va_state) ->
va_QEmpty ((auth_in, cipher_byte_seq, plain_byte_seq, y_inout))))) (fun (va_s:va_state) va_g ->
let ((auth_in:(seq quad32)), (cipher_byte_seq:(seq quad32)), (plain_byte_seq:(seq quad32)),
(y_inout:Vale.Def.Types_s.quad32)) = va_g in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 547 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 548 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_make_length_quad ()) (fun (va_s:va_state) _ -> let
(length_quad32:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 0
va_s) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 551 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_register hkeys_b h_LE y_inout) (fun (va_s:va_state) _ -> let
(y_final:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s)
in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 554 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRbp) 0 Secret scratch_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 557 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gctr_register alg key round_keys keys_b) (fun (va_s:va_state) _ -> let
(va_arg126:Vale.Def.Types_s.quad32) = va_get_xmm 8 va_s in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 560 column 40 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.Arch.Types.le_seq_quad32_to_bytes_of_singleton va_arg126)
(va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 561 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun (icb_BE_677:Vale.Def.Types_s.quad32) (plain_LE_678:Vale.Def.Types_s.quad32)
(alg_679:Vale.AES.AES_common_s.algorithm) (key_680:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32))
(i_681:Prims.int) -> Vale.AES.AES_s.is_aes_key_LE alg_679 key_680) j0 y_final alg key 0) (fun _
-> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 561 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 8 va_s == Vale.AES.GCTR_s.gctr_encrypt_block j0 y_final alg key 0) (let
(plain128:(FStar.Seq.Base.seq Vale.X64.Decls.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in let
(cipher128:(FStar.Seq.Base.seq Vale.X64.Decls.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) in128_b) in va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 566 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.length #quad32 plain_byte_seq == 0 ==> FStar.Seq.Base.equal
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 plain128 plain_byte_seq)
plain128) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 567 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.length #quad32 cipher_byte_seq == 0 ==> FStar.Seq.Base.equal
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 cipher128 cipher_byte_seq)
cipher128) (let (va_arg125:Vale.Def.Types_s.quad32) = Vale.AES.GCTR.inc32lite ctr_BE_2 len128x6
in let (va_arg124:Vale.Def.Types_s.quad32) = ctr_BE_2 in let (va_arg123:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) = key in let (va_arg122:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32))
= Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b in let
(va_arg121:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) in128_b in let (va_arg120:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) out128x6_b in let
(va_arg119:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_old_s) in128x6_b in let (va_arg118:Prims.nat) = len128 in let
(va_arg117:Prims.nat) = len128x6 in let (va_arg116:Vale.AES.AES_common_s.algorithm) = alg in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 569 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.lemma_gctr_partial_append va_arg116 va_arg117 va_arg118
va_arg119 va_arg120 va_arg121 va_arg122 va_arg123 va_arg124 va_arg125) (let
(va_arg115:Vale.Def.Types_s.quad32) = Vale.AES.GCTR.inc32lite (Vale.AES.GCTR.inc32lite ctr_BE_2
len128x6) len128 in let (va_arg114:Vale.Def.Types_s.quad32) = ctr_BE_2 in let
(va_arg113:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in let
(va_arg112:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = cipher_byte_seq in let
(va_arg111:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = plain_byte_seq in let
(va_arg110:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b) in let
(va_arg109:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in let (va_arg108:Prims.nat) =
FStar.Seq.Base.length #quad32 plain_byte_seq in let (va_arg107:Prims.nat) = len128x6 + len128
in let (va_arg106:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 575 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.lemma_gctr_partial_append va_arg106 va_arg107 va_arg108
va_arg109 va_arg110 va_arg111 va_arg112 va_arg113 va_arg114 va_arg115) (let
(va_arg105:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg104:Vale.Def.Types_s.quad32) = y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 583 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_hash_append2 h_LE va_arg104 y_inout y_final va_arg105
length_quad32) (let auth_in = FStar.Seq.Base.append #quad32 auth_in (FStar.Seq.Base.create
#Vale.Def.Types_s.quad32 1 length_quad32) in let (va_arg103:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = auth_in in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 585 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.ghash_incremental_to_ghash h_LE va_arg103) (va_QEmpty
(()))))))))))))))))))))))))))))))))))))))))))))))))
val va_lemma_Gcm_blocks : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> offset:int ->
auth_b:buffer128 -> abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 ->
in128_b:buffer128 -> out128_b:buffer128 -> inout_b:buffer128 -> iv_b:buffer128 ->
scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks alg offset) va_s0 /\ va_get_ok va_s0 /\
(let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in sse_enabled /\ movbe_enabled /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp
va_s0 + offset + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet
1 va_s0) (va_get_reg64 rRdi va_s0) auth_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2
va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6
va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) in128_ptr in128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1
va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) inout_ptr inout_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0) hkeys_b 8
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet
1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b
(va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer128
scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) /\
Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32
/\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let
(ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in let
(plain_in:(seq quad32)) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) then FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) else FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in let (cipher_out:(seq quad32)) = (if (plain_num_bytes
> (len128x6 + len128) `op_Multiply` 128 `op_Division` 8) then FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) else
FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM)
out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b)) in let
(cipher_bound:nat) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128 `op_Division`
8) then (len128x6 + len128 + 1) else (len128x6 + len128)) in Vale.AES.GCTR.gctr_partial alg
cipher_bound plain_in cipher_out key ctr_BE_2 /\ (let (length_quad:quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) (8
`op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply` plain_num_bytes) 0) in let
(raw_auth_quads:(seq quad32)) = (if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) then FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b) else Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0)
auth_b) in let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64 rRsi va_s0) in let
(padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in let
(auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes in let
(raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 (FStar.Seq.Base.append #quad32
auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in let (total_bytes:nat) =
FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 + plain_num_bytes in let
(raw_quad_seq:(seq quad32)) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) then (let (ab:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32 raw_quad_seq
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let (pb:(seq
nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32 pb) else
raw_quad_seq) in let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 raw_quad_seq
(FStar.Seq.Base.create #quad32 1 length_quad) in va_get_xmm 8 va_sM ==
Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE h_LE auth_quad_seq) alg
key 0))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM
(va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm
13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm
9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM
(va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM
(va_update_reg64 rRbp va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0)))))))))))))))))))))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_blocks va_b0 va_s0 alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5;
va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14;
va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12;
va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp;
va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx;
va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks va_mods alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks alg offset) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 283 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
let (h_LE:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.X64.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 0 va_s0)) in label va_range1
"***** POSTCONDITION NOT MET AT line 396 column 56 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 397 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 398 column 57 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 399 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 400 column 58 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet
6 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 403 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(plain_num_bytes < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 404 column 38 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRsi va_s0 < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 406 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 408 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (ctr_BE_1:quad32) = iv_BE in label va_range1
"***** POSTCONDITION NOT MET AT line 409 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in label va_range1
"***** POSTCONDITION NOT MET AT line 412 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (plain_in:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in label va_range1
"***** POSTCONDITION NOT MET AT line 421 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (cipher_out:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_sM) out128_b)) in label va_range1
"***** POSTCONDITION NOT MET AT line 430 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (cipher_bound:nat) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> len128x6 + len128 + 1) (fun _ -> len128x6 + len128) in label
va_range1
"***** POSTCONDITION NOT MET AT line 434 column 77 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg cipher_bound plain_in cipher_out key ctr_BE_2) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 438 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (length_quad:quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 0 0 0 0) (8 `op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply`
plain_num_bytes) 0) in label va_range1
"***** POSTCONDITION NOT MET AT line 440 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_auth_quads:(seq quad32)) = va_if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b)) (fun _ -> Vale.X64.Decls.s128 (va_get_mem_heaplet 1
va_s0) auth_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 444 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64 rRsi va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 445 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in label
va_range1
"***** POSTCONDITION NOT MET AT line 446 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes
in label va_range1
"***** POSTCONDITION NOT MET AT line 448 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 (FStar.Seq.Base.append #quad32
auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 452 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (total_bytes:nat) = FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 +
plain_num_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 453 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_quad_seq:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply`
128 `op_Division` 8) (fun _ -> let (ab:(seq nat8)) = FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32
raw_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let
(pb:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32
pb) (fun _ -> raw_quad_seq) in label va_range1
"***** POSTCONDITION NOT MET AT line 460 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 raw_quad_seq
(FStar.Seq.Base.create #quad32 1 length_quad) in label va_range1
"***** POSTCONDITION NOT MET AT line 461 column 106 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 8 va_sM == Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE
h_LE auth_quad_seq) alg key 0)))))))))))))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_blocks (alg:algorithm) (offset:int) (auth_b:buffer128) (abytes_b:buffer128)
(in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128) (out128_b:buffer128)
(inout_b:buffer128) (iv_b:buffer128) (scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
let (h_LE:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.X64.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 0 va_s0)) in sse_enabled /\
movbe_enabled /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0)
(va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet
1 va_s0) (va_get_reg64 rRdi va_s0) auth_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2
va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6
va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) in128_ptr in128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1
va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) inout_ptr inout_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0) hkeys_b 8
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)))) /\ (forall (va_x_mem:vale_heap)
(va_x_rax:nat64) (va_x_rbx:nat64) (va_x_rcx:nat64) (va_x_rdx:nat64) (va_x_rdi:nat64)
(va_x_rsi:nat64) (va_x_rbp:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64)
(va_x_r11:nat64) (va_x_r12:nat64) (va_x_r13:nat64) (va_x_r14:nat64) (va_x_r15:nat64)
(va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32)
(va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm9:quad32)
(va_x_xmm10:quad32) (va_x_xmm11:quad32) (va_x_xmm12:quad32) (va_x_xmm13:quad32)
(va_x_xmm14:quad32) (va_x_xmm15:quad32) (va_x_heap1:vale_heap) (va_x_heap2:vale_heap)
(va_x_heap3:vale_heap) (va_x_heap5:vale_heap) (va_x_heap6:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 6
va_x_heap6 (va_upd_mem_heaplet 5 va_x_heap5 (va_upd_mem_heaplet 3 va_x_heap3
(va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 15 va_x_xmm15
(va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12 (va_upd_xmm 11
va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (va_upd_xmm 8 va_x_xmm8
(va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4
(va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0
(va_upd_reg64 rR15 va_x_r15 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13
(va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10
(va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRbp va_x_rbp (va_upd_reg64
rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRcx
va_x_rcx (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem
va_s0))))))))))))))))))))))))))))))))))))) in va_get_ok va_sM /\ (let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet
1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b
(va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer128
scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) /\
Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32
/\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let
(ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in let
(plain_in:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in let (cipher_out:(seq quad32)) = va_if
(plain_num_bytes > (len128x6 + len128) `op_Multiply` 128 `op_Division` 8) (fun _ ->
FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_sM) out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM)
inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) in let (cipher_bound:nat) = va_if (plain_num_bytes > (len128x6 + len128)
`op_Multiply` 128 `op_Division` 8) (fun _ -> len128x6 + len128 + 1) (fun _ -> len128x6 +
len128) in Vale.AES.GCTR.gctr_partial alg cipher_bound plain_in cipher_out key ctr_BE_2 /\ (let
(length_quad:quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) (8
`op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply` plain_num_bytes) 0) in let
(raw_auth_quads:(seq quad32)) = va_if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b)) (fun _ -> Vale.X64.Decls.s128 (va_get_mem_heaplet 1
va_s0) auth_b) in let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64
rRsi va_s0) in let (padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits
auth_input_bytes in let (auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32
padded_auth_bytes in let (raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32
(FStar.Seq.Base.append #quad32 auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0)
in128x6_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in let (total_bytes:nat)
= FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 + plain_num_bytes in let
(raw_quad_seq:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> let (ab:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32 raw_quad_seq
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let (pb:(seq
nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32 pb) (fun
_ -> raw_quad_seq) in let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32
raw_quad_seq (FStar.Seq.Base.create #quad32 1 length_quad) in va_get_xmm 8 va_sM ==
Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE h_LE auth_quad_seq) alg
key 0))) ==> va_k va_sM (())))
val va_wpProof_Gcm_blocks : alg:algorithm -> offset:int -> auth_b:buffer128 -> abytes_b:buffer128
-> in128x6_b:buffer128 -> out128x6_b:buffer128 -> in128_b:buffer128 -> out128_b:buffer128 ->
inout_b:buffer128 -> iv_b:buffer128 -> scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq
quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit ->
Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b
in128_b out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks alg offset) ([va_Mod_flags;
va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2;
va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm
11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5;
va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15;
va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10;
va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi;
va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) va_s0
va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b
iv_b scratch_b key round_keys keys_b hkeys_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_blocks (va_code_Gcm_blocks alg offset) va_s0 alg offset auth_b
abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b scratch_b key round_keys keys_b
hkeys_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM
(va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm
13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm
9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM
(va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM
(va_update_reg64 rRbp va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))))))))))))))))))))))))))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_blocks (alg:algorithm) (offset:int) (auth_b:buffer128) (abytes_b:buffer128)
(in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128) (out128_b:buffer128)
(inout_b:buffer128) (iv_b:buffer128) (scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit (va_code_Gcm_blocks alg
offset)) =
(va_QProc (va_code_Gcm_blocks alg offset) ([va_Mod_flags; va_Mod_mem_heaplet 6;
va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1;
va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10;
va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm
3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64
rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64
rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64
rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_Gcm_blocks alg offset auth_b
abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b scratch_b key round_keys keys_b
hkeys_b) (va_wpProof_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b))
#pop-options
//--
//-- Gcm_blocks_wrapped
#push-options "--z3rlimit 60"
val va_code_Gcm_blocks_wrapped : alg:algorithm -> offset:int -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks_wrapped alg offset =
(va_Block (va_CCons (va_code_Gcm_blocks alg offset) (va_CCons (va_Block (va_CNil ())) (va_CCons
(va_Block (va_CNil ())) (va_CNil ())))))
val va_codegen_success_Gcm_blocks_wrapped : alg:algorithm -> offset:int -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks_wrapped alg offset =
(va_pbool_and (va_codegen_success_Gcm_blocks alg offset) (va_ttrue ()))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks_wrapped (va_mods:va_mods_t) (alg:algorithm) (offset:int) (auth_b:buffer128)
(abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128)
(out128_b:buffer128) (inout_b:buffer128) (iv_b:buffer128) (iv:supported_iv_LE)
(scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128)
(hkeys_b:buffer128) (expected_tag:(seq nat8)) : (va_quickCode unit (va_code_Gcm_blocks_wrapped
alg offset)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 0) (va_get_stack va_s) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 8) (va_get_stack va_s) in let
(out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 16) (va_get_stack va_s) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 24) (va_get_stack va_s) in let
(in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 32) (va_get_stack va_s) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 40) (va_get_stack va_s) in let
(len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset
+ 48) (va_get_stack va_s) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 56) (va_get_stack va_s) in let
(plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s
+ offset + 64) (va_get_stack va_s) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 739 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b
iv_b scratch_b key round_keys keys_b hkeys_b) (fun (va_s:va_state) _ -> va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 741 column 37 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(8 `op_Multiply` va_get_reg64 rRsi va_old_s >= 0 /\ 8 `op_Multiply` va_get_reg64 rRsi va_old_s
<= 18446744073709551615 /\ 8 `op_Multiply` plain_num_bytes >= 0 /\ 8 `op_Multiply`
plain_num_bytes <= 18446744073709551615) (fun _ -> let (va_arg55:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) (8
`op_Multiply` va_get_reg64 rRsi va_old_s) 1) (8 `op_Multiply` plain_num_bytes) 0) in let
(va_arg54:Vale.Def.Types_s.quad32) = va_get_xmm 8 va_s in let
(va_arg53:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.X64.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 0 va_s)) in let
(va_arg52:Vale.Def.Types_s.quad32) = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2
va_old_s) in let (va_arg51:Vale.AES.GCM_s.supported_iv_LE) = iv in let (va_arg50:Prims.nat) =
va_get_reg64 rRsi va_old_s in let (va_arg49:Prims.nat) = plain_num_bytes in let
(va_arg48:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s) inout_b in let (va_arg47:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b in let
(va_arg46:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s) out128x6_b in let (va_arg45:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b in let
(va_arg44:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) in128_b in let (va_arg43:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b in
let (va_arg42:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_old_s) abytes_b in let (va_arg41:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) auth_b in let
(va_arg40:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = key in let
(va_arg39:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 741 column 37 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCM.gcm_blocks_dec_helper_simplified va_arg39 va_arg40 va_arg41
va_arg42 va_arg43 va_arg44 va_arg45 va_arg46 va_arg47 va_arg48 va_arg49 va_arg50 va_arg51
va_arg52 va_arg53 va_arg54 va_arg55) (let (auth_raw_quads:(FStar.Seq.Base.seq
Vale.X64.Decls.quad32)) = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) auth_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_old_s)
abytes_b) in va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 751 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun a_1906 (s_1907:(FStar.Seq.Base.seq a_1906)) (i_1908:Prims.nat) (j_1909:Prims.nat) -> let
(j_1869:Prims.nat) = j_1909 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1908
j_1869) (Prims.op_LessThanOrEqual j_1869 (FStar.Seq.Base.length #a_1906 s_1907))))
Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0 (va_get_reg64
rRsi va_old_s)) (fun _ -> let (auth_bytes:(FStar.Seq.Base.seq Vale.Def.Types_s.nat8)) =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
auth_raw_quads) 0 (va_get_reg64 rRsi va_old_s) in let (va_arg38:Vale.Def.Types_s.quad32) =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_old_s) in let
(va_arg37:Vale.AES.GCM_s.supported_iv_LE) = iv in let (va_arg36:Prims.nat) = plain_num_bytes in
let (va_arg35:(FStar.Seq.Base.seq Vale.Def.Words_s.nat8)) = expected_tag in let
(va_arg34:(FStar.Seq.Base.seq Vale.Def.Words_s.nat8)) = auth_bytes in let
(va_arg33:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s) inout_b in let (va_arg32:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b in let
(va_arg31:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s) out128x6_b in let (va_arg30:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b in let
(va_arg29:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) in128_b in let (va_arg28:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b in
let (va_arg27:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = key in let
(va_arg26:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 752 column 37 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCM.gcm_blocks_helper_dec_simplified va_arg26 va_arg27 va_arg28
va_arg29 va_arg30 va_arg31 va_arg32 va_arg33 va_arg34 va_arg35 va_arg36 va_arg37 va_arg38)
(va_QEmpty (()))))))))
val va_lemma_Gcm_blocks_wrapped : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> offset:int ->
auth_b:buffer128 -> abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 ->
in128_b:buffer128 -> out128_b:buffer128 -> inout_b:buffer128 -> iv_b:buffer128 ->
iv:supported_iv_LE -> scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) ->
keys_b:buffer128 -> hkeys_b:buffer128 -> expected_tag:(seq nat8)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks_wrapped alg offset) va_s0 /\ va_get_ok
va_s0 /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in sse_enabled /\ movbe_enabled /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp
va_s0 + offset + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet
1 va_s0) (va_get_reg64 rRdi va_s0) auth_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2
va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6
va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) in128_ptr in128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1
va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) inout_ptr inout_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0) hkeys_b 8
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\ (let iv_BE =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let h_LE =
Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
in iv_BE == Vale.AES.GCM_s.compute_iv_BE h_LE iv))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in Vale.X64.Decls.modifies_buffer128 out128_b
(va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128
iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\
Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM) /\ Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0)
(va_get_mem_heaplet 5 va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b
(va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\
va_get_reg64 rRsi va_s0 < pow2_32 /\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0
(va_get_mem_heaplet 2 va_s0) in let auth_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_s0) abytes_b) in let auth_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
auth_raw_quads) 0 (va_get_reg64 rRsi va_s0) in let plain_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0)
in128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) in let plain_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
plain_raw_quads) 0 plain_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) in let cipher_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
cipher_raw_quads) 0 plain_num_bytes in l_and (l_and (l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.nat8 auth_bytes < pow2_32) (FStar.Seq.Base.length #Vale.Def.Types_s.nat8
plain_bytes < pow2_32)) (cipher_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq
Vale.Def.Types_s.nat8) #bool (Vale.AES.GCM_s.gcm_decrypt_LE alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes expected_tag)))
(Vale.Def.Types_s.le_quad32_to_bytes (va_get_xmm 8 va_sM) == Vale.AES.GCM.gcm_decrypt_LE_tag
alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM (va_update_mem_heaplet
5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 1
va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12
va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm 9 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM
(va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM
(va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRbp va_sM
(va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRdx va_sM
(va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_blocks_wrapped va_b0 va_s0 alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b expected_tag =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5;
va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14;
va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12;
va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp;
va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx;
va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks_wrapped va_mods alg offset auth_b abytes_b in128x6_b out128x6_b
in128_b out128_b inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b expected_tag in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks_wrapped alg offset) va_qc
va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 588 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 711 column 56 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 712 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 713 column 57 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 714 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 715 column 58 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet
6 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 718 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(plain_num_bytes < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 719 column 38 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRsi va_s0 < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 721 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 723 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let auth_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_s0)
abytes_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 724 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let auth_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0 (va_get_reg64 rRsi va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 725 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let plain_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 726 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let plain_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads) 0 plain_num_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 727 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let cipher_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 728 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let cipher_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads) 0 plain_num_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 737 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(l_and (l_and (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 auth_bytes < pow2_32)
(FStar.Seq.Base.length #Vale.Def.Types_s.nat8 plain_bytes < pow2_32)) (cipher_bytes ==
__proj__Mktuple2__item___1 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv
plain_bytes auth_bytes expected_tag))) (Vale.Def.Types_s.le_quad32_to_bytes (va_get_xmm 8
va_sM) == Vale.AES.GCM.gcm_decrypt_LE_tag alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE
key) iv plain_bytes auth_bytes))))))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_blocks_wrapped (alg:algorithm) (offset:int) (auth_b:buffer128) (abytes_b:buffer128)
(in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128) (out128_b:buffer128)
(inout_b:buffer128) (iv_b:buffer128) (iv:supported_iv_LE) (scratch_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (expected_tag:(seq nat8))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
sse_enabled /\ movbe_enabled /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 +
offset + 0) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 32) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 48) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 64) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) auth_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0) (va_get_reg64 rR8 va_s0) iv_b 1
(va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6
va_s0) in128x6_ptr in128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6 va_s0) out128x6_ptr out128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1
va_s0) in128_ptr in128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) out128_ptr out128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5
va_s0) inout_ptr inout_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128
(va_get_mem_heaplet 3 va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0)
hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\ (let iv_BE =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let h_LE =
Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
in iv_BE == Vale.AES.GCM_s.compute_iv_BE h_LE iv)) /\ (forall (va_x_mem:vale_heap)
(va_x_rax:nat64) (va_x_rbx:nat64) (va_x_rcx:nat64) (va_x_rdx:nat64) (va_x_rdi:nat64)
(va_x_rsi:nat64) (va_x_rbp:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64)
(va_x_r11:nat64) (va_x_r12:nat64) (va_x_r13:nat64) (va_x_r14:nat64) (va_x_r15:nat64)
(va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32)
(va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm9:quad32)
(va_x_xmm10:quad32) (va_x_xmm11:quad32) (va_x_xmm12:quad32) (va_x_xmm13:quad32)
(va_x_xmm14:quad32) (va_x_xmm15:quad32) (va_x_heap1:vale_heap) (va_x_heap2:vale_heap)
(va_x_heap3:vale_heap) (va_x_heap5:vale_heap) (va_x_heap6:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 6
va_x_heap6 (va_upd_mem_heaplet 5 va_x_heap5 (va_upd_mem_heaplet 3 va_x_heap3
(va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 15 va_x_xmm15
(va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12 (va_upd_xmm 11
va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (va_upd_xmm 8 va_x_xmm8
(va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4
(va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0
(va_upd_reg64 rR15 va_x_r15 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13
(va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10
(va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRbp va_x_rbp (va_upd_reg64
rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRcx
va_x_rcx (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem
va_s0))))))))))))))))))))))))))))))))))))) in va_get_ok va_sM /\ (let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in Vale.X64.Decls.modifies_buffer128 out128_b
(va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128
iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\
Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM) /\ Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0)
(va_get_mem_heaplet 5 va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b
(va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\
va_get_reg64 rRsi va_s0 < pow2_32 /\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0
(va_get_mem_heaplet 2 va_s0) in let auth_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_s0) abytes_b) in let auth_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
auth_raw_quads) 0 (va_get_reg64 rRsi va_s0) in let plain_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0)
in128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) in let plain_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
plain_raw_quads) 0 plain_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) in let cipher_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
cipher_raw_quads) 0 plain_num_bytes in l_and (l_and (l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.nat8 auth_bytes < pow2_32) (FStar.Seq.Base.length #Vale.Def.Types_s.nat8
plain_bytes < pow2_32)) (cipher_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq
Vale.Def.Types_s.nat8) #bool (Vale.AES.GCM_s.gcm_decrypt_LE alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes expected_tag)))
(Vale.Def.Types_s.le_quad32_to_bytes (va_get_xmm 8 va_sM) == Vale.AES.GCM.gcm_decrypt_LE_tag
alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) ==> va_k
va_sM (())))
val va_wpProof_Gcm_blocks_wrapped : alg:algorithm -> offset:int -> auth_b:buffer128 ->
abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 -> in128_b:buffer128 ->
out128_b:buffer128 -> inout_b:buffer128 -> iv_b:buffer128 -> iv:supported_iv_LE ->
scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> expected_tag:(seq nat8) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gcm_blocks_wrapped alg offset auth_b abytes_b in128x6_b
out128x6_b in128_b out128_b inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b
expected_tag va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks_wrapped alg offset)
([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3;
va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Stack.fsti.checked",
"Vale.X64.QuickCodes.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.InsVector.fsti.checked",
"Vale.X64.InsStack.fsti.checked",
"Vale.X64.InsMem.fsti.checked",
"Vale.X64.InsBasic.fsti.checked",
"Vale.X64.InsAes.fsti.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Lib.Meta.fsti.checked",
"Vale.Lib.Basic.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_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",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.X64.GHash.fsti.checked",
"Vale.AES.X64.GF128_Mul.fsti.checked",
"Vale.AES.X64.GCTR.fsti.checked",
"Vale.AES.X64.GCMencryptOpt.fsti.checked",
"Vale.AES.X64.AESopt2.fsti.checked",
"Vale.AES.X64.AESopt.fsti.checked",
"Vale.AES.X64.AESGCM.fsti.checked",
"Vale.AES.X64.AES.fsti.checked",
"Vale.AES.OptPublic.fsti.checked",
"Vale.AES.GHash_s.fst.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_s.fst.checked",
"Vale.AES.GCTR.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"Vale.AES.GCM.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_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.X64.GCMdecryptOpt.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Lib.Basic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"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.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_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": "Vale.Def.Types_s",
"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": "FStar.Seq",
"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.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"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.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_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": "Vale.Def.Types_s",
"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": "FStar.Seq",
"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.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 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": 60,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
alg: Vale.AES.AES_common_s.algorithm ->
offset: Prims.int ->
auth_b: Vale.X64.Memory.buffer128 ->
abytes_b: Vale.X64.Memory.buffer128 ->
in128x6_b: Vale.X64.Memory.buffer128 ->
out128x6_b: Vale.X64.Memory.buffer128 ->
in128_b: Vale.X64.Memory.buffer128 ->
out128_b: Vale.X64.Memory.buffer128 ->
inout_b: Vale.X64.Memory.buffer128 ->
iv_b: Vale.X64.Memory.buffer128 ->
iv: Vale.AES.GCM_s.supported_iv_LE ->
scratch_b: Vale.X64.Memory.buffer128 ->
key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 ->
round_keys: FStar.Seq.Base.seq Vale.X64.Decls.quad32 ->
keys_b: Vale.X64.Memory.buffer128 ->
hkeys_b: Vale.X64.Memory.buffer128 ->
expected_tag: FStar.Seq.Base.seq Vale.X64.Memory.nat8 ->
va_s0: Vale.X64.Decls.va_state ->
va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit) | Prims.Ghost | [] | [] | [
"Vale.AES.AES_common_s.algorithm",
"Prims.int",
"Vale.X64.Memory.buffer128",
"Vale.AES.GCM_s.supported_iv_LE",
"FStar.Seq.Base.seq",
"Vale.X64.Memory.nat32",
"Vale.X64.Decls.quad32",
"Vale.X64.Memory.nat8",
"Vale.X64.Decls.va_state",
"Prims.unit",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple3",
"Vale.X64.QuickCode.va_lemma_norm_mods",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_Mod_flags",
"Vale.X64.QuickCode.va_Mod_mem_heaplet",
"Vale.X64.QuickCode.va_Mod_xmm",
"Vale.X64.QuickCode.va_Mod_reg64",
"Vale.X64.Machine_s.rR15",
"Vale.X64.Machine_s.rR14",
"Vale.X64.Machine_s.rR13",
"Vale.X64.Machine_s.rR12",
"Vale.X64.Machine_s.rR11",
"Vale.X64.Machine_s.rR10",
"Vale.X64.Machine_s.rR9",
"Vale.X64.Machine_s.rR8",
"Vale.X64.Machine_s.rRbp",
"Vale.X64.Machine_s.rRsi",
"Vale.X64.Machine_s.rRdi",
"Vale.X64.Machine_s.rRdx",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.Machine_s.rRax",
"Vale.X64.QuickCode.va_Mod_mem",
"Prims.Nil",
"Prims._assert",
"Vale.X64.Decls.va_state_eq",
"Vale.X64.Decls.va_update_flags",
"Vale.X64.Decls.va_update_mem_heaplet",
"Vale.X64.Decls.va_update_xmm",
"Vale.X64.Decls.va_update_reg64",
"Vale.X64.Decls.va_update_ok",
"Vale.X64.Decls.va_update_mem",
"Vale.X64.Decls.va_lemma_upd_update",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.State.vale_state",
"Vale.AES.X64.GCMdecryptOpt.va_lemma_Gcm_blocks_wrapped",
"Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_blocks_wrapped"
] | [] | false | false | false | false | false | let va_wpProof_Gcm_blocks_wrapped
alg
offset
auth_b
abytes_b
in128x6_b
out128x6_b
in128_b
out128_b
inout_b
iv_b
iv
scratch_b
key
round_keys
keys_b
hkeys_b
expected_tag
va_s0
va_k
=
| let va_sM, va_f0 =
va_lemma_Gcm_blocks_wrapped (va_code_Gcm_blocks_wrapped alg offset) va_s0 alg offset auth_b
abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b iv scratch_b key round_keys keys_b
hkeys_b expected_tag
in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM
(va_update_flags va_sM
(va_update_mem_heaplet 6
va_sM
(va_update_mem_heaplet 5
va_sM
(va_update_mem_heaplet 3
va_sM
(va_update_mem_heaplet 2
va_sM
(va_update_mem_heaplet 1
va_sM
(va_update_xmm 15
va_sM
(va_update_xmm 14
va_sM
(va_update_xmm 13
va_sM
(va_update_xmm 12
va_sM
(va_update_xmm 11
va_sM
(va_update_xmm 10
va_sM
(va_update_xmm 9
va_sM
(va_update_xmm 8
va_sM
(va_update_xmm 7
va_sM
(va_update_xmm 6
va_sM
(va_update_xmm 5
va_sM
(va_update_xmm 4
va_sM
(va_update_xmm 3
va_sM
(va_update_xmm 2
va_sM
(va_update_xmm
1
va_sM
(va_update_xmm
0
va_sM
(va_update_reg64
rR15
va_sM
(va_update_reg64
rR14
va_sM
(
va_update_reg64
rR13
va_sM
(
va_update_reg64
rR12
va_sM
(
va_update_reg64
rR11
va_sM
(
va_update_reg64
rR10
va_sM
(
va_update_reg64
rR9
va_sM
(
va_update_reg64
rR8
va_sM
(
va_update_reg64
rRbp
va_sM
(
va_update_reg64
rRsi
va_sM
(
va_update_reg64
rRdi
va_sM
(
va_update_reg64
rRdx
va_sM
(
va_update_reg64
rRcx
va_sM
(
va_update_reg64
rRbx
va_sM
(
va_update_reg64
rRax
va_sM
(
va_update_ok
va_sM
(
va_update_mem
va_sM
va_s0
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
))
))))))))))
)))))))))))));
va_lemma_norm_mods ([
va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3;
va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12;
va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp;
va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx;
va_Mod_reg64 rRax; va_Mod_mem
])
va_sM
va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | false |
LowStar.Lib.LinkedList.fst | LowStar.Lib.LinkedList.frame | val frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem)
: Lemma
(requires
(well_formed h0 l n /\ invariant h0 l n /\ B.loc_disjoint r (footprint h0 l n) /\
B.modifies r h0 h1))
(ensures
(well_formed h1 l n /\ footprint h1 l n == footprint h0 l n /\ cells h1 l n == cells h0 l n /\
invariant h1 l n))
(decreases n)
[SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1)] | val frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem)
: Lemma
(requires
(well_formed h0 l n /\ invariant h0 l n /\ B.loc_disjoint r (footprint h0 l n) /\
B.modifies r h0 h1))
(ensures
(well_formed h1 l n /\ footprint h1 l n == footprint h0 l n /\ cells h1 l n == cells h0 l n /\
invariant h1 l n))
(decreases n)
[SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1)] | let rec frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem): Lemma
(requires (
well_formed h0 l n /\
invariant h0 l n /\
B.loc_disjoint r (footprint h0 l n) /\
B.modifies r h0 h1
))
(ensures (
well_formed h1 l n /\
footprint h1 l n == footprint h0 l n /\
cells h1 l n == cells h0 l n /\
invariant h1 l n
))
(decreases n)
[ SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1) ]
=
if B.g_is_null l then
()
else
frame (B.deref h0 l).next (L.tl n) r h0 h1 | {
"file_name": "krmllib/LowStar.Lib.LinkedList.fst",
"git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} | {
"end_col": 46,
"end_line": 218,
"start_col": 0,
"start_line": 199
} | module LowStar.Lib.LinkedList
/// This module, oftentimes referred to as LL1 in other parts of the
/// documentation, provides a low-level view over a linked list. Unless you
/// intend on modifying the structure of the linked list (e.g. removing cells)
/// or iterating over each cell, your are probably better off using LL2.
///
/// This module is intentionally not relying on a tight abstraction, to i) permit
/// direct-style iteration by clients and ii) allow stating some SMTPat lemmas
/// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can
/// happen automatically at the SMT level since LL2 does not have an fsti either).
///
/// Some open questions relative to the design of this module:
/// - should ``v`` be defined directly in terms of ``cells`` rather than have a
/// recursive definition along with an equivalence lemma?
/// - should ``footprint`` be defined directly in terms of ``cells`` rather than
/// have a recursive definition along with an equivalence lemma?
/// - is it worth the trouble defining a footprint? my intuition is that it's
/// fine and allows some clients to do very precise reasoning -- other modules
/// (e.g. AssocList), when establishing abstraction boundaries, can simplify
/// things and get rid of the precise footprint reasoning in favor of a static
/// region-based footprint
///
/// Some remaining work items:
/// - switch to C.Loops.while
open LowStar.BufferOps
module B = LowStar.Buffer
module HS = FStar.HyperStack
module G = FStar.Ghost
module L = FStar.List.Tot
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
open FStar.HyperStack.ST
/// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since
/// everything does recursive list reasoning.
#set-options "--__no_positivity --fuel 1 --ifuel 1"
/// Definition of the Low* type
/// ---------------------------
noeq
type t (a: Type0) =
B.pointer_or_null (cell a)
and cell (a: Type0) = {
next: t a;
data: a;
}
/// Unlike the canonical style that associates a ``v`` function to any stateful
/// representation, we use a relation here. Writing a function is just
/// impossible, since we can't prove termination of ``v`` owing to the fact that
/// there may be an infinite number of cells in the heap.
///
/// LL2 is the module that switches to the function style.
///
/// Note: no need to use erased here for ``l`` since the function is already in ``GTot``.
let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) =
B.live h c /\ (
match l with
| [] ->
B.g_is_null c
| a :: q ->
B.length c == 1 /\ (
let { data=data; next=next } = B.get h c 0 in
a == data /\
well_formed h next (G.hide q)
))
/// Precise reasoning via the cells predicate
/// -----------------------------------------
///
/// The modifies clauses are given either on the footprint of the list, or on a
/// region that includes the footprint of the list (higher up the stack, e.g.
/// LL2). This is good, but does not rule out "stupid" implementations that
/// might re-allocate every single list cell when, say, doing a pop.
///
/// For advanced usages which take pointers directly to individual list cells,
/// it's important to rule out these cases. We thus define the ``cells``
/// predicate for that purpose.
let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a)))
(requires well_formed h c l)
(ensures fun _ -> True)
(decreases l)
=
if B.g_is_null c then
[]
else
c :: cells h (B.deref h c).next (List.Tot.tl l)
/// A missing bit of automated reasoning
/// ------------------------------------
/// This should be absolutely trivial, yet, because there's no pattern on
/// null_unique, we have to do the case analysis and the decomposition
/// ourselves. This is quite tedious, as it usually takes a while (at least it
/// did for me!) to realize that this property does not hold automatically.
///
/// I'm setting an SMTPat on this lemma because it's absolutely impossible to
/// get any work done without it.
let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma
(requires (
well_formed h0 ll0 l0 /\
well_formed h1 ll1 l1 /\
cells h0 ll0 l0 == cells h1 ll1 l1))
(ensures (
ll0 == ll1))
[ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ]
=
if B.g_is_null ll0 && B.g_is_null ll1 then begin
B.null_unique ll0;
B.null_unique ll1
end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin
()
end else
false_elim ()
/// Classic stateful reasoning lemmas
/// ---------------------------------
///
/// This essentially follows ``stateful``, the type class of a mutable piece of
/// state defined using the modifies-theory of Low*v2 and equipped with the
/// right lemmas to enable usage by clients. See
/// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context.
val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc
(requires (well_formed h l n))
(ensures (fun refs -> True))
(decreases n)
let rec footprint #a h l n =
if B.g_is_null l
then B.loc_none
else
let {next = next} = B.get h l 0 in
let refs = footprint h next (G.hide (L.tl n)) in
B.loc_union (B.loc_addr_of_buffer l) refs
/// Departing from LinkedList4 here. I prefer to bolt these into the invariant
/// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to
/// deduce these.
val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_pairwise_disjoint #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\
cells_pairwise_disjoint h next (L.tl n)
val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_live_freeable #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.live h l /\ B.freeable l /\
cells_live_freeable h next (L.tl n)
val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let invariant #a h l n =
cells_live_freeable h l n /\ cells_pairwise_disjoint h l n
/// Normally this would be automatic and writing a custom lemma for that stuff
/// would be needed only when writing an fsti, however, as stated earlier,
/// recursion makes everything more difficult and this absolutely needs to be in
/// scope otherwise the modifies-clause theory cannot deduce disjointness of
/// fresh allocations w.r.t. the footprint.
let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a): Lemma
(requires well_formed h l n)
(ensures B.loc_in (footprint h l n) h)
(decreases n)
[ SMTPat (invariant h l n) ]
=
if B.g_is_null l then
()
else
let next = (B.deref h l).next in
invariant_loc_in_footprint h next (L.tl n)
/// Another absolutely essential lemma, for which interestingly the pattern
/// "invariant h1 l n" does not work, but well_formed does... I guess that's | {
"checked_file": "/",
"dependencies": [
"TestLib.fsti.checked",
"prims.fst.checked",
"LowStar.Failure.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int32.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Lib.LinkedList.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
l: LowStar.Lib.LinkedList.t a ->
n: Prims.list a ->
r: LowStar.Monotonic.Buffer.loc ->
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem
-> FStar.Pervasives.Lemma
(requires
LowStar.Lib.LinkedList.well_formed h0 l n /\ LowStar.Lib.LinkedList.invariant h0 l n /\
LowStar.Monotonic.Buffer.loc_disjoint r (LowStar.Lib.LinkedList.footprint h0 l n) /\
LowStar.Monotonic.Buffer.modifies r h0 h1)
(ensures
LowStar.Lib.LinkedList.well_formed h1 l n /\
LowStar.Lib.LinkedList.footprint h1 l n == LowStar.Lib.LinkedList.footprint h0 l n /\
LowStar.Lib.LinkedList.cells h1 l n == LowStar.Lib.LinkedList.cells h0 l n /\
LowStar.Lib.LinkedList.invariant h1 l n)
(decreases n)
[
SMTPat (LowStar.Lib.LinkedList.well_formed h1 l n);
SMTPat (LowStar.Monotonic.Buffer.modifies r h0 h1)
] | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"LowStar.Lib.LinkedList.t",
"Prims.list",
"LowStar.Monotonic.Buffer.loc",
"FStar.Monotonic.HyperStack.mem",
"LowStar.Monotonic.Buffer.g_is_null",
"LowStar.Lib.LinkedList.cell",
"LowStar.Buffer.trivial_preorder",
"Prims.bool",
"LowStar.Lib.LinkedList.frame",
"LowStar.Lib.LinkedList.__proj__Mkcell__item__next",
"LowStar.Monotonic.Buffer.deref",
"FStar.List.Tot.Base.tl",
"Prims.unit",
"Prims.l_and",
"LowStar.Lib.LinkedList.well_formed",
"LowStar.Lib.LinkedList.invariant",
"LowStar.Monotonic.Buffer.loc_disjoint",
"LowStar.Lib.LinkedList.footprint",
"LowStar.Monotonic.Buffer.modifies",
"Prims.squash",
"Prims.eq2",
"LowStar.Buffer.pointer",
"LowStar.Lib.LinkedList.cells",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil"
] | [
"recursion"
] | false | false | true | false | false | let rec frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem)
: Lemma
(requires
(well_formed h0 l n /\ invariant h0 l n /\ B.loc_disjoint r (footprint h0 l n) /\
B.modifies r h0 h1))
(ensures
(well_formed h1 l n /\ footprint h1 l n == footprint h0 l n /\ cells h1 l n == cells h0 l n /\
invariant h1 l n))
(decreases n)
[SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1)] =
| if B.g_is_null l then () else frame (B.deref h0 l).next (L.tl n) r h0 h1 | false |
LowParse.SLow.FLData.fst | LowParse.SLow.FLData.size32_fldata_strong | val size32_fldata_strong
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(sz: nat)
(sz32: U32.t{U32.v sz32 == sz})
: Tot (size32 (serialize_fldata_strong s sz)) | val size32_fldata_strong
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(sz: nat)
(sz32: U32.t{U32.v sz32 == sz})
: Tot (size32 (serialize_fldata_strong s sz)) | let size32_fldata_strong
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(sz: nat)
(sz32: U32.t { U32.v sz32 == sz } )
: Tot (size32 (serialize_fldata_strong s sz))
= size32_constant (serialize_fldata_strong s sz) sz32 () | {
"file_name": "src/lowparse/LowParse.SLow.FLData.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 56,
"end_line": 73,
"start_col": 0,
"start_line": 65
} | module LowParse.SLow.FLData
include LowParse.Spec.FLData
include LowParse.SLow.Combinators
module B32 = LowParse.Bytes32
module U32 = FStar.UInt32
inline_for_extraction
let parse32_fldata
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(sz: nat)
(sz32: U32.t { U32.v sz32 == sz } )
: Tot (parser32 (parse_fldata p sz))
= (fun (input: bytes32) -> ((
if U32.lt (B32.len input) sz32
then
None
else
match p32 (B32.b32slice input 0ul sz32) with
| Some (v, consumed) ->
if consumed = sz32
then begin
Some (v, consumed)
end else None
| None -> None
) <: (res: option (t * U32.t) { parser32_correct (parse_fldata p sz) input res } )))
inline_for_extraction
let parse32_fldata_strong
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(p32: parser32 p)
(sz: nat)
(sz32: U32.t { U32.v sz32 == sz } )
: Tot (parser32 (parse_fldata_strong s sz))
= (fun (input: bytes32) -> ((
match parse32_fldata p32 sz sz32 input with
| Some (v, consumed) ->
assert (
parse_fldata_strong_correct s sz (B32.reveal input) (U32.v consumed) v;
Seq.length (s v) == sz
);
Some ((v <: parse_fldata_strong_t s sz), consumed)
| None -> None
)
<: (res: option (parse_fldata_strong_t s sz * U32.t) { parser32_correct (parse_fldata_strong s sz) input res } )))
inline_for_extraction
let serialize32_fldata_strong
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(#s: serializer p)
(s32: partial_serializer32 s)
(sz: nat { sz < 4294967296 } )
: Tot (serializer32 (serialize_fldata_strong s sz))
= (fun (input: parse_fldata_strong_t s sz) -> s32 input) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.FLData.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.FLData",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
s: LowParse.Spec.Base.serializer p ->
sz: Prims.nat ->
sz32: FStar.UInt32.t{FStar.UInt32.v sz32 == sz}
-> LowParse.SLow.Base.size32 (LowParse.Spec.FLData.serialize_fldata_strong s sz) | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Base.serializer",
"Prims.nat",
"FStar.UInt32.t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt32.n",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt32.v",
"LowParse.SLow.Base.size32_constant",
"LowParse.Spec.FLData.parse_fldata_kind",
"LowParse.Spec.FLData.parse_fldata_strong_t",
"LowParse.Spec.FLData.parse_fldata_strong",
"LowParse.Spec.FLData.serialize_fldata_strong",
"LowParse.SLow.Base.size32"
] | [] | false | false | false | false | false | let size32_fldata_strong
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(sz: nat)
(sz32: U32.t{U32.v sz32 == sz})
: Tot (size32 (serialize_fldata_strong s sz)) =
| size32_constant (serialize_fldata_strong s sz) sz32 () | false |
LowStar.Lib.LinkedList.fst | LowStar.Lib.LinkedList.push | val push: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) -> (x: a) ->
ST unit
(requires (fun h ->
let l = B.deref h pl in
B.live h pl /\
well_formed h l n /\
invariant h l n /\
ST.is_eternal_region r /\
B.(loc_includes (loc_region_only true r) (footprint h l n)) /\
B.(loc_disjoint (loc_buffer pl) (loc_region_only true r))
))
(ensures (fun h0 _ h1 ->
let n' = G.hide (x :: G.reveal n) in
let l = B.deref h1 pl in
// Style note: I don't repeat ``B.live pl`` in the post-condition since
// ``B.modifies (loc_buffer pl) h0 h1`` implies that ``B.live h1 pl``.
B.modifies (B.loc_buffer pl) h0 h1 /\
well_formed h1 l n' /\
invariant h1 l n' /\
B.(loc_includes (loc_region_only true r) (footprint h1 l n') /\
Cons? (cells h1 l n') /\ List.Tot.tail (cells h1 l n') == cells h0 (B.deref h0 pl) n /\
B.fresh_loc (B.loc_addr_of_buffer (List.Tot.hd (cells h1 l n'))) h0 h1)
)) | val push: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) -> (x: a) ->
ST unit
(requires (fun h ->
let l = B.deref h pl in
B.live h pl /\
well_formed h l n /\
invariant h l n /\
ST.is_eternal_region r /\
B.(loc_includes (loc_region_only true r) (footprint h l n)) /\
B.(loc_disjoint (loc_buffer pl) (loc_region_only true r))
))
(ensures (fun h0 _ h1 ->
let n' = G.hide (x :: G.reveal n) in
let l = B.deref h1 pl in
// Style note: I don't repeat ``B.live pl`` in the post-condition since
// ``B.modifies (loc_buffer pl) h0 h1`` implies that ``B.live h1 pl``.
B.modifies (B.loc_buffer pl) h0 h1 /\
well_formed h1 l n' /\
invariant h1 l n' /\
B.(loc_includes (loc_region_only true r) (footprint h1 l n') /\
Cons? (cells h1 l n') /\ List.Tot.tail (cells h1 l n') == cells h0 (B.deref h0 pl) n /\
B.fresh_loc (B.loc_addr_of_buffer (List.Tot.hd (cells h1 l n'))) h0 h1)
)) | let push #a r n pl x =
(**) let h0 = ST.get () in
let l = !* pl in
let c = { data = x; next = l } in
let pc: B.pointer (cell a) = B.malloc r c 1ul in
(**) let h1 = ST.get () in
(**) B.(modifies_only_not_unused_in loc_none h0 h1);
(**) assert B.(loc_disjoint (loc_buffer pc) (footprint h0 l n));
pl *= pc;
(**) let h2 = ST.get () in
(**) let n' = G.hide (x :: G.reveal n) in
(**) B.(modifies_trans loc_none h0 h1 (loc_buffer pl) h2);
(**) assert (well_formed h2 (B.deref h2 pl) n');
(**) assert (invariant h2 (B.deref h2 pl) n');
(**) assert ((B.deref h2 (B.deref h2 pl)).next == l);
() | {
"file_name": "krmllib/LowStar.Lib.LinkedList.fst",
"git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} | {
"end_col": 4,
"end_line": 371,
"start_col": 0,
"start_line": 353
} | module LowStar.Lib.LinkedList
/// This module, oftentimes referred to as LL1 in other parts of the
/// documentation, provides a low-level view over a linked list. Unless you
/// intend on modifying the structure of the linked list (e.g. removing cells)
/// or iterating over each cell, your are probably better off using LL2.
///
/// This module is intentionally not relying on a tight abstraction, to i) permit
/// direct-style iteration by clients and ii) allow stating some SMTPat lemmas
/// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can
/// happen automatically at the SMT level since LL2 does not have an fsti either).
///
/// Some open questions relative to the design of this module:
/// - should ``v`` be defined directly in terms of ``cells`` rather than have a
/// recursive definition along with an equivalence lemma?
/// - should ``footprint`` be defined directly in terms of ``cells`` rather than
/// have a recursive definition along with an equivalence lemma?
/// - is it worth the trouble defining a footprint? my intuition is that it's
/// fine and allows some clients to do very precise reasoning -- other modules
/// (e.g. AssocList), when establishing abstraction boundaries, can simplify
/// things and get rid of the precise footprint reasoning in favor of a static
/// region-based footprint
///
/// Some remaining work items:
/// - switch to C.Loops.while
open LowStar.BufferOps
module B = LowStar.Buffer
module HS = FStar.HyperStack
module G = FStar.Ghost
module L = FStar.List.Tot
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
open FStar.HyperStack.ST
/// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since
/// everything does recursive list reasoning.
#set-options "--__no_positivity --fuel 1 --ifuel 1"
/// Definition of the Low* type
/// ---------------------------
noeq
type t (a: Type0) =
B.pointer_or_null (cell a)
and cell (a: Type0) = {
next: t a;
data: a;
}
/// Unlike the canonical style that associates a ``v`` function to any stateful
/// representation, we use a relation here. Writing a function is just
/// impossible, since we can't prove termination of ``v`` owing to the fact that
/// there may be an infinite number of cells in the heap.
///
/// LL2 is the module that switches to the function style.
///
/// Note: no need to use erased here for ``l`` since the function is already in ``GTot``.
let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) =
B.live h c /\ (
match l with
| [] ->
B.g_is_null c
| a :: q ->
B.length c == 1 /\ (
let { data=data; next=next } = B.get h c 0 in
a == data /\
well_formed h next (G.hide q)
))
/// Precise reasoning via the cells predicate
/// -----------------------------------------
///
/// The modifies clauses are given either on the footprint of the list, or on a
/// region that includes the footprint of the list (higher up the stack, e.g.
/// LL2). This is good, but does not rule out "stupid" implementations that
/// might re-allocate every single list cell when, say, doing a pop.
///
/// For advanced usages which take pointers directly to individual list cells,
/// it's important to rule out these cases. We thus define the ``cells``
/// predicate for that purpose.
let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a)))
(requires well_formed h c l)
(ensures fun _ -> True)
(decreases l)
=
if B.g_is_null c then
[]
else
c :: cells h (B.deref h c).next (List.Tot.tl l)
/// A missing bit of automated reasoning
/// ------------------------------------
/// This should be absolutely trivial, yet, because there's no pattern on
/// null_unique, we have to do the case analysis and the decomposition
/// ourselves. This is quite tedious, as it usually takes a while (at least it
/// did for me!) to realize that this property does not hold automatically.
///
/// I'm setting an SMTPat on this lemma because it's absolutely impossible to
/// get any work done without it.
let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma
(requires (
well_formed h0 ll0 l0 /\
well_formed h1 ll1 l1 /\
cells h0 ll0 l0 == cells h1 ll1 l1))
(ensures (
ll0 == ll1))
[ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ]
=
if B.g_is_null ll0 && B.g_is_null ll1 then begin
B.null_unique ll0;
B.null_unique ll1
end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin
()
end else
false_elim ()
/// Classic stateful reasoning lemmas
/// ---------------------------------
///
/// This essentially follows ``stateful``, the type class of a mutable piece of
/// state defined using the modifies-theory of Low*v2 and equipped with the
/// right lemmas to enable usage by clients. See
/// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context.
val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc
(requires (well_formed h l n))
(ensures (fun refs -> True))
(decreases n)
let rec footprint #a h l n =
if B.g_is_null l
then B.loc_none
else
let {next = next} = B.get h l 0 in
let refs = footprint h next (G.hide (L.tl n)) in
B.loc_union (B.loc_addr_of_buffer l) refs
/// Departing from LinkedList4 here. I prefer to bolt these into the invariant
/// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to
/// deduce these.
val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_pairwise_disjoint #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\
cells_pairwise_disjoint h next (L.tl n)
val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_live_freeable #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.live h l /\ B.freeable l /\
cells_live_freeable h next (L.tl n)
val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let invariant #a h l n =
cells_live_freeable h l n /\ cells_pairwise_disjoint h l n
/// Normally this would be automatic and writing a custom lemma for that stuff
/// would be needed only when writing an fsti, however, as stated earlier,
/// recursion makes everything more difficult and this absolutely needs to be in
/// scope otherwise the modifies-clause theory cannot deduce disjointness of
/// fresh allocations w.r.t. the footprint.
let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a): Lemma
(requires well_formed h l n)
(ensures B.loc_in (footprint h l n) h)
(decreases n)
[ SMTPat (invariant h l n) ]
=
if B.g_is_null l then
()
else
let next = (B.deref h l).next in
invariant_loc_in_footprint h next (L.tl n)
/// Another absolutely essential lemma, for which interestingly the pattern
/// "invariant h1 l n" does not work, but well_formed does... I guess that's
/// alright.
let rec frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem): Lemma
(requires (
well_formed h0 l n /\
invariant h0 l n /\
B.loc_disjoint r (footprint h0 l n) /\
B.modifies r h0 h1
))
(ensures (
well_formed h1 l n /\
footprint h1 l n == footprint h0 l n /\
cells h1 l n == cells h0 l n /\
invariant h1 l n
))
(decreases n)
[ SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1) ]
=
if B.g_is_null l then
()
else
frame (B.deref h0 l).next (L.tl n) r h0 h1
/// Lemmas for working with linked lists
/// ------------------------------------
///
/// Since it's a recursive data structure, a lot of the automated reasoning from
/// LowStar.Buffer doesn't work since it requires inductions. Some helpful
/// properties are therefore proved here.
let rec length_functional #a (h: HS.mem) (c: t a) (l1 l2: list a):
Lemma
(requires (well_formed h c l1 /\ well_formed h c l2))
(ensures (l1 == l2))
(decreases (G.reveal l1))
[ SMTPat (well_formed h c l1); SMTPat (well_formed h c l2) ] =
if B.g_is_null c
then ()
else
let { next=next } = B.get h c 0 in
length_functional h next (G.hide (L.tl l1)) (G.hide (L.tl l2))
/// The footprint is based on loc_addr_of_buffer so that we can write a free
/// operation that operates on the footprint. However, this invalidates most of
/// the helper lemmas for disjointness that were present in the previous
/// iteration of this module, named LinkedList4.fst. It's ok, we bake
/// disjointness directly onto the invariant and it works just as well.
/// Connection between ``cells`` and ``v``
/// --------------------------------------
/// Redefining some helpers.
#push-options "--ifuel 1"
let rec gmap #a #b (f: a -> GTot b) (xs: list a): GTot (list b) =
match xs with
| [] -> []
| x :: xs -> f x :: gmap f xs
/// "As we all know", right folds are the easiest to work with because they
/// follow the natural structure of recursion (left-folds are evil).
let rec gfold_right #a #b (f: b -> a -> GTot b) (xs: list a) (acc: b): Ghost b
(requires True)
(ensures fun _ -> True)
(decreases xs)
=
match xs with
| [] -> acc
| x :: xs -> f (gfold_right f xs acc) x
#pop-options
/// Connecting ``v`` and ``cells``.
///
/// See ``tests/Wireguard.fst`` for why going through gmap is important and how
/// to structure your definitions (should you need to reason about ``cells``) in
/// a way that will make your life easier.
let deref_data #a (h: HS.mem) (c: B.pointer (cell a)): GTot a =
(B.deref h c).data
#push-options "--fuel 1 --ifuel 1"
let rec deref_cells_is_v #a (h: HS.mem) (ll: t a) (l: list a): Lemma
(requires
well_formed h ll l /\
invariant h ll l)
(ensures
gmap (deref_data h) (cells h ll l) == l)
(decreases l)
[ SMTPat (well_formed h ll l) ]
=
if B.g_is_null ll then
()
else
deref_cells_is_v h (B.deref h ll).next (List.Tot.tl l)
#pop-options
/// Connecting ``footprint`` and ``cells``.
///
/// This allows conveniently switching to a low-level representation of the
/// footprint in case clients want to do some ultra-precise reasoning about
/// what's happening with the list spine. However, the fact that all
/// operations from this module specify things in terms of ``cells`` along with
/// ``same_cells_same_pointer`` should cover most common cases. (This predates
/// the introduction of ``same_cells_same_pointer``.)
///
/// So, no SMTPat here. Note, I also used the same trick as above with
/// higher-order combinators to isolate the use of the argument ``h`` to a
/// single sub-term rather than having it passed down the recursive calls.
#push-options "--fuel 2 --ifuel 2"
let rec footprint_via_cells_is_footprint #a (h: HS.mem) (ll: t a) (l: list a): Lemma
(requires well_formed h ll l)
(ensures
footprint h ll l == (gfold_right B.loc_union (gmap B.loc_addr_of_buffer (cells h ll l)) B.loc_none))
(decreases l)
=
if B.g_is_null ll then
()
else
footprint_via_cells_is_footprint h (B.deref h ll).next (List.Tot.tl l)
#pop-options
/// Stateful operations
/// -------------------
///
/// One thing to note: we pass the region `r` explicitly, which is certainly not
/// very convenient, but that's alright, another layer of abstraction will take
/// care of adding existentials and extra machinery to make this more pleasant
/// to use.
///
/// All of the operations below are low-level (in the sense that they rely on
/// the predicate). I expect clients to use exclusively the variants of these
/// functions present in LL2.
val push: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) -> (x: a) ->
ST unit
(requires (fun h ->
let l = B.deref h pl in
B.live h pl /\
well_formed h l n /\
invariant h l n /\
ST.is_eternal_region r /\
B.(loc_includes (loc_region_only true r) (footprint h l n)) /\
B.(loc_disjoint (loc_buffer pl) (loc_region_only true r))
))
(ensures (fun h0 _ h1 ->
let n' = G.hide (x :: G.reveal n) in
let l = B.deref h1 pl in
// Style note: I don't repeat ``B.live pl`` in the post-condition since
// ``B.modifies (loc_buffer pl) h0 h1`` implies that ``B.live h1 pl``.
B.modifies (B.loc_buffer pl) h0 h1 /\
well_formed h1 l n' /\
invariant h1 l n' /\
B.(loc_includes (loc_region_only true r) (footprint h1 l n') /\
Cons? (cells h1 l n') /\ List.Tot.tail (cells h1 l n') == cells h0 (B.deref h0 pl) n /\
B.fresh_loc (B.loc_addr_of_buffer (List.Tot.hd (cells h1 l n'))) h0 h1)
)) | {
"checked_file": "/",
"dependencies": [
"TestLib.fsti.checked",
"prims.fst.checked",
"LowStar.Failure.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int32.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Lib.LinkedList.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
r: FStar.Monotonic.HyperHeap.rid ->
n: FStar.Ghost.erased (Prims.list a) ->
pl: LowStar.Buffer.pointer (LowStar.Lib.LinkedList.t a) ->
x: a
-> FStar.HyperStack.ST.ST Prims.unit | FStar.HyperStack.ST.ST | [] | [] | [
"FStar.Monotonic.HyperHeap.rid",
"FStar.Ghost.erased",
"Prims.list",
"LowStar.Buffer.pointer",
"LowStar.Lib.LinkedList.t",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"LowStar.Buffer.pointer_or_null",
"LowStar.Lib.LinkedList.cell",
"LowStar.Lib.LinkedList.__proj__Mkcell__item__next",
"LowStar.Monotonic.Buffer.deref",
"LowStar.Buffer.trivial_preorder",
"LowStar.Lib.LinkedList.invariant",
"FStar.Ghost.reveal",
"LowStar.Lib.LinkedList.well_formed",
"LowStar.Monotonic.Buffer.modifies_trans",
"LowStar.Monotonic.Buffer.loc_none",
"LowStar.Monotonic.Buffer.loc_buffer",
"FStar.Ghost.hide",
"Prims.Cons",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"LowStar.BufferOps.op_Star_Equals",
"LowStar.Monotonic.Buffer.loc_disjoint",
"LowStar.Lib.LinkedList.footprint",
"LowStar.Monotonic.Buffer.modifies_only_not_unused_in",
"LowStar.Buffer.malloc",
"FStar.UInt32.__uint_to_t",
"LowStar.Monotonic.Buffer.mbuffer",
"Prims.l_and",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.UInt32.v",
"Prims.b2t",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"LowStar.Monotonic.Buffer.frameOf",
"LowStar.Monotonic.Buffer.freeable",
"LowStar.Lib.LinkedList.Mkcell",
"LowStar.BufferOps.op_Bang_Star"
] | [] | false | true | false | false | false | let push #a r n pl x =
| let h0 = ST.get () in
let l = !*pl in
let c = { data = x; next = l } in
let pc:B.pointer (cell a) = B.malloc r c 1ul in
let h1 = ST.get () in
(let open B in modifies_only_not_unused_in loc_none h0 h1);
assert B.(loc_disjoint (loc_buffer pc) (footprint h0 l n));
pl *= pc;
let h2 = ST.get () in
let n' = G.hide (x :: G.reveal n) in
(let open B in modifies_trans loc_none h0 h1 (loc_buffer pl) h2);
assert (well_formed h2 (B.deref h2 pl) n');
assert (invariant h2 (B.deref h2 pl) n');
assert ((B.deref h2 (B.deref h2 pl)).next == l);
() | false |
LowStar.Lib.LinkedList.fst | LowStar.Lib.LinkedList.test | val test: unit -> ST (Int32.t) (fun _ -> true) (fun _ _ _ -> true) | val test: unit -> ST (Int32.t) (fun _ -> true) (fun _ _ _ -> true) | let test () =
let l: B.pointer_or_null (t Int32.t) = B.malloc HS.root B.null 1ul in
let l_region = new_region HS.root in
push #Int32.t l_region (G.hide []) l 1l;
push #Int32.t l_region (G.hide [1l]) l 0l;
let r = pop #Int32.t l_region (G.hide [0l; 1l]) l in
TestLib.checku32 (length (G.hide [1l]) !*l) 1ul;
r | {
"file_name": "krmllib/LowStar.Lib.LinkedList.fst",
"git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} | {
"end_col": 3,
"end_line": 485,
"start_col": 0,
"start_line": 478
} | module LowStar.Lib.LinkedList
/// This module, oftentimes referred to as LL1 in other parts of the
/// documentation, provides a low-level view over a linked list. Unless you
/// intend on modifying the structure of the linked list (e.g. removing cells)
/// or iterating over each cell, your are probably better off using LL2.
///
/// This module is intentionally not relying on a tight abstraction, to i) permit
/// direct-style iteration by clients and ii) allow stating some SMTPat lemmas
/// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can
/// happen automatically at the SMT level since LL2 does not have an fsti either).
///
/// Some open questions relative to the design of this module:
/// - should ``v`` be defined directly in terms of ``cells`` rather than have a
/// recursive definition along with an equivalence lemma?
/// - should ``footprint`` be defined directly in terms of ``cells`` rather than
/// have a recursive definition along with an equivalence lemma?
/// - is it worth the trouble defining a footprint? my intuition is that it's
/// fine and allows some clients to do very precise reasoning -- other modules
/// (e.g. AssocList), when establishing abstraction boundaries, can simplify
/// things and get rid of the precise footprint reasoning in favor of a static
/// region-based footprint
///
/// Some remaining work items:
/// - switch to C.Loops.while
open LowStar.BufferOps
module B = LowStar.Buffer
module HS = FStar.HyperStack
module G = FStar.Ghost
module L = FStar.List.Tot
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
open FStar.HyperStack.ST
/// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since
/// everything does recursive list reasoning.
#set-options "--__no_positivity --fuel 1 --ifuel 1"
/// Definition of the Low* type
/// ---------------------------
noeq
type t (a: Type0) =
B.pointer_or_null (cell a)
and cell (a: Type0) = {
next: t a;
data: a;
}
/// Unlike the canonical style that associates a ``v`` function to any stateful
/// representation, we use a relation here. Writing a function is just
/// impossible, since we can't prove termination of ``v`` owing to the fact that
/// there may be an infinite number of cells in the heap.
///
/// LL2 is the module that switches to the function style.
///
/// Note: no need to use erased here for ``l`` since the function is already in ``GTot``.
let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) =
B.live h c /\ (
match l with
| [] ->
B.g_is_null c
| a :: q ->
B.length c == 1 /\ (
let { data=data; next=next } = B.get h c 0 in
a == data /\
well_formed h next (G.hide q)
))
/// Precise reasoning via the cells predicate
/// -----------------------------------------
///
/// The modifies clauses are given either on the footprint of the list, or on a
/// region that includes the footprint of the list (higher up the stack, e.g.
/// LL2). This is good, but does not rule out "stupid" implementations that
/// might re-allocate every single list cell when, say, doing a pop.
///
/// For advanced usages which take pointers directly to individual list cells,
/// it's important to rule out these cases. We thus define the ``cells``
/// predicate for that purpose.
let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a)))
(requires well_formed h c l)
(ensures fun _ -> True)
(decreases l)
=
if B.g_is_null c then
[]
else
c :: cells h (B.deref h c).next (List.Tot.tl l)
/// A missing bit of automated reasoning
/// ------------------------------------
/// This should be absolutely trivial, yet, because there's no pattern on
/// null_unique, we have to do the case analysis and the decomposition
/// ourselves. This is quite tedious, as it usually takes a while (at least it
/// did for me!) to realize that this property does not hold automatically.
///
/// I'm setting an SMTPat on this lemma because it's absolutely impossible to
/// get any work done without it.
let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma
(requires (
well_formed h0 ll0 l0 /\
well_formed h1 ll1 l1 /\
cells h0 ll0 l0 == cells h1 ll1 l1))
(ensures (
ll0 == ll1))
[ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ]
=
if B.g_is_null ll0 && B.g_is_null ll1 then begin
B.null_unique ll0;
B.null_unique ll1
end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin
()
end else
false_elim ()
/// Classic stateful reasoning lemmas
/// ---------------------------------
///
/// This essentially follows ``stateful``, the type class of a mutable piece of
/// state defined using the modifies-theory of Low*v2 and equipped with the
/// right lemmas to enable usage by clients. See
/// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context.
val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc
(requires (well_formed h l n))
(ensures (fun refs -> True))
(decreases n)
let rec footprint #a h l n =
if B.g_is_null l
then B.loc_none
else
let {next = next} = B.get h l 0 in
let refs = footprint h next (G.hide (L.tl n)) in
B.loc_union (B.loc_addr_of_buffer l) refs
/// Departing from LinkedList4 here. I prefer to bolt these into the invariant
/// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to
/// deduce these.
val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_pairwise_disjoint #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\
cells_pairwise_disjoint h next (L.tl n)
val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_live_freeable #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.live h l /\ B.freeable l /\
cells_live_freeable h next (L.tl n)
val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let invariant #a h l n =
cells_live_freeable h l n /\ cells_pairwise_disjoint h l n
/// Normally this would be automatic and writing a custom lemma for that stuff
/// would be needed only when writing an fsti, however, as stated earlier,
/// recursion makes everything more difficult and this absolutely needs to be in
/// scope otherwise the modifies-clause theory cannot deduce disjointness of
/// fresh allocations w.r.t. the footprint.
let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a): Lemma
(requires well_formed h l n)
(ensures B.loc_in (footprint h l n) h)
(decreases n)
[ SMTPat (invariant h l n) ]
=
if B.g_is_null l then
()
else
let next = (B.deref h l).next in
invariant_loc_in_footprint h next (L.tl n)
/// Another absolutely essential lemma, for which interestingly the pattern
/// "invariant h1 l n" does not work, but well_formed does... I guess that's
/// alright.
let rec frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem): Lemma
(requires (
well_formed h0 l n /\
invariant h0 l n /\
B.loc_disjoint r (footprint h0 l n) /\
B.modifies r h0 h1
))
(ensures (
well_formed h1 l n /\
footprint h1 l n == footprint h0 l n /\
cells h1 l n == cells h0 l n /\
invariant h1 l n
))
(decreases n)
[ SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1) ]
=
if B.g_is_null l then
()
else
frame (B.deref h0 l).next (L.tl n) r h0 h1
/// Lemmas for working with linked lists
/// ------------------------------------
///
/// Since it's a recursive data structure, a lot of the automated reasoning from
/// LowStar.Buffer doesn't work since it requires inductions. Some helpful
/// properties are therefore proved here.
let rec length_functional #a (h: HS.mem) (c: t a) (l1 l2: list a):
Lemma
(requires (well_formed h c l1 /\ well_formed h c l2))
(ensures (l1 == l2))
(decreases (G.reveal l1))
[ SMTPat (well_formed h c l1); SMTPat (well_formed h c l2) ] =
if B.g_is_null c
then ()
else
let { next=next } = B.get h c 0 in
length_functional h next (G.hide (L.tl l1)) (G.hide (L.tl l2))
/// The footprint is based on loc_addr_of_buffer so that we can write a free
/// operation that operates on the footprint. However, this invalidates most of
/// the helper lemmas for disjointness that were present in the previous
/// iteration of this module, named LinkedList4.fst. It's ok, we bake
/// disjointness directly onto the invariant and it works just as well.
/// Connection between ``cells`` and ``v``
/// --------------------------------------
/// Redefining some helpers.
#push-options "--ifuel 1"
let rec gmap #a #b (f: a -> GTot b) (xs: list a): GTot (list b) =
match xs with
| [] -> []
| x :: xs -> f x :: gmap f xs
/// "As we all know", right folds are the easiest to work with because they
/// follow the natural structure of recursion (left-folds are evil).
let rec gfold_right #a #b (f: b -> a -> GTot b) (xs: list a) (acc: b): Ghost b
(requires True)
(ensures fun _ -> True)
(decreases xs)
=
match xs with
| [] -> acc
| x :: xs -> f (gfold_right f xs acc) x
#pop-options
/// Connecting ``v`` and ``cells``.
///
/// See ``tests/Wireguard.fst`` for why going through gmap is important and how
/// to structure your definitions (should you need to reason about ``cells``) in
/// a way that will make your life easier.
let deref_data #a (h: HS.mem) (c: B.pointer (cell a)): GTot a =
(B.deref h c).data
#push-options "--fuel 1 --ifuel 1"
let rec deref_cells_is_v #a (h: HS.mem) (ll: t a) (l: list a): Lemma
(requires
well_formed h ll l /\
invariant h ll l)
(ensures
gmap (deref_data h) (cells h ll l) == l)
(decreases l)
[ SMTPat (well_formed h ll l) ]
=
if B.g_is_null ll then
()
else
deref_cells_is_v h (B.deref h ll).next (List.Tot.tl l)
#pop-options
/// Connecting ``footprint`` and ``cells``.
///
/// This allows conveniently switching to a low-level representation of the
/// footprint in case clients want to do some ultra-precise reasoning about
/// what's happening with the list spine. However, the fact that all
/// operations from this module specify things in terms of ``cells`` along with
/// ``same_cells_same_pointer`` should cover most common cases. (This predates
/// the introduction of ``same_cells_same_pointer``.)
///
/// So, no SMTPat here. Note, I also used the same trick as above with
/// higher-order combinators to isolate the use of the argument ``h`` to a
/// single sub-term rather than having it passed down the recursive calls.
#push-options "--fuel 2 --ifuel 2"
let rec footprint_via_cells_is_footprint #a (h: HS.mem) (ll: t a) (l: list a): Lemma
(requires well_formed h ll l)
(ensures
footprint h ll l == (gfold_right B.loc_union (gmap B.loc_addr_of_buffer (cells h ll l)) B.loc_none))
(decreases l)
=
if B.g_is_null ll then
()
else
footprint_via_cells_is_footprint h (B.deref h ll).next (List.Tot.tl l)
#pop-options
/// Stateful operations
/// -------------------
///
/// One thing to note: we pass the region `r` explicitly, which is certainly not
/// very convenient, but that's alright, another layer of abstraction will take
/// care of adding existentials and extra machinery to make this more pleasant
/// to use.
///
/// All of the operations below are low-level (in the sense that they rely on
/// the predicate). I expect clients to use exclusively the variants of these
/// functions present in LL2.
val push: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) -> (x: a) ->
ST unit
(requires (fun h ->
let l = B.deref h pl in
B.live h pl /\
well_formed h l n /\
invariant h l n /\
ST.is_eternal_region r /\
B.(loc_includes (loc_region_only true r) (footprint h l n)) /\
B.(loc_disjoint (loc_buffer pl) (loc_region_only true r))
))
(ensures (fun h0 _ h1 ->
let n' = G.hide (x :: G.reveal n) in
let l = B.deref h1 pl in
// Style note: I don't repeat ``B.live pl`` in the post-condition since
// ``B.modifies (loc_buffer pl) h0 h1`` implies that ``B.live h1 pl``.
B.modifies (B.loc_buffer pl) h0 h1 /\
well_formed h1 l n' /\
invariant h1 l n' /\
B.(loc_includes (loc_region_only true r) (footprint h1 l n') /\
Cons? (cells h1 l n') /\ List.Tot.tail (cells h1 l n') == cells h0 (B.deref h0 pl) n /\
B.fresh_loc (B.loc_addr_of_buffer (List.Tot.hd (cells h1 l n'))) h0 h1)
))
let push #a r n pl x =
(**) let h0 = ST.get () in
let l = !* pl in
let c = { data = x; next = l } in
let pc: B.pointer (cell a) = B.malloc r c 1ul in
(**) let h1 = ST.get () in
(**) B.(modifies_only_not_unused_in loc_none h0 h1);
(**) assert B.(loc_disjoint (loc_buffer pc) (footprint h0 l n));
pl *= pc;
(**) let h2 = ST.get () in
(**) let n' = G.hide (x :: G.reveal n) in
(**) B.(modifies_trans loc_none h0 h1 (loc_buffer pl) h2);
(**) assert (well_formed h2 (B.deref h2 pl) n');
(**) assert (invariant h2 (B.deref h2 pl) n');
(**) assert ((B.deref h2 (B.deref h2 pl)).next == l);
()
val pop: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) ->
ST a
(requires (fun h ->
let l = B.deref h pl in
B.live h pl /\
well_formed h l n /\
invariant h l n /\
ST.is_eternal_region r /\
B.(loc_includes (loc_region_only true r) (footprint h l n)) /\
B.loc_disjoint (B.loc_buffer pl) (footprint h l n) /\
Cons? n
))
(ensures (fun h0 x h1 ->
let l = B.deref h1 pl in
let n' = L.tl n in
x == L.hd n /\
// Introducing a super precise modifies clause (e.g. loc_addr_of_buffer
// (B.deref h0 pl)) here is not useful and prevents trigger-based
// reasoning, while also requiring clients to unroll footprint. There's a
// tension here between revealing that ``pop`` does nothing stupid (e.g.
// re-allocating all the list cells) and providing an abstract enough
// predicate to work with.
B.(modifies (loc_buffer pl `loc_union` footprint h0 (B.deref h0 pl) n) h0 h1) /\
well_formed h1 l n' /\
invariant h1 l n' /\
B.(loc_includes (loc_region_only true r) (footprint h1 l n')) /\
List.Tot.tail (cells h0 (B.deref h0 pl) n) == cells h1 l n'))
let pop #a r n pl =
let l = !* pl in
let r = (!*l).data in
let next = (!*l).next in
(**) let h1 = ST.get () in
(**) assert (cells h1 l n == l :: cells h1 next (List.Tot.tl n));
(**) assert B.(loc_disjoint (loc_buffer pl) (footprint h1 l n));
(**) assert B.(loc_disjoint (loc_buffer pl) (footprint h1 next (List.Tot.tl n)));
pl *= next;
B.free l;
r
val free_: (#a: Type) -> (#n: G.erased (list a)) -> (l: t a) ->
ST unit
(requires (fun h ->
well_formed h l n /\
invariant h l n
))
(ensures (fun h0 _ h1 ->
B.(modifies (footprint h0 l n) h0 h1)))
let rec free_ #a #n l =
if B.is_null l then
()
else begin
let tl: G.erased (list a) = G.hide (L.tl (G.reveal n)) in
free_ #_ #tl (!*l).next;
B.free l
end
val free: (#a: Type) -> (#n: G.erased (list a)) -> (pl: B.pointer (t a)) ->
ST unit
(requires (fun h ->
let l = B.deref h pl in
B.live h pl /\
well_formed h l n /\
invariant h l n /\
B.loc_disjoint (B.loc_buffer pl) (footprint h l n)
))
(ensures (fun h0 _ h1 ->
let l = B.deref h1 pl in
well_formed h1 l [] /\
invariant h1 l [] /\
footprint h1 l [] == B.loc_none /\
cells h1 l [] == [] /\
B.(modifies (footprint h0 (B.deref h0 pl) n `loc_union` loc_buffer pl) h0 h1)))
let free #a #n pl =
free_ #_ #n !*pl;
pl *= B.null
val length (#a: Type) (gn: G.erased (list a)) (l: t a): Stack UInt32.t
(requires (fun h -> well_formed h l gn))
(ensures (fun h0 n h1 ->
h0 == h1 /\
U32.v n = L.length (G.reveal gn)
))
let rec length #a gn l =
if B.is_null l then
0ul
else
let open U32 in
let c = !* l in
let next = c.next in
let n = length (G.hide (L.tail (G.reveal gn))) next in
if n = 0xfffffffful then begin
LowStar.Failure.failwith "Integer overflow in LowStar.LinkedList.length"
end else
n +^ 1ul
/// Small test
/// ----------
val test: unit -> ST (Int32.t) (fun _ -> true) (fun _ _ _ -> true) | {
"checked_file": "/",
"dependencies": [
"TestLib.fsti.checked",
"prims.fst.checked",
"LowStar.Failure.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int32.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Lib.LinkedList.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit -> FStar.HyperStack.ST.ST FStar.Int32.t | FStar.HyperStack.ST.ST | [] | [] | [
"Prims.unit",
"FStar.Int32.t",
"TestLib.checku32",
"FStar.UInt32.__uint_to_t",
"FStar.UInt32.t",
"LowStar.Lib.LinkedList.length",
"FStar.Ghost.hide",
"Prims.list",
"Prims.Cons",
"FStar.Int32.__int_to_t",
"Prims.Nil",
"LowStar.Lib.LinkedList.t",
"LowStar.BufferOps.op_Bang_Star",
"LowStar.Buffer.trivial_preorder",
"LowStar.Lib.LinkedList.pop",
"LowStar.Lib.LinkedList.push",
"FStar.Monotonic.HyperHeap.rid",
"FStar.HyperStack.ST.new_region",
"FStar.Monotonic.HyperHeap.root",
"LowStar.Buffer.pointer_or_null",
"LowStar.Buffer.malloc",
"LowStar.Buffer.null",
"LowStar.Lib.LinkedList.cell",
"LowStar.Monotonic.Buffer.mbuffer",
"Prims.l_and",
"Prims.eq2",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.UInt32.v",
"Prims.b2t",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"LowStar.Monotonic.Buffer.frameOf",
"LowStar.Monotonic.Buffer.freeable"
] | [] | false | true | false | false | false | let test () =
| let l:B.pointer_or_null (t Int32.t) = B.malloc HS.root B.null 1ul in
let l_region = new_region HS.root in
push #Int32.t l_region (G.hide []) l 1l;
push #Int32.t l_region (G.hide [1l]) l 0l;
let r = pop #Int32.t l_region (G.hide [0l; 1l]) l in
TestLib.checku32 (length (G.hide [1l]) !*l) 1ul;
r | false |
LowStar.Lib.LinkedList.fst | LowStar.Lib.LinkedList.free | val free: (#a: Type) -> (#n: G.erased (list a)) -> (pl: B.pointer (t a)) ->
ST unit
(requires (fun h ->
let l = B.deref h pl in
B.live h pl /\
well_formed h l n /\
invariant h l n /\
B.loc_disjoint (B.loc_buffer pl) (footprint h l n)
))
(ensures (fun h0 _ h1 ->
let l = B.deref h1 pl in
well_formed h1 l [] /\
invariant h1 l [] /\
footprint h1 l [] == B.loc_none /\
cells h1 l [] == [] /\
B.(modifies (footprint h0 (B.deref h0 pl) n `loc_union` loc_buffer pl) h0 h1))) | val free: (#a: Type) -> (#n: G.erased (list a)) -> (pl: B.pointer (t a)) ->
ST unit
(requires (fun h ->
let l = B.deref h pl in
B.live h pl /\
well_formed h l n /\
invariant h l n /\
B.loc_disjoint (B.loc_buffer pl) (footprint h l n)
))
(ensures (fun h0 _ h1 ->
let l = B.deref h1 pl in
well_formed h1 l [] /\
invariant h1 l [] /\
footprint h1 l [] == B.loc_none /\
cells h1 l [] == [] /\
B.(modifies (footprint h0 (B.deref h0 pl) n `loc_union` loc_buffer pl) h0 h1))) | let free #a #n pl =
free_ #_ #n !*pl;
pl *= B.null | {
"file_name": "krmllib/LowStar.Lib.LinkedList.fst",
"git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} | {
"end_col": 14,
"end_line": 451,
"start_col": 0,
"start_line": 449
} | module LowStar.Lib.LinkedList
/// This module, oftentimes referred to as LL1 in other parts of the
/// documentation, provides a low-level view over a linked list. Unless you
/// intend on modifying the structure of the linked list (e.g. removing cells)
/// or iterating over each cell, your are probably better off using LL2.
///
/// This module is intentionally not relying on a tight abstraction, to i) permit
/// direct-style iteration by clients and ii) allow stating some SMTPat lemmas
/// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can
/// happen automatically at the SMT level since LL2 does not have an fsti either).
///
/// Some open questions relative to the design of this module:
/// - should ``v`` be defined directly in terms of ``cells`` rather than have a
/// recursive definition along with an equivalence lemma?
/// - should ``footprint`` be defined directly in terms of ``cells`` rather than
/// have a recursive definition along with an equivalence lemma?
/// - is it worth the trouble defining a footprint? my intuition is that it's
/// fine and allows some clients to do very precise reasoning -- other modules
/// (e.g. AssocList), when establishing abstraction boundaries, can simplify
/// things and get rid of the precise footprint reasoning in favor of a static
/// region-based footprint
///
/// Some remaining work items:
/// - switch to C.Loops.while
open LowStar.BufferOps
module B = LowStar.Buffer
module HS = FStar.HyperStack
module G = FStar.Ghost
module L = FStar.List.Tot
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
open FStar.HyperStack.ST
/// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since
/// everything does recursive list reasoning.
#set-options "--__no_positivity --fuel 1 --ifuel 1"
/// Definition of the Low* type
/// ---------------------------
noeq
type t (a: Type0) =
B.pointer_or_null (cell a)
and cell (a: Type0) = {
next: t a;
data: a;
}
/// Unlike the canonical style that associates a ``v`` function to any stateful
/// representation, we use a relation here. Writing a function is just
/// impossible, since we can't prove termination of ``v`` owing to the fact that
/// there may be an infinite number of cells in the heap.
///
/// LL2 is the module that switches to the function style.
///
/// Note: no need to use erased here for ``l`` since the function is already in ``GTot``.
let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) =
B.live h c /\ (
match l with
| [] ->
B.g_is_null c
| a :: q ->
B.length c == 1 /\ (
let { data=data; next=next } = B.get h c 0 in
a == data /\
well_formed h next (G.hide q)
))
/// Precise reasoning via the cells predicate
/// -----------------------------------------
///
/// The modifies clauses are given either on the footprint of the list, or on a
/// region that includes the footprint of the list (higher up the stack, e.g.
/// LL2). This is good, but does not rule out "stupid" implementations that
/// might re-allocate every single list cell when, say, doing a pop.
///
/// For advanced usages which take pointers directly to individual list cells,
/// it's important to rule out these cases. We thus define the ``cells``
/// predicate for that purpose.
let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a)))
(requires well_formed h c l)
(ensures fun _ -> True)
(decreases l)
=
if B.g_is_null c then
[]
else
c :: cells h (B.deref h c).next (List.Tot.tl l)
/// A missing bit of automated reasoning
/// ------------------------------------
/// This should be absolutely trivial, yet, because there's no pattern on
/// null_unique, we have to do the case analysis and the decomposition
/// ourselves. This is quite tedious, as it usually takes a while (at least it
/// did for me!) to realize that this property does not hold automatically.
///
/// I'm setting an SMTPat on this lemma because it's absolutely impossible to
/// get any work done without it.
let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma
(requires (
well_formed h0 ll0 l0 /\
well_formed h1 ll1 l1 /\
cells h0 ll0 l0 == cells h1 ll1 l1))
(ensures (
ll0 == ll1))
[ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ]
=
if B.g_is_null ll0 && B.g_is_null ll1 then begin
B.null_unique ll0;
B.null_unique ll1
end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin
()
end else
false_elim ()
/// Classic stateful reasoning lemmas
/// ---------------------------------
///
/// This essentially follows ``stateful``, the type class of a mutable piece of
/// state defined using the modifies-theory of Low*v2 and equipped with the
/// right lemmas to enable usage by clients. See
/// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context.
val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc
(requires (well_formed h l n))
(ensures (fun refs -> True))
(decreases n)
let rec footprint #a h l n =
if B.g_is_null l
then B.loc_none
else
let {next = next} = B.get h l 0 in
let refs = footprint h next (G.hide (L.tl n)) in
B.loc_union (B.loc_addr_of_buffer l) refs
/// Departing from LinkedList4 here. I prefer to bolt these into the invariant
/// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to
/// deduce these.
val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_pairwise_disjoint #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\
cells_pairwise_disjoint h next (L.tl n)
val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_live_freeable #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.live h l /\ B.freeable l /\
cells_live_freeable h next (L.tl n)
val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let invariant #a h l n =
cells_live_freeable h l n /\ cells_pairwise_disjoint h l n
/// Normally this would be automatic and writing a custom lemma for that stuff
/// would be needed only when writing an fsti, however, as stated earlier,
/// recursion makes everything more difficult and this absolutely needs to be in
/// scope otherwise the modifies-clause theory cannot deduce disjointness of
/// fresh allocations w.r.t. the footprint.
let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a): Lemma
(requires well_formed h l n)
(ensures B.loc_in (footprint h l n) h)
(decreases n)
[ SMTPat (invariant h l n) ]
=
if B.g_is_null l then
()
else
let next = (B.deref h l).next in
invariant_loc_in_footprint h next (L.tl n)
/// Another absolutely essential lemma, for which interestingly the pattern
/// "invariant h1 l n" does not work, but well_formed does... I guess that's
/// alright.
let rec frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem): Lemma
(requires (
well_formed h0 l n /\
invariant h0 l n /\
B.loc_disjoint r (footprint h0 l n) /\
B.modifies r h0 h1
))
(ensures (
well_formed h1 l n /\
footprint h1 l n == footprint h0 l n /\
cells h1 l n == cells h0 l n /\
invariant h1 l n
))
(decreases n)
[ SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1) ]
=
if B.g_is_null l then
()
else
frame (B.deref h0 l).next (L.tl n) r h0 h1
/// Lemmas for working with linked lists
/// ------------------------------------
///
/// Since it's a recursive data structure, a lot of the automated reasoning from
/// LowStar.Buffer doesn't work since it requires inductions. Some helpful
/// properties are therefore proved here.
let rec length_functional #a (h: HS.mem) (c: t a) (l1 l2: list a):
Lemma
(requires (well_formed h c l1 /\ well_formed h c l2))
(ensures (l1 == l2))
(decreases (G.reveal l1))
[ SMTPat (well_formed h c l1); SMTPat (well_formed h c l2) ] =
if B.g_is_null c
then ()
else
let { next=next } = B.get h c 0 in
length_functional h next (G.hide (L.tl l1)) (G.hide (L.tl l2))
/// The footprint is based on loc_addr_of_buffer so that we can write a free
/// operation that operates on the footprint. However, this invalidates most of
/// the helper lemmas for disjointness that were present in the previous
/// iteration of this module, named LinkedList4.fst. It's ok, we bake
/// disjointness directly onto the invariant and it works just as well.
/// Connection between ``cells`` and ``v``
/// --------------------------------------
/// Redefining some helpers.
#push-options "--ifuel 1"
let rec gmap #a #b (f: a -> GTot b) (xs: list a): GTot (list b) =
match xs with
| [] -> []
| x :: xs -> f x :: gmap f xs
/// "As we all know", right folds are the easiest to work with because they
/// follow the natural structure of recursion (left-folds are evil).
let rec gfold_right #a #b (f: b -> a -> GTot b) (xs: list a) (acc: b): Ghost b
(requires True)
(ensures fun _ -> True)
(decreases xs)
=
match xs with
| [] -> acc
| x :: xs -> f (gfold_right f xs acc) x
#pop-options
/// Connecting ``v`` and ``cells``.
///
/// See ``tests/Wireguard.fst`` for why going through gmap is important and how
/// to structure your definitions (should you need to reason about ``cells``) in
/// a way that will make your life easier.
let deref_data #a (h: HS.mem) (c: B.pointer (cell a)): GTot a =
(B.deref h c).data
#push-options "--fuel 1 --ifuel 1"
let rec deref_cells_is_v #a (h: HS.mem) (ll: t a) (l: list a): Lemma
(requires
well_formed h ll l /\
invariant h ll l)
(ensures
gmap (deref_data h) (cells h ll l) == l)
(decreases l)
[ SMTPat (well_formed h ll l) ]
=
if B.g_is_null ll then
()
else
deref_cells_is_v h (B.deref h ll).next (List.Tot.tl l)
#pop-options
/// Connecting ``footprint`` and ``cells``.
///
/// This allows conveniently switching to a low-level representation of the
/// footprint in case clients want to do some ultra-precise reasoning about
/// what's happening with the list spine. However, the fact that all
/// operations from this module specify things in terms of ``cells`` along with
/// ``same_cells_same_pointer`` should cover most common cases. (This predates
/// the introduction of ``same_cells_same_pointer``.)
///
/// So, no SMTPat here. Note, I also used the same trick as above with
/// higher-order combinators to isolate the use of the argument ``h`` to a
/// single sub-term rather than having it passed down the recursive calls.
#push-options "--fuel 2 --ifuel 2"
let rec footprint_via_cells_is_footprint #a (h: HS.mem) (ll: t a) (l: list a): Lemma
(requires well_formed h ll l)
(ensures
footprint h ll l == (gfold_right B.loc_union (gmap B.loc_addr_of_buffer (cells h ll l)) B.loc_none))
(decreases l)
=
if B.g_is_null ll then
()
else
footprint_via_cells_is_footprint h (B.deref h ll).next (List.Tot.tl l)
#pop-options
/// Stateful operations
/// -------------------
///
/// One thing to note: we pass the region `r` explicitly, which is certainly not
/// very convenient, but that's alright, another layer of abstraction will take
/// care of adding existentials and extra machinery to make this more pleasant
/// to use.
///
/// All of the operations below are low-level (in the sense that they rely on
/// the predicate). I expect clients to use exclusively the variants of these
/// functions present in LL2.
val push: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) -> (x: a) ->
ST unit
(requires (fun h ->
let l = B.deref h pl in
B.live h pl /\
well_formed h l n /\
invariant h l n /\
ST.is_eternal_region r /\
B.(loc_includes (loc_region_only true r) (footprint h l n)) /\
B.(loc_disjoint (loc_buffer pl) (loc_region_only true r))
))
(ensures (fun h0 _ h1 ->
let n' = G.hide (x :: G.reveal n) in
let l = B.deref h1 pl in
// Style note: I don't repeat ``B.live pl`` in the post-condition since
// ``B.modifies (loc_buffer pl) h0 h1`` implies that ``B.live h1 pl``.
B.modifies (B.loc_buffer pl) h0 h1 /\
well_formed h1 l n' /\
invariant h1 l n' /\
B.(loc_includes (loc_region_only true r) (footprint h1 l n') /\
Cons? (cells h1 l n') /\ List.Tot.tail (cells h1 l n') == cells h0 (B.deref h0 pl) n /\
B.fresh_loc (B.loc_addr_of_buffer (List.Tot.hd (cells h1 l n'))) h0 h1)
))
let push #a r n pl x =
(**) let h0 = ST.get () in
let l = !* pl in
let c = { data = x; next = l } in
let pc: B.pointer (cell a) = B.malloc r c 1ul in
(**) let h1 = ST.get () in
(**) B.(modifies_only_not_unused_in loc_none h0 h1);
(**) assert B.(loc_disjoint (loc_buffer pc) (footprint h0 l n));
pl *= pc;
(**) let h2 = ST.get () in
(**) let n' = G.hide (x :: G.reveal n) in
(**) B.(modifies_trans loc_none h0 h1 (loc_buffer pl) h2);
(**) assert (well_formed h2 (B.deref h2 pl) n');
(**) assert (invariant h2 (B.deref h2 pl) n');
(**) assert ((B.deref h2 (B.deref h2 pl)).next == l);
()
val pop: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) ->
ST a
(requires (fun h ->
let l = B.deref h pl in
B.live h pl /\
well_formed h l n /\
invariant h l n /\
ST.is_eternal_region r /\
B.(loc_includes (loc_region_only true r) (footprint h l n)) /\
B.loc_disjoint (B.loc_buffer pl) (footprint h l n) /\
Cons? n
))
(ensures (fun h0 x h1 ->
let l = B.deref h1 pl in
let n' = L.tl n in
x == L.hd n /\
// Introducing a super precise modifies clause (e.g. loc_addr_of_buffer
// (B.deref h0 pl)) here is not useful and prevents trigger-based
// reasoning, while also requiring clients to unroll footprint. There's a
// tension here between revealing that ``pop`` does nothing stupid (e.g.
// re-allocating all the list cells) and providing an abstract enough
// predicate to work with.
B.(modifies (loc_buffer pl `loc_union` footprint h0 (B.deref h0 pl) n) h0 h1) /\
well_formed h1 l n' /\
invariant h1 l n' /\
B.(loc_includes (loc_region_only true r) (footprint h1 l n')) /\
List.Tot.tail (cells h0 (B.deref h0 pl) n) == cells h1 l n'))
let pop #a r n pl =
let l = !* pl in
let r = (!*l).data in
let next = (!*l).next in
(**) let h1 = ST.get () in
(**) assert (cells h1 l n == l :: cells h1 next (List.Tot.tl n));
(**) assert B.(loc_disjoint (loc_buffer pl) (footprint h1 l n));
(**) assert B.(loc_disjoint (loc_buffer pl) (footprint h1 next (List.Tot.tl n)));
pl *= next;
B.free l;
r
val free_: (#a: Type) -> (#n: G.erased (list a)) -> (l: t a) ->
ST unit
(requires (fun h ->
well_formed h l n /\
invariant h l n
))
(ensures (fun h0 _ h1 ->
B.(modifies (footprint h0 l n) h0 h1)))
let rec free_ #a #n l =
if B.is_null l then
()
else begin
let tl: G.erased (list a) = G.hide (L.tl (G.reveal n)) in
free_ #_ #tl (!*l).next;
B.free l
end
val free: (#a: Type) -> (#n: G.erased (list a)) -> (pl: B.pointer (t a)) ->
ST unit
(requires (fun h ->
let l = B.deref h pl in
B.live h pl /\
well_formed h l n /\
invariant h l n /\
B.loc_disjoint (B.loc_buffer pl) (footprint h l n)
))
(ensures (fun h0 _ h1 ->
let l = B.deref h1 pl in
well_formed h1 l [] /\
invariant h1 l [] /\
footprint h1 l [] == B.loc_none /\
cells h1 l [] == [] /\
B.(modifies (footprint h0 (B.deref h0 pl) n `loc_union` loc_buffer pl) h0 h1))) | {
"checked_file": "/",
"dependencies": [
"TestLib.fsti.checked",
"prims.fst.checked",
"LowStar.Failure.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int32.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Lib.LinkedList.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | pl: LowStar.Buffer.pointer (LowStar.Lib.LinkedList.t a) -> FStar.HyperStack.ST.ST Prims.unit | FStar.HyperStack.ST.ST | [] | [] | [
"FStar.Ghost.erased",
"Prims.list",
"LowStar.Buffer.pointer",
"LowStar.Lib.LinkedList.t",
"LowStar.BufferOps.op_Star_Equals",
"LowStar.Buffer.trivial_preorder",
"LowStar.Buffer.null",
"LowStar.Lib.LinkedList.cell",
"Prims.unit",
"LowStar.Lib.LinkedList.free_",
"LowStar.BufferOps.op_Bang_Star"
] | [] | false | true | false | false | false | let free #a #n pl =
| free_ #_ #n !*pl;
pl *= B.null | false |
LowParse.SLow.FLData.fst | LowParse.SLow.FLData.parse32_fldata_strong | val parse32_fldata_strong
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(p32: parser32 p)
(sz: nat)
(sz32: U32.t{U32.v sz32 == sz})
: Tot (parser32 (parse_fldata_strong s sz)) | val parse32_fldata_strong
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(p32: parser32 p)
(sz: nat)
(sz32: U32.t{U32.v sz32 == sz})
: Tot (parser32 (parse_fldata_strong s sz)) | let parse32_fldata_strong
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(p32: parser32 p)
(sz: nat)
(sz32: U32.t { U32.v sz32 == sz } )
: Tot (parser32 (parse_fldata_strong s sz))
= (fun (input: bytes32) -> ((
match parse32_fldata p32 sz sz32 input with
| Some (v, consumed) ->
assert (
parse_fldata_strong_correct s sz (B32.reveal input) (U32.v consumed) v;
Seq.length (s v) == sz
);
Some ((v <: parse_fldata_strong_t s sz), consumed)
| None -> None
)
<: (res: option (parse_fldata_strong_t s sz * U32.t) { parser32_correct (parse_fldata_strong s sz) input res } ))) | {
"file_name": "src/lowparse/LowParse.SLow.FLData.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 118,
"end_line": 51,
"start_col": 0,
"start_line": 32
} | module LowParse.SLow.FLData
include LowParse.Spec.FLData
include LowParse.SLow.Combinators
module B32 = LowParse.Bytes32
module U32 = FStar.UInt32
inline_for_extraction
let parse32_fldata
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(sz: nat)
(sz32: U32.t { U32.v sz32 == sz } )
: Tot (parser32 (parse_fldata p sz))
= (fun (input: bytes32) -> ((
if U32.lt (B32.len input) sz32
then
None
else
match p32 (B32.b32slice input 0ul sz32) with
| Some (v, consumed) ->
if consumed = sz32
then begin
Some (v, consumed)
end else None
| None -> None
) <: (res: option (t * U32.t) { parser32_correct (parse_fldata p sz) input res } ))) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.FLData.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.FLData",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
s: LowParse.Spec.Base.serializer p ->
p32: LowParse.SLow.Base.parser32 p ->
sz: Prims.nat ->
sz32: FStar.UInt32.t{FStar.UInt32.v sz32 == sz}
-> LowParse.SLow.Base.parser32 (LowParse.Spec.FLData.parse_fldata_strong s sz) | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Base.serializer",
"LowParse.SLow.Base.parser32",
"Prims.nat",
"FStar.UInt32.t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt32.n",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt32.v",
"LowParse.SLow.Base.bytes32",
"LowParse.SLow.FLData.parse32_fldata",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.FLData.parse_fldata_strong_t",
"FStar.Pervasives.Native.Mktuple2",
"Prims.unit",
"Prims._assert",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"LowParse.Spec.FLData.parse_fldata_strong_correct",
"FStar.Bytes.reveal",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option",
"LowParse.SLow.Base.parser32_correct",
"LowParse.Spec.FLData.parse_fldata_kind",
"LowParse.Spec.FLData.parse_fldata_strong"
] | [] | false | false | false | false | false | let parse32_fldata_strong
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(p32: parser32 p)
(sz: nat)
(sz32: U32.t{U32.v sz32 == sz})
: Tot (parser32 (parse_fldata_strong s sz)) =
| (fun (input: bytes32) ->
((match parse32_fldata p32 sz sz32 input with
| Some (v, consumed) ->
assert (parse_fldata_strong_correct s sz (B32.reveal input) (U32.v consumed) v;
Seq.length (s v) == sz);
Some ((v <: parse_fldata_strong_t s sz), consumed)
| None -> None)
<:
(res:
option (parse_fldata_strong_t s sz * U32.t)
{parser32_correct (parse_fldata_strong s sz) input res}))) | false |
LowParse.SLow.FLData.fst | LowParse.SLow.FLData.serialize32_fldata_strong | val serialize32_fldata_strong
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(#s: serializer p)
(s32: partial_serializer32 s)
(sz: nat{sz < 4294967296})
: Tot (serializer32 (serialize_fldata_strong s sz)) | val serialize32_fldata_strong
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(#s: serializer p)
(s32: partial_serializer32 s)
(sz: nat{sz < 4294967296})
: Tot (serializer32 (serialize_fldata_strong s sz)) | let serialize32_fldata_strong
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(#s: serializer p)
(s32: partial_serializer32 s)
(sz: nat { sz < 4294967296 } )
: Tot (serializer32 (serialize_fldata_strong s sz))
= (fun (input: parse_fldata_strong_t s sz) -> s32 input) | {
"file_name": "src/lowparse/LowParse.SLow.FLData.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 56,
"end_line": 62,
"start_col": 0,
"start_line": 54
} | module LowParse.SLow.FLData
include LowParse.Spec.FLData
include LowParse.SLow.Combinators
module B32 = LowParse.Bytes32
module U32 = FStar.UInt32
inline_for_extraction
let parse32_fldata
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(sz: nat)
(sz32: U32.t { U32.v sz32 == sz } )
: Tot (parser32 (parse_fldata p sz))
= (fun (input: bytes32) -> ((
if U32.lt (B32.len input) sz32
then
None
else
match p32 (B32.b32slice input 0ul sz32) with
| Some (v, consumed) ->
if consumed = sz32
then begin
Some (v, consumed)
end else None
| None -> None
) <: (res: option (t * U32.t) { parser32_correct (parse_fldata p sz) input res } )))
inline_for_extraction
let parse32_fldata_strong
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(p32: parser32 p)
(sz: nat)
(sz32: U32.t { U32.v sz32 == sz } )
: Tot (parser32 (parse_fldata_strong s sz))
= (fun (input: bytes32) -> ((
match parse32_fldata p32 sz sz32 input with
| Some (v, consumed) ->
assert (
parse_fldata_strong_correct s sz (B32.reveal input) (U32.v consumed) v;
Seq.length (s v) == sz
);
Some ((v <: parse_fldata_strong_t s sz), consumed)
| None -> None
)
<: (res: option (parse_fldata_strong_t s sz * U32.t) { parser32_correct (parse_fldata_strong s sz) input res } ))) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.FLData.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.FLData",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s32: LowParse.SLow.Base.partial_serializer32 s -> sz: Prims.nat{sz < 4294967296}
-> LowParse.SLow.Base.serializer32 (LowParse.Spec.FLData.serialize_fldata_strong s sz) | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Base.serializer",
"LowParse.SLow.Base.partial_serializer32",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"LowParse.Spec.FLData.parse_fldata_strong_t",
"LowParse.SLow.Base.bytes32",
"LowParse.SLow.Base.serializer32_correct",
"LowParse.Spec.FLData.parse_fldata_kind",
"LowParse.Spec.FLData.parse_fldata_strong",
"LowParse.Spec.FLData.serialize_fldata_strong",
"LowParse.SLow.Base.serializer32"
] | [] | false | false | false | false | false | let serialize32_fldata_strong
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(#s: serializer p)
(s32: partial_serializer32 s)
(sz: nat{sz < 4294967296})
: Tot (serializer32 (serialize_fldata_strong s sz)) =
| (fun (input: parse_fldata_strong_t s sz) -> s32 input) | false |
LowStar.Lib.LinkedList.fst | LowStar.Lib.LinkedList.pop | val pop: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) ->
ST a
(requires (fun h ->
let l = B.deref h pl in
B.live h pl /\
well_formed h l n /\
invariant h l n /\
ST.is_eternal_region r /\
B.(loc_includes (loc_region_only true r) (footprint h l n)) /\
B.loc_disjoint (B.loc_buffer pl) (footprint h l n) /\
Cons? n
))
(ensures (fun h0 x h1 ->
let l = B.deref h1 pl in
let n' = L.tl n in
x == L.hd n /\
// Introducing a super precise modifies clause (e.g. loc_addr_of_buffer
// (B.deref h0 pl)) here is not useful and prevents trigger-based
// reasoning, while also requiring clients to unroll footprint. There's a
// tension here between revealing that ``pop`` does nothing stupid (e.g.
// re-allocating all the list cells) and providing an abstract enough
// predicate to work with.
B.(modifies (loc_buffer pl `loc_union` footprint h0 (B.deref h0 pl) n) h0 h1) /\
well_formed h1 l n' /\
invariant h1 l n' /\
B.(loc_includes (loc_region_only true r) (footprint h1 l n')) /\
List.Tot.tail (cells h0 (B.deref h0 pl) n) == cells h1 l n')) | val pop: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) ->
ST a
(requires (fun h ->
let l = B.deref h pl in
B.live h pl /\
well_formed h l n /\
invariant h l n /\
ST.is_eternal_region r /\
B.(loc_includes (loc_region_only true r) (footprint h l n)) /\
B.loc_disjoint (B.loc_buffer pl) (footprint h l n) /\
Cons? n
))
(ensures (fun h0 x h1 ->
let l = B.deref h1 pl in
let n' = L.tl n in
x == L.hd n /\
// Introducing a super precise modifies clause (e.g. loc_addr_of_buffer
// (B.deref h0 pl)) here is not useful and prevents trigger-based
// reasoning, while also requiring clients to unroll footprint. There's a
// tension here between revealing that ``pop`` does nothing stupid (e.g.
// re-allocating all the list cells) and providing an abstract enough
// predicate to work with.
B.(modifies (loc_buffer pl `loc_union` footprint h0 (B.deref h0 pl) n) h0 h1) /\
well_formed h1 l n' /\
invariant h1 l n' /\
B.(loc_includes (loc_region_only true r) (footprint h1 l n')) /\
List.Tot.tail (cells h0 (B.deref h0 pl) n) == cells h1 l n')) | let pop #a r n pl =
let l = !* pl in
let r = (!*l).data in
let next = (!*l).next in
(**) let h1 = ST.get () in
(**) assert (cells h1 l n == l :: cells h1 next (List.Tot.tl n));
(**) assert B.(loc_disjoint (loc_buffer pl) (footprint h1 l n));
(**) assert B.(loc_disjoint (loc_buffer pl) (footprint h1 next (List.Tot.tl n)));
pl *= next;
B.free l;
r | {
"file_name": "krmllib/LowStar.Lib.LinkedList.fst",
"git_rev": "da1e941b2fcb196aa5d1e34941aa00b4c67ac321",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} | {
"end_col": 3,
"end_line": 412,
"start_col": 0,
"start_line": 401
} | module LowStar.Lib.LinkedList
/// This module, oftentimes referred to as LL1 in other parts of the
/// documentation, provides a low-level view over a linked list. Unless you
/// intend on modifying the structure of the linked list (e.g. removing cells)
/// or iterating over each cell, your are probably better off using LL2.
///
/// This module is intentionally not relying on a tight abstraction, to i) permit
/// direct-style iteration by clients and ii) allow stating some SMTPat lemmas
/// only on LL1 rather than replicating them in LL2 (going from LL2 to LL1 can
/// happen automatically at the SMT level since LL2 does not have an fsti either).
///
/// Some open questions relative to the design of this module:
/// - should ``v`` be defined directly in terms of ``cells`` rather than have a
/// recursive definition along with an equivalence lemma?
/// - should ``footprint`` be defined directly in terms of ``cells`` rather than
/// have a recursive definition along with an equivalence lemma?
/// - is it worth the trouble defining a footprint? my intuition is that it's
/// fine and allows some clients to do very precise reasoning -- other modules
/// (e.g. AssocList), when establishing abstraction boundaries, can simplify
/// things and get rid of the precise footprint reasoning in favor of a static
/// region-based footprint
///
/// Some remaining work items:
/// - switch to C.Loops.while
open LowStar.BufferOps
module B = LowStar.Buffer
module HS = FStar.HyperStack
module G = FStar.Ghost
module L = FStar.List.Tot
module U32 = FStar.UInt32
module ST = FStar.HyperStack.ST
open FStar.HyperStack.ST
/// Breaking from my own recommendation here... using fuel 1 / ifuel 1 since
/// everything does recursive list reasoning.
#set-options "--__no_positivity --fuel 1 --ifuel 1"
/// Definition of the Low* type
/// ---------------------------
noeq
type t (a: Type0) =
B.pointer_or_null (cell a)
and cell (a: Type0) = {
next: t a;
data: a;
}
/// Unlike the canonical style that associates a ``v`` function to any stateful
/// representation, we use a relation here. Writing a function is just
/// impossible, since we can't prove termination of ``v`` owing to the fact that
/// there may be an infinite number of cells in the heap.
///
/// LL2 is the module that switches to the function style.
///
/// Note: no need to use erased here for ``l`` since the function is already in ``GTot``.
let rec well_formed #a (h: HS.mem) (c: t a) (l: list a): GTot Type0 (decreases l) =
B.live h c /\ (
match l with
| [] ->
B.g_is_null c
| a :: q ->
B.length c == 1 /\ (
let { data=data; next=next } = B.get h c 0 in
a == data /\
well_formed h next (G.hide q)
))
/// Precise reasoning via the cells predicate
/// -----------------------------------------
///
/// The modifies clauses are given either on the footprint of the list, or on a
/// region that includes the footprint of the list (higher up the stack, e.g.
/// LL2). This is good, but does not rule out "stupid" implementations that
/// might re-allocate every single list cell when, say, doing a pop.
///
/// For advanced usages which take pointers directly to individual list cells,
/// it's important to rule out these cases. We thus define the ``cells``
/// predicate for that purpose.
let rec cells #a (h: HS.mem) (c: t a) (l: list a): Ghost (list (B.pointer (cell a)))
(requires well_formed h c l)
(ensures fun _ -> True)
(decreases l)
=
if B.g_is_null c then
[]
else
c :: cells h (B.deref h c).next (List.Tot.tl l)
/// A missing bit of automated reasoning
/// ------------------------------------
/// This should be absolutely trivial, yet, because there's no pattern on
/// null_unique, we have to do the case analysis and the decomposition
/// ourselves. This is quite tedious, as it usually takes a while (at least it
/// did for me!) to realize that this property does not hold automatically.
///
/// I'm setting an SMTPat on this lemma because it's absolutely impossible to
/// get any work done without it.
let same_cells_same_pointer #a (h0 h1: HS.mem) (ll0 ll1: t a) (l0 l1: list a): Lemma
(requires (
well_formed h0 ll0 l0 /\
well_formed h1 ll1 l1 /\
cells h0 ll0 l0 == cells h1 ll1 l1))
(ensures (
ll0 == ll1))
[ SMTPat (cells h0 ll0 l0); SMTPat (cells h1 ll1 l1) ]
=
if B.g_is_null ll0 && B.g_is_null ll1 then begin
B.null_unique ll0;
B.null_unique ll1
end else if not (B.g_is_null ll0) && not (B.g_is_null ll1) then begin
()
end else
false_elim ()
/// Classic stateful reasoning lemmas
/// ---------------------------------
///
/// This essentially follows ``stateful``, the type class of a mutable piece of
/// state defined using the modifies-theory of Low*v2 and equipped with the
/// right lemmas to enable usage by clients. See
/// hacl-star/code/streaming/Hacl.Streaming.Interface.fst for more context.
val footprint: (#a: Type) -> (h: HS.mem) -> (l: t a) -> (n: list a) -> Ghost B.loc
(requires (well_formed h l n))
(ensures (fun refs -> True))
(decreases n)
let rec footprint #a h l n =
if B.g_is_null l
then B.loc_none
else
let {next = next} = B.get h l 0 in
let refs = footprint h next (G.hide (L.tl n)) in
B.loc_union (B.loc_addr_of_buffer l) refs
/// Departing from LinkedList4 here. I prefer to bolt these into the invariant
/// rather than requiring on some wizard lemmas from LowStar.Monotonic.Buffer to
/// deduce these.
val cells_pairwise_disjoint: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_pairwise_disjoint #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.loc_disjoint (B.loc_addr_of_buffer l) (footprint h next (L.tl n)) /\
cells_pairwise_disjoint h next (L.tl n)
val cells_live_freeable: #a:Type -> h:HS.mem -> l:t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let rec cells_live_freeable #_ h l n =
if B.g_is_null l then
True
else
let next = (B.deref h l).next in
B.live h l /\ B.freeable l /\
cells_live_freeable h next (L.tl n)
val invariant: #a:Type -> h:HS.mem -> l: t a -> n:list a -> Ghost Type0
(requires well_formed h l n)
(ensures fun _ -> True)
(decreases n)
let invariant #a h l n =
cells_live_freeable h l n /\ cells_pairwise_disjoint h l n
/// Normally this would be automatic and writing a custom lemma for that stuff
/// would be needed only when writing an fsti, however, as stated earlier,
/// recursion makes everything more difficult and this absolutely needs to be in
/// scope otherwise the modifies-clause theory cannot deduce disjointness of
/// fresh allocations w.r.t. the footprint.
let rec invariant_loc_in_footprint (#a: Type) (h: HS.mem) (l: t a) (n: list a): Lemma
(requires well_formed h l n)
(ensures B.loc_in (footprint h l n) h)
(decreases n)
[ SMTPat (invariant h l n) ]
=
if B.g_is_null l then
()
else
let next = (B.deref h l).next in
invariant_loc_in_footprint h next (L.tl n)
/// Another absolutely essential lemma, for which interestingly the pattern
/// "invariant h1 l n" does not work, but well_formed does... I guess that's
/// alright.
let rec frame (#a: Type) (l: t a) (n: list a) (r: B.loc) (h0 h1: HS.mem): Lemma
(requires (
well_formed h0 l n /\
invariant h0 l n /\
B.loc_disjoint r (footprint h0 l n) /\
B.modifies r h0 h1
))
(ensures (
well_formed h1 l n /\
footprint h1 l n == footprint h0 l n /\
cells h1 l n == cells h0 l n /\
invariant h1 l n
))
(decreases n)
[ SMTPat (well_formed h1 l n); SMTPat (B.modifies r h0 h1) ]
=
if B.g_is_null l then
()
else
frame (B.deref h0 l).next (L.tl n) r h0 h1
/// Lemmas for working with linked lists
/// ------------------------------------
///
/// Since it's a recursive data structure, a lot of the automated reasoning from
/// LowStar.Buffer doesn't work since it requires inductions. Some helpful
/// properties are therefore proved here.
let rec length_functional #a (h: HS.mem) (c: t a) (l1 l2: list a):
Lemma
(requires (well_formed h c l1 /\ well_formed h c l2))
(ensures (l1 == l2))
(decreases (G.reveal l1))
[ SMTPat (well_formed h c l1); SMTPat (well_formed h c l2) ] =
if B.g_is_null c
then ()
else
let { next=next } = B.get h c 0 in
length_functional h next (G.hide (L.tl l1)) (G.hide (L.tl l2))
/// The footprint is based on loc_addr_of_buffer so that we can write a free
/// operation that operates on the footprint. However, this invalidates most of
/// the helper lemmas for disjointness that were present in the previous
/// iteration of this module, named LinkedList4.fst. It's ok, we bake
/// disjointness directly onto the invariant and it works just as well.
/// Connection between ``cells`` and ``v``
/// --------------------------------------
/// Redefining some helpers.
#push-options "--ifuel 1"
let rec gmap #a #b (f: a -> GTot b) (xs: list a): GTot (list b) =
match xs with
| [] -> []
| x :: xs -> f x :: gmap f xs
/// "As we all know", right folds are the easiest to work with because they
/// follow the natural structure of recursion (left-folds are evil).
let rec gfold_right #a #b (f: b -> a -> GTot b) (xs: list a) (acc: b): Ghost b
(requires True)
(ensures fun _ -> True)
(decreases xs)
=
match xs with
| [] -> acc
| x :: xs -> f (gfold_right f xs acc) x
#pop-options
/// Connecting ``v`` and ``cells``.
///
/// See ``tests/Wireguard.fst`` for why going through gmap is important and how
/// to structure your definitions (should you need to reason about ``cells``) in
/// a way that will make your life easier.
let deref_data #a (h: HS.mem) (c: B.pointer (cell a)): GTot a =
(B.deref h c).data
#push-options "--fuel 1 --ifuel 1"
let rec deref_cells_is_v #a (h: HS.mem) (ll: t a) (l: list a): Lemma
(requires
well_formed h ll l /\
invariant h ll l)
(ensures
gmap (deref_data h) (cells h ll l) == l)
(decreases l)
[ SMTPat (well_formed h ll l) ]
=
if B.g_is_null ll then
()
else
deref_cells_is_v h (B.deref h ll).next (List.Tot.tl l)
#pop-options
/// Connecting ``footprint`` and ``cells``.
///
/// This allows conveniently switching to a low-level representation of the
/// footprint in case clients want to do some ultra-precise reasoning about
/// what's happening with the list spine. However, the fact that all
/// operations from this module specify things in terms of ``cells`` along with
/// ``same_cells_same_pointer`` should cover most common cases. (This predates
/// the introduction of ``same_cells_same_pointer``.)
///
/// So, no SMTPat here. Note, I also used the same trick as above with
/// higher-order combinators to isolate the use of the argument ``h`` to a
/// single sub-term rather than having it passed down the recursive calls.
#push-options "--fuel 2 --ifuel 2"
let rec footprint_via_cells_is_footprint #a (h: HS.mem) (ll: t a) (l: list a): Lemma
(requires well_formed h ll l)
(ensures
footprint h ll l == (gfold_right B.loc_union (gmap B.loc_addr_of_buffer (cells h ll l)) B.loc_none))
(decreases l)
=
if B.g_is_null ll then
()
else
footprint_via_cells_is_footprint h (B.deref h ll).next (List.Tot.tl l)
#pop-options
/// Stateful operations
/// -------------------
///
/// One thing to note: we pass the region `r` explicitly, which is certainly not
/// very convenient, but that's alright, another layer of abstraction will take
/// care of adding existentials and extra machinery to make this more pleasant
/// to use.
///
/// All of the operations below are low-level (in the sense that they rely on
/// the predicate). I expect clients to use exclusively the variants of these
/// functions present in LL2.
val push: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) -> (x: a) ->
ST unit
(requires (fun h ->
let l = B.deref h pl in
B.live h pl /\
well_formed h l n /\
invariant h l n /\
ST.is_eternal_region r /\
B.(loc_includes (loc_region_only true r) (footprint h l n)) /\
B.(loc_disjoint (loc_buffer pl) (loc_region_only true r))
))
(ensures (fun h0 _ h1 ->
let n' = G.hide (x :: G.reveal n) in
let l = B.deref h1 pl in
// Style note: I don't repeat ``B.live pl`` in the post-condition since
// ``B.modifies (loc_buffer pl) h0 h1`` implies that ``B.live h1 pl``.
B.modifies (B.loc_buffer pl) h0 h1 /\
well_formed h1 l n' /\
invariant h1 l n' /\
B.(loc_includes (loc_region_only true r) (footprint h1 l n') /\
Cons? (cells h1 l n') /\ List.Tot.tail (cells h1 l n') == cells h0 (B.deref h0 pl) n /\
B.fresh_loc (B.loc_addr_of_buffer (List.Tot.hd (cells h1 l n'))) h0 h1)
))
let push #a r n pl x =
(**) let h0 = ST.get () in
let l = !* pl in
let c = { data = x; next = l } in
let pc: B.pointer (cell a) = B.malloc r c 1ul in
(**) let h1 = ST.get () in
(**) B.(modifies_only_not_unused_in loc_none h0 h1);
(**) assert B.(loc_disjoint (loc_buffer pc) (footprint h0 l n));
pl *= pc;
(**) let h2 = ST.get () in
(**) let n' = G.hide (x :: G.reveal n) in
(**) B.(modifies_trans loc_none h0 h1 (loc_buffer pl) h2);
(**) assert (well_formed h2 (B.deref h2 pl) n');
(**) assert (invariant h2 (B.deref h2 pl) n');
(**) assert ((B.deref h2 (B.deref h2 pl)).next == l);
()
val pop: (#a: Type) -> (r: HS.rid) -> (n: G.erased (list a)) -> (pl: B.pointer (t a)) ->
ST a
(requires (fun h ->
let l = B.deref h pl in
B.live h pl /\
well_formed h l n /\
invariant h l n /\
ST.is_eternal_region r /\
B.(loc_includes (loc_region_only true r) (footprint h l n)) /\
B.loc_disjoint (B.loc_buffer pl) (footprint h l n) /\
Cons? n
))
(ensures (fun h0 x h1 ->
let l = B.deref h1 pl in
let n' = L.tl n in
x == L.hd n /\
// Introducing a super precise modifies clause (e.g. loc_addr_of_buffer
// (B.deref h0 pl)) here is not useful and prevents trigger-based
// reasoning, while also requiring clients to unroll footprint. There's a
// tension here between revealing that ``pop`` does nothing stupid (e.g.
// re-allocating all the list cells) and providing an abstract enough
// predicate to work with.
B.(modifies (loc_buffer pl `loc_union` footprint h0 (B.deref h0 pl) n) h0 h1) /\
well_formed h1 l n' /\
invariant h1 l n' /\
B.(loc_includes (loc_region_only true r) (footprint h1 l n')) /\
List.Tot.tail (cells h0 (B.deref h0 pl) n) == cells h1 l n')) | {
"checked_file": "/",
"dependencies": [
"TestLib.fsti.checked",
"prims.fst.checked",
"LowStar.Failure.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int32.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "LowStar.Lib.LinkedList.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
r: FStar.Monotonic.HyperHeap.rid ->
n: FStar.Ghost.erased (Prims.list a) ->
pl: LowStar.Buffer.pointer (LowStar.Lib.LinkedList.t a)
-> FStar.HyperStack.ST.ST a | FStar.HyperStack.ST.ST | [] | [] | [
"FStar.Monotonic.HyperHeap.rid",
"FStar.Ghost.erased",
"Prims.list",
"LowStar.Buffer.pointer",
"LowStar.Lib.LinkedList.t",
"Prims.unit",
"LowStar.Monotonic.Buffer.free",
"LowStar.Lib.LinkedList.cell",
"LowStar.Buffer.trivial_preorder",
"LowStar.BufferOps.op_Star_Equals",
"Prims._assert",
"LowStar.Monotonic.Buffer.loc_disjoint",
"LowStar.Monotonic.Buffer.loc_buffer",
"LowStar.Lib.LinkedList.footprint",
"FStar.List.Tot.Base.tl",
"FStar.Ghost.reveal",
"Prims.eq2",
"LowStar.Lib.LinkedList.cells",
"Prims.Cons",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"LowStar.Buffer.pointer_or_null",
"LowStar.Lib.LinkedList.__proj__Mkcell__item__next",
"LowStar.BufferOps.op_Bang_Star",
"LowStar.Lib.LinkedList.__proj__Mkcell__item__data"
] | [] | false | true | false | false | false | let pop #a r n pl =
| let l = !*pl in
let r = (!*l).data in
let next = (!*l).next in
let h1 = ST.get () in
assert (cells h1 l n == l :: cells h1 next (List.Tot.tl n));
assert B.(loc_disjoint (loc_buffer pl) (footprint h1 l n));
assert B.(loc_disjoint (loc_buffer pl) (footprint h1 next (List.Tot.tl n)));
pl *= next;
B.free l;
r | false |
LowParse.SLow.FLData.fst | LowParse.SLow.FLData.parse32_fldata | val parse32_fldata
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(sz: nat)
(sz32: U32.t{U32.v sz32 == sz})
: Tot (parser32 (parse_fldata p sz)) | val parse32_fldata
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(sz: nat)
(sz32: U32.t{U32.v sz32 == sz})
: Tot (parser32 (parse_fldata p sz)) | let parse32_fldata
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(sz: nat)
(sz32: U32.t { U32.v sz32 == sz } )
: Tot (parser32 (parse_fldata p sz))
= (fun (input: bytes32) -> ((
if U32.lt (B32.len input) sz32
then
None
else
match p32 (B32.b32slice input 0ul sz32) with
| Some (v, consumed) ->
if consumed = sz32
then begin
Some (v, consumed)
end else None
| None -> None
) <: (res: option (t * U32.t) { parser32_correct (parse_fldata p sz) input res } ))) | {
"file_name": "src/lowparse/LowParse.SLow.FLData.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 86,
"end_line": 29,
"start_col": 0,
"start_line": 9
} | module LowParse.SLow.FLData
include LowParse.Spec.FLData
include LowParse.SLow.Combinators
module B32 = LowParse.Bytes32
module U32 = FStar.UInt32 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.FLData.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.FLData.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.FLData",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
p32: LowParse.SLow.Base.parser32 p ->
sz: Prims.nat ->
sz32: FStar.UInt32.t{FStar.UInt32.v sz32 == sz}
-> LowParse.SLow.Base.parser32 (LowParse.Spec.FLData.parse_fldata p sz) | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.SLow.Base.parser32",
"Prims.nat",
"FStar.UInt32.t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt32.n",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt32.v",
"LowParse.SLow.Base.bytes32",
"FStar.UInt32.lt",
"FStar.Bytes.len",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.tuple2",
"Prims.bool",
"LowParse.Bytes32.b32slice",
"FStar.UInt32.__uint_to_t",
"Prims.op_Equality",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.option",
"LowParse.SLow.Base.parser32_correct",
"LowParse.Spec.FLData.parse_fldata_kind",
"LowParse.Spec.FLData.parse_fldata"
] | [] | false | false | false | false | false | let parse32_fldata
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(p32: parser32 p)
(sz: nat)
(sz32: U32.t{U32.v sz32 == sz})
: Tot (parser32 (parse_fldata p sz)) =
| (fun (input: bytes32) ->
((if U32.lt (B32.len input) sz32
then None
else
match p32 (B32.b32slice input 0ul sz32) with
| Some (v, consumed) -> if consumed = sz32 then Some (v, consumed) else None
| None -> None)
<:
(res: option (t * U32.t) {parser32_correct (parse_fldata p sz) input res}))) | false |
AlgHeap.fst | AlgHeap.handle_with | val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1 | val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1 | let handle_with f v h = fold_with f v h | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 39,
"end_line": 144,
"start_col": 0,
"start_line": 144
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | f: AlgHeap.tree a labs0 -> v: (_: a -> AlgHeap.tree b labs1) -> h: AlgHeap.handler_ty labs0 b labs1
-> AlgHeap.tree b labs1 | Prims.Tot | [
"total"
] | [] | [
"AlgHeap.ops",
"AlgHeap.tree",
"AlgHeap.handler_ty",
"AlgHeap.fold_with"
] | [] | false | false | false | false | false | let handle_with f v h =
| fold_with f v h | false |
AlgHeap.fst | AlgHeap.handler_ty_l | val handler_ty_l : o: AlgHeap.op -> b: Type -> labs: AlgHeap.ops -> Type | let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 54,
"end_line": 132,
"start_col": 0,
"start_line": 131
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k' | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | o: AlgHeap.op -> b: Type -> labs: AlgHeap.ops -> Type | Prims.Tot | [
"total"
] | [] | [
"AlgHeap.op",
"AlgHeap.ops",
"AlgHeap.op_inp",
"AlgHeap.op_out",
"AlgHeap.tree"
] | [] | false | false | false | true | true | let handler_ty_l (o: op) (b: Type) (labs: ops) =
| op_inp o -> (op_out o -> tree b labs) -> tree b labs | false |
|
Pulse.Checker.Base.fst | Pulse.Checker.Base.match_comp_res_with_post_hint | val match_comp_res_with_post_hint (#g:env) (#t:st_term) (#c:comp_st)
(d:st_typing g t c)
(post_hint:post_hint_opt g)
: T.Tac (t':st_term &
c':comp_st &
st_typing g t' c') | val match_comp_res_with_post_hint (#g:env) (#t:st_term) (#c:comp_st)
(d:st_typing g t c)
(post_hint:post_hint_opt g)
: T.Tac (t':st_term &
c':comp_st &
st_typing g t' c') | let match_comp_res_with_post_hint (#g:env) (#t:st_term) (#c:comp_st)
(d:st_typing g t c)
(post_hint:post_hint_opt g)
: T.Tac (t':st_term &
c':comp_st &
st_typing g t' c') =
match post_hint with
| None -> (| t, c, d |)
| Some { ret_ty } ->
let cres = comp_res c in
if eq_tm cres ret_ty
then (| t, c, d |)
else match Pulse.Checker.Pure.check_equiv g cres ret_ty with
| None ->
fail g (Some t.range)
(Printf.sprintf "Could not prove equiv for computed type %s and expected type %s"
(P.term_to_string cres)
(P.term_to_string ret_ty))
| Some tok ->
let d_equiv
: RT.equiv _ (elab_term cres) (elab_term ret_ty) =
RT.Rel_eq_token _ _ _ (FStar.Squash.return_squash tok) in
let c' = with_st_comp c {(st_comp_of_comp c) with res = ret_ty } in
let (| cres_typing, cpre_typing, x, cpost_typing |) =
st_comp_typing_inversion (fst <| comp_typing_inversion (st_typing_correctness d)) in
let d_stequiv : st_equiv g c c' =
ST_VPropEquiv _ c c' _ cpre_typing cres_typing cpost_typing d_equiv (VE_Refl _ _) (VE_Refl _ _)
in
(| t, c', T_Equiv _ _ _ _ d d_stequiv |) | {
"file_name": "lib/steel/pulse/Pulse.Checker.Base.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 51,
"end_line": 616,
"start_col": 0,
"start_line": 584
} | (*
Copyright 2023 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Pulse.Checker.Base
module T = FStar.Tactics.V2
module RT = FStar.Reflection.Typing
module Metatheory = Pulse.Typing.Metatheory
module CP = Pulse.Checker.Pure
module RU = Pulse.RuntimeUtils
module FV = Pulse.Typing.FV
module P = Pulse.Syntax.Printer
open Pulse.Typing.Combinators
open Pulse.Typing.Metatheory
let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit =
if RU.debug_at_level (fstar_env g) "pulse.checker" then
T.print (f())
let format_failed_goal (g:env) (ctxt:list term) (goal:list term) =
let terms_to_strings (ts:list term)= T.map Pulse.Syntax.Printer.term_to_string ts in
let numbered_list ss =
let _, s = T.fold_left (fun (i, acc) s -> (i+1, Printf.sprintf "%d. %s" i s :: acc)) (1, []) ss in
String.concat "\n " (List.rev s)
in
let format_terms (ts:list term) = numbered_list (terms_to_strings ts) in
Printf.sprintf
"Failed to prove the following goals:\n \
%s\n\
The remaining conjuncts in the separation logic context available for use are:\n \
%s\n\
The typing context is:\n \
%s\n"
(format_terms goal)
(format_terms ctxt)
(env_to_string g)
let mk_arrow ty t = RT.mk_arrow (elab_term ty) T.Q_Explicit (elab_term t)
let mk_abs ty t = RT.(mk_abs (elab_term ty) T.Q_Explicit (elab_term t))
let intro_comp_typing (g:env)
(c:comp_st)
(pre_typing:tot_typing g (comp_pre c) tm_vprop)
(i_typing:effect_annot_typing g (effect_annot_of_comp c))
(res_typing:universe_of g (comp_res c) (comp_u c))
(x:var { fresh_wrt x g (freevars (comp_post c)) })
(post_typing:tot_typing (push_binding g x ppname_default (comp_res c)) (open_term (comp_post c) x) tm_vprop)
: T.Tac (comp_typing g c (universe_of_comp c))
= let intro_st_comp_typing (st:st_comp { comp_u c == st.u /\
comp_pre c == st.pre /\
comp_res c == st.res /\
comp_post c == st.post } )
: T.Tac (st_comp_typing g st)
= STC g st x res_typing pre_typing post_typing
in
match c with
| C_ST st ->
let stc = intro_st_comp_typing st in
CT_ST _ _ stc
| C_STAtomic i obs st ->
let stc = intro_st_comp_typing st in
CT_STAtomic _ i obs _ i_typing stc
| C_STGhost st ->
let stc = intro_st_comp_typing st in
CT_STGhost _ _ stc
irreducible
let post_typing_as_abstraction
(#g:env) (#x:var) (#ty:term) (#t:term { fresh_wrt x g (freevars t) })
(_:tot_typing (push_binding g x ppname_default ty) (open_term t x) tm_vprop)
: FStar.Ghost.erased (RT.tot_typing (elab_env g) (mk_abs ty t) (mk_arrow ty tm_vprop))
= admit()
let check_effect_annot (g:env) (e:effect_annot) : T.Tac (effect_annot_typing g e) =
match e with
| EffectAnnotSTT
| EffectAnnotGhost -> ()
| EffectAnnotAtomic { opens } ->
CP.core_check_term g opens T.E_Total tm_inames
let intro_post_hint g effect_annot ret_ty_opt post =
let x = fresh g in
let ret_ty =
match ret_ty_opt with
| None -> tm_fstar RT.unit_ty FStar.Range.range_0
| Some t -> t
in
let ret_ty, _ = CP.instantiate_term_implicits g ret_ty in
let (| u, ty_typing |) = CP.check_universe g ret_ty in
let (| post, post_typing |) = CP.check_vprop (push_binding g x ppname_default ret_ty) (open_term_nv post (v_as_nv x)) in
let post' = close_term post x in
Pulse.Typing.FV.freevars_close_term post x 0;
let effect_annot_typing = check_effect_annot g effect_annot in
assume (open_term post' x == post);
{ g;
effect_annot;
effect_annot_typing;
ret_ty; u; ty_typing;
post=post';
x; post_typing_src=post_typing;
post_typing=post_typing_as_abstraction #_ #_ #_ #post' post_typing }
let comp_typing_as_effect_annot_typing (#g:env) (#c:comp_st) (ct:comp_typing_u g c)
: effect_annot_typing g (effect_annot_of_comp c)
= let _, iname_typing = Metatheory.comp_typing_inversion ct in
match c with
| C_ST _ -> ()
| C_STGhost _ -> ()
| C_STAtomic opens obs _ -> iname_typing
let post_hint_from_comp_typing #g #c ct =
let st_comp_typing, _ = Metatheory.comp_typing_inversion ct in
let (| ty_typing, pre_typing, x, post_typing |) = Metatheory.st_comp_typing_inversion st_comp_typing in
let effect_annot_typing = comp_typing_as_effect_annot_typing ct in
let p : post_hint_t =
{ g;
effect_annot=_;
effect_annot_typing;
ret_ty = comp_res c; u=comp_u c;
ty_typing=ty_typing;
post=comp_post c;
x;
post_typing_src=post_typing;
post_typing=post_typing_as_abstraction post_typing }
in
p
let comp_typing_from_post_hint
(#g: env)
(c: comp_st)
(pre_typing: tot_typing g (comp_pre c) tm_vprop)
(p:post_hint_for_env g { comp_post_matches_hint c (Some p) })
: T.Tac (comp_typing_u g c)
= let x = fresh g in
if x `Set.mem` freevars p.post //exclude this
then fail g None "Impossible: unexpected freevar in post, please file a bug-report"
else let post_typing = post_hint_typing g p x in
intro_comp_typing g c pre_typing
post_typing.effect_annot_typing
post_typing.ty_typing
x post_typing.post_typing
let extend_post_hint g p x tx conjunct conjunct_typing =
let g' = push_binding g x ppname_default tx in
let y = fresh g' in
let g'' = push_binding g' y ppname_default p.ret_ty in
let p_post_typing_src
: tot_typing (push_binding p.g p.x ppname_default p.ret_ty)
(open_term p.post p.x) tm_vprop
= p.post_typing_src
in
let p_post_typing_src''
: tot_typing g'' (open_term p.post y) tm_vprop
= RU.magic () //weaken, rename
in
let conjunct_typing'
: tot_typing g' conjunct tm_vprop
= conjunct_typing
in
let conjunct_typing''
: tot_typing g'' (open_term conjunct y) tm_vprop
= RU.magic () //weaken
in
let new_post = tm_star p.post conjunct in
let new_post_typing
: tot_typing g'' (open_term new_post y) tm_vprop
= Pulse.Typing.star_typing p_post_typing_src'' conjunct_typing''
in
assume (fresh_wrt y g'' (freevars new_post));
let new_post_abs_typing
: Ghost.erased (RT.tot_typing (elab_env g'') (mk_abs p.ret_ty new_post) (mk_arrow p.ret_ty tm_vprop))
= post_typing_as_abstraction new_post_typing
in
{ p with
g=g';
post=new_post;
x=y;
post_typing_src=new_post_typing;
post_typing=new_post_abs_typing }
let k_elab_unit (g:env) (ctxt:term)
: continuation_elaborator g ctxt g ctxt
= fun p r -> r
let k_elab_trans
(#g0:env) (#g1:env { g1 `env_extends` g0 }) (#g2:env { g2 `env_extends` g1 }) (#ctxt0 #ctxt1 #ctxt2:term)
(k0:continuation_elaborator g0 ctxt0 g1 ctxt1)
(k1:continuation_elaborator g1 ctxt1 g2 ctxt2 { g1 `env_extends` g0})
: continuation_elaborator g0 ctxt0 g2 ctxt2
= fun post_hint res -> k0 post_hint (k1 post_hint res)
let comp_st_with_post (c:comp_st) (post:term)
: c':comp_st { st_comp_of_comp c' == ({ st_comp_of_comp c with post} <: st_comp) } =
match c with
| C_ST st -> C_ST { st with post }
| C_STGhost st -> C_STGhost { st with post }
| C_STAtomic i obs st -> C_STAtomic i obs {st with post}
let ve_unit_r g (p:term) : vprop_equiv g (tm_star p tm_emp) p =
VE_Trans _ _ _ _ (VE_Comm _ _ _) (VE_Unit _ _)
let st_equiv_trans (#g:env) (#c0 #c1 #c2:comp) (d01:st_equiv g c0 c1) (d12:st_equiv g c1 c2)
: option (st_equiv g c0 c2)
=
match d01 with
| ST_VPropEquiv _f _c0 _c1 x c0_pre_typing c0_res_typing c0_post_typing eq_res_01 eq_pre_01 eq_post_01 -> (
let ST_VPropEquiv _f _c1 _c2 y c1_pre_typing c1_res_typing c1_post_typing eq_res_12 eq_pre_12 eq_post_12 = d12 in
if x = y && eq_tm (comp_res c0) (comp_res c1)
then Some (
ST_VPropEquiv g c0 c2 x c0_pre_typing c0_res_typing c0_post_typing
(RT.Rel_trans _ _ _ _ _ eq_res_01 eq_res_12)
(VE_Trans _ _ _ _ eq_pre_01 eq_pre_12)
(VE_Trans _ _ _ _ eq_post_01 eq_post_12)
)
else None
)
| ST_TotEquiv g t1 t2 u typing eq ->
let ST_TotEquiv _g _t1 t3 _ _ eq' = d12 in
let eq'' = Ghost.hide (RT.Rel_trans _ _ _ _ _ eq eq') in
Some (ST_TotEquiv g t1 t3 u typing eq'')
let t_equiv #g #st #c (d:st_typing g st c) (#c':comp) (eq:st_equiv g c c')
: st_typing g st c'
= match d with
| T_Equiv _ _ _ _ d0 eq' -> (
match st_equiv_trans eq' eq with
| None -> T_Equiv _ _ _ _ d eq
| Some eq'' -> T_Equiv _ _ _ _ d0 eq''
)
| _ -> T_Equiv _ _ _ _ d eq
let st_equiv_post (#g:env) (#t:st_term) (#c:comp_st) (d:st_typing g t c)
(post:term { freevars post `Set.subset` freevars (comp_post c)})
(veq: (x:var { fresh_wrt x g (freevars (comp_post c)) } ->
vprop_equiv (push_binding g x ppname_default (comp_res c))
(open_term (comp_post c) x)
(open_term post x)))
: st_typing g t (comp_st_with_post c post)
= if eq_tm post (comp_post c) then d
else
let c' = comp_st_with_post c post in
let (| u_of, pre_typing, x, post_typing |) = Metatheory.(st_comp_typing_inversion (fst (comp_typing_inversion (st_typing_correctness d)))) in
let veq = veq x in
let st_equiv : st_equiv g c c' =
ST_VPropEquiv g c c' x pre_typing u_of post_typing (RT.Rel_refl _ _ _) (VE_Refl _ _) veq
in
t_equiv d st_equiv
let simplify_post (#g:env) (#t:st_term) (#c:comp_st) (d:st_typing g t c)
(post:term { comp_post c == tm_star post tm_emp})
: st_typing g t (comp_st_with_post c post)
= st_equiv_post d post (fun x -> ve_unit_r (push_binding g x ppname_default (comp_res c)) (open_term post x))
let simplify_lemma (c:comp_st) (c':comp_st) (post_hint:option post_hint_t)
: Lemma
(requires
comp_post_matches_hint c post_hint /\
effect_annot_of_comp c == effect_annot_of_comp c' /\
comp_res c' == comp_res c /\
comp_u c' == comp_u c /\
comp_post c' == tm_star (comp_post c) tm_emp)
(ensures comp_post_matches_hint (comp_st_with_post c' (comp_post c)) post_hint /\
comp_pre (comp_st_with_post c' (comp_post c)) == comp_pre c')
= ()
let vprop_equiv_typing_bk (#g:env) (#ctxt:_) (ctxt_typing:tot_typing g ctxt tm_vprop)
(#p:_) (d:vprop_equiv g p ctxt)
: tot_typing g p tm_vprop
= let _, bk = vprop_equiv_typing d in
bk ctxt_typing
let comp_with_pre (c:comp_st) (pre:term) =
match c with
| C_ST st -> C_ST { st with pre }
| C_STGhost st -> C_STGhost { st with pre }
| C_STAtomic i obs st -> C_STAtomic i obs {st with pre}
let st_equiv_pre (#g:env) (#t:st_term) (#c:comp_st) (d:st_typing g t c)
(pre:term)
(veq: vprop_equiv g (comp_pre c) pre)
: st_typing g t (comp_with_pre c pre)
= if eq_tm pre (comp_pre c) then d
else
let c' = comp_with_pre c pre in
let (| u_of, pre_typing, x, post_typing |) =
Metatheory.(st_comp_typing_inversion (fst (comp_typing_inversion (st_typing_correctness d)))) in
let st_equiv : st_equiv g c c' =
ST_VPropEquiv g c c' x pre_typing u_of post_typing (RT.Rel_refl _ _ _) veq (VE_Refl _ _)
in
t_equiv d st_equiv
#push-options "--z3rlimit_factor 4 --ifuel 2 --fuel 0"
let k_elab_equiv_continuation (#g1:env) (#g2:env { g2 `env_extends` g1 }) (#ctxt #ctxt1 #ctxt2:term)
(k:continuation_elaborator g1 ctxt g2 ctxt1)
(d:vprop_equiv g2 ctxt1 ctxt2)
: continuation_elaborator g1 ctxt g2 ctxt2 =
fun post_hint res ->
let (| st, c, st_d |) = res in
let st_d : st_typing g2 st c = st_d in
assert (comp_pre c == ctxt2);
let st_d' : st_typing g2 st (comp_with_pre c ctxt1) = st_equiv_pre st_d _ (VE_Sym _ _ _ d) in
k post_hint (| st, _, st_d' |)
#pop-options
let vprop_equiv_typing_fwd (#g:env) (#ctxt:_) (ctxt_typing:tot_typing g ctxt tm_vprop)
(#p:_) (d:vprop_equiv g ctxt p)
: tot_typing g p tm_vprop
= let fwd, _ = vprop_equiv_typing d in
fwd ctxt_typing
#push-options "--z3rlimit_factor 4 --ifuel 1 --fuel 0"
let k_elab_equiv_prefix
(#g1:env) (#g2:env { g2 `env_extends` g1 }) (#ctxt1 #ctxt2 #ctxt:term)
(k:continuation_elaborator g1 ctxt1 g2 ctxt)
(d:vprop_equiv g1 ctxt1 ctxt2)
: continuation_elaborator g1 ctxt2 g2 ctxt =
fun post_hint res ->
let framing_token : frame_for_req_in_ctxt g1 ctxt2 ctxt1 =
let d = VE_Trans _ _ _ _ (VE_Comm _ _ _) (VE_Trans _ _ _ _ (VE_Unit _ _) d) in
(| tm_emp, emp_typing, d |)
in
let res = k post_hint res in
let (| st, c, st_d |) = res in
assert (comp_pre c == ctxt1);
(| _, _, st_equiv_pre st_d _ d |)
#pop-options
let k_elab_equiv
(#g1:env) (#g2:env { g2 `env_extends` g1 }) (#ctxt1 #ctxt1' #ctxt2 #ctxt2':term)
(k:continuation_elaborator g1 ctxt1 g2 ctxt2)
(d1:vprop_equiv g1 ctxt1 ctxt1')
(d2:vprop_equiv g2 ctxt2 ctxt2')
: continuation_elaborator g1 ctxt1' g2 ctxt2' =
let k : continuation_elaborator g1 ctxt1 g2 ctxt2' =
k_elab_equiv_continuation k d2 in
let k : continuation_elaborator g1 ctxt1' g2 ctxt2' =
k_elab_equiv_prefix k d1 in
k
#push-options "--query_stats --fuel 2 --ifuel 2 --split_queries no --z3rlimit_factor 20"
open Pulse.PP
let continuation_elaborator_with_bind (#g:env) (ctxt:term)
(#c1:comp{stateful_comp c1})
(#e1:st_term)
(e1_typing:st_typing g e1 c1)
(ctxt_pre1_typing:tot_typing g (tm_star ctxt (comp_pre c1)) tm_vprop)
(x:nvar { None? (lookup g (snd x)) })
: T.Tac (continuation_elaborator
g
(tm_star ctxt (comp_pre c1))
(push_binding g (snd x) (fst x) (comp_res c1))
(tm_star (open_term (comp_post c1) (snd x)) ctxt)) =
let pre1 = comp_pre c1 in
let res1 = comp_res c1 in
let post1 = comp_post c1 in
let ctxt_typing = star_typing_inversion_l ctxt_pre1_typing in
// let p_prop = Metatheory.pure_typing_inversion pure_typing in
let v_eq = VE_Comm g ctxt pre1 in
let framing_token : frame_for_req_in_ctxt g (tm_star ctxt pre1) pre1 =
(| ctxt, ctxt_typing, VE_Comm g pre1 ctxt |)
in
let (| c1, e1_typing |) =
apply_frame ctxt_pre1_typing e1_typing framing_token in
let (| u_of_1, pre_typing, _, _ |) =
Metatheory.(st_comp_typing_inversion (fst <| comp_typing_inversion (st_typing_correctness e1_typing))) in
let b = res1 in
let ppname, x = x in
let g' = push_binding g x ppname b in
let post1_opened = open_term_nv post1 (v_as_nv x) in
let k : continuation_elaborator g (tm_star ctxt pre1) g' (tm_star post1_opened ctxt) =
fun post_hint res ->
let (| e2, c2, e2_typing |) = res in
assert (comp_post_matches_hint c2 post_hint);
let e2_typing : st_typing g' e2 c2 = e2_typing in
let e2_closed = close_st_term e2 x in
assume (open_st_term e2_closed x == e2);
assert (comp_pre c1 == (tm_star ctxt pre1));
assert (comp_post c1 == tm_star post1 ctxt);
assert (comp_pre c2 == tm_star post1_opened ctxt);
assert (open_term (comp_post c1) x == tm_star post1_opened (open_term ctxt x));
// ctxt is well-typed, hence ln
assume (open_term ctxt x == ctxt);
assert (open_term (comp_post c1) x == comp_pre c2);
// we closed e2 with x
assume (~ (x `Set.mem` freevars_st e2_closed));
if x `Set.mem` freevars (comp_post c2)
then fail g' None "Impossible: freevar clash when constructing continuation elaborator for bind, please file a bug-report"
else (
let t_typing, post_typing =
Pulse.Typing.Combinators.bind_res_and_post_typing g c2 x post_hint in
let g = push_context g "mk_bind" e1.range in
// info_doc g None
// [prefix 4 1 (doc_of_string "mk_bind e1 = ") (doc_of_string (Pulse.Syntax.Printer.st_term_to_string e1));
// prefix 4 1 (doc_of_string "mk_bind c1 = ") (pp #comp c1);
// prefix 4 1 (doc_of_string "mk_bind e2 = ") (doc_of_string (Pulse.Syntax.Printer.st_term_to_string e2));
// prefix 4 1 (doc_of_string "mk_bind c2 = ") (pp #comp c2)]
// ;
let (| e, c, e_typing |) =
Pulse.Typing.Combinators.mk_bind
g (tm_star ctxt pre1)
e1 e2_closed c1 c2 (ppname, x) e1_typing
u_of_1
e2_typing
t_typing
post_typing
(Some? post_hint)
in
(| e, c, e_typing |)
)
in
k
#pop-options
module LN = Pulse.Typing.LN
#push-options "--z3rlimit_factor 4 --fuel 1 --ifuel 1"
let st_comp_typing_with_post_hint
(#g:env) (#ctxt:_)
(ctxt_typing:tot_typing g ctxt tm_vprop)
(post_hint:post_hint_opt g { Some? post_hint })
(c:comp_st { comp_pre c == ctxt /\ comp_post_matches_hint c post_hint })
: st_comp_typing g (st_comp_of_comp c)
= let st = st_comp_of_comp c in
let Some ph = post_hint in
let post_typing_src
: tot_typing (push_binding ph.g ph.x ppname_default ph.ret_ty)
(open_term ph.post ph.x) tm_vprop
= ph.post_typing_src
in
let x = fresh g in
assume (fresh_wrt x g (freevars ph.post));
assume (None? (lookup g ph.x));
let post_typing_src
: tot_typing (push_binding ph.g x ppname_default ph.ret_ty)
(open_term ph.post x) tm_vprop
= if x = ph.x
then post_typing_src
else
let open Pulse.Typing.Metatheory.Base in
let tt :
tot_typing
(push_binding ph.g x ppname_default ph.ret_ty)
(subst_term (open_term ph.post ph.x) (renaming ph.x x))
(subst_term tm_vprop (renaming ph.x x)) =
tot_typing_renaming1 ph.g ph.x ph.ret_ty (open_term ph.post ph.x) tm_vprop post_typing_src x
in
assert (subst_term tm_vprop (renaming ph.x x) == tm_vprop);
assume (subst_term (open_term ph.post ph.x) (renaming ph.x x) ==
open_term ph.post x);
tt
in
let post_typing_src
: tot_typing (push_binding g x ppname_default ph.ret_ty)
(open_term ph.post x) tm_vprop
= //weakening: TODO
RU.magic ()
in
let ty_typing : universe_of ph.g st.res st.u = ph.ty_typing in
let ty_typing : universe_of g st.res st.u =
Pulse.Typing.Metatheory.tot_typing_weakening_standard ph.g ty_typing g
in
assert (st.res == ph.ret_ty);
assert (st.post == ph.post);
STC g st x ty_typing ctxt_typing post_typing_src
let continuation_elaborator_with_bind_fn (#g:env) (#ctxt:term)
(ctxt_typing:tot_typing g ctxt tm_vprop)
(#e1:st_term)
(#c1:comp { C_Tot? c1 })
(b:binder{b.binder_ty == comp_res c1})
(e1_typing:st_typing g e1 c1)
(x:nvar { None? (lookup g (snd x)) })
: T.Tac (continuation_elaborator
g ctxt
(push_binding g (snd x) ppname_default (comp_res c1)) ctxt)
= let t1 = comp_res c1 in
assert ((push_binding g (snd x) (fst x) t1) `env_extends` g);
fun post_hint (| e2, c2, d2 |) ->
if None? post_hint then T.fail "bind_fn: expects the post_hint to be set";
let ppname, x = x in
let e2_closed = close_st_term e2 x in
assume (open_st_term (close_st_term e2 x) x == e2);
let e = wr c2 (Tm_Bind {binder=b; head=e1; body=e2_closed}) in
let (| u, c1_typing |) = Pulse.Typing.Metatheory.Base.st_typing_correctness_ctot e1_typing in
let c2_typing : comp_typing g c2 (universe_of_comp c2) =
match c2 with
| C_ST st ->
let stc = st_comp_typing_with_post_hint ctxt_typing post_hint c2 in
CT_ST _ _ stc
| C_STAtomic i obs st ->
let stc = st_comp_typing_with_post_hint ctxt_typing post_hint c2 in
let i_typing = CP.core_check_term g i T.E_Total tm_inames in
CT_STAtomic _ _ obs _ i_typing stc
| C_STGhost st ->
let stc = st_comp_typing_with_post_hint ctxt_typing post_hint c2 in
CT_STGhost _ _ stc
in
let d : st_typing g e c2 =
T_BindFn g e1 e2_closed c1 c2 b x e1_typing u c1_typing d2 c2_typing
in
(| e, c2, d |)
let rec check_equiv_emp (g:env) (vp:term)
: option (vprop_equiv g vp tm_emp)
= match vp.t with
| Tm_Emp -> Some (VE_Refl _ _)
| Tm_Star vp1 vp2 ->
(match check_equiv_emp g vp1, check_equiv_emp g vp2 with
| Some d1, Some d2 ->
let d3 : vprop_equiv g (tm_star vp1 vp2) (tm_star tm_emp tm_emp)
= VE_Ctxt _ _ _ _ _ d1 d2 in
let d4 : vprop_equiv g (tm_star tm_emp tm_emp) tm_emp =
VE_Unit _ _ in
Some (VE_Trans _ _ _ _ d3 d4)
| _, _ -> None)
| _ -> None
let emp_inames_included (g:env) (i:term) (_:tot_typing g i tm_inames)
: prop_validity g (tm_inames_subset tm_emp_inames i)
= RU.magic()
let return_in_ctxt (g:env) (y:var) (y_ppname:ppname) (u:universe) (ty:term) (ctxt:vprop)
(ty_typing:universe_of g ty u)
(post_hint0:post_hint_opt g { Some? post_hint0 /\ checker_res_matches_post_hint g post_hint0 y ty ctxt})
: Pure (st_typing_in_ctxt g ctxt post_hint0)
(requires lookup g y == Some ty)
(ensures fun _ -> True)
= let Some post_hint = post_hint0 in
let x = fresh g in
assume (~ (x `Set.mem` freevars post_hint.post));
let ctag =
match post_hint.effect_annot with
| EffectAnnotAtomic _ -> STT_Atomic
| EffectAnnotGhost -> STT_Ghost
| _ -> STT
in
let y_tm = tm_var {nm_index=y;nm_ppname=y_ppname} in
let d = T_Return g ctag false u ty y_tm post_hint.post x ty_typing
(RU.magic ()) // that null_var y is well typed at ty in g, we know since lookup g y == Some ty
(RU.magic ()) // typing of (open post x) in (g, x) ... post_hint is well-typed, so should get
in
let t = wtag (Some ctag) (Tm_Return {expected_type=tm_unknown;insert_eq=false;term=y_tm}) in
let c = comp_return ctag false u ty y_tm post_hint.post x in
let d : st_typing g t c = d in
assume (comp_u c == post_hint.u); // this u should follow from equality of t
match c, post_hint.effect_annot with
| C_STAtomic _ obs _, EffectAnnotAtomic { opens } ->
assert (comp_inames c == tm_emp_inames);
let pht = post_hint_typing g post_hint x in
let validity = emp_inames_included g opens pht.effect_annot_typing in
let d = T_Sub _ _ _ _ d (STS_AtomicInvs _ (st_comp_of_comp c) tm_emp_inames opens obs obs validity) in
(| _, _, d |)
| _ ->
(| _, _, d |) | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.Metatheory.Base.fsti.checked",
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.LN.fsti.checked",
"Pulse.Typing.FV.fsti.checked",
"Pulse.Typing.Combinators.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Readback.fsti.checked",
"Pulse.PP.fst.checked",
"Pulse.Checker.Pure.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.String.fsti.checked",
"FStar.Squash.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Reflection.V2.TermEq.fst.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Range.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Base.fst"
} | [
{
"abbrev": true,
"full_module": "Pulse.Typing.LN",
"short_module": "LN"
},
{
"abbrev": false,
"full_module": "Pulse.PP",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Metatheory",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Pure",
"short_module": "CP"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.FV",
"short_module": "FV"
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 4,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | d: Pulse.Typing.st_typing g t c -> post_hint: Pulse.Typing.post_hint_opt g
-> FStar.Tactics.Effect.Tac
(FStar.Pervasives.dtuple3 Pulse.Syntax.Base.st_term
(fun _ -> Pulse.Syntax.Base.comp_st)
(fun t' c' -> Pulse.Typing.st_typing g t' c')) | FStar.Tactics.Effect.Tac | [] | [] | [
"Pulse.Typing.Env.env",
"Pulse.Syntax.Base.st_term",
"Pulse.Syntax.Base.comp_st",
"Pulse.Typing.st_typing",
"Pulse.Typing.post_hint_opt",
"FStar.Pervasives.Mkdtuple3",
"FStar.Pervasives.dtuple3",
"Pulse.Syntax.Base.effect_annot",
"Pulse.Typing.effect_annot_typing",
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Base.universe",
"Pulse.Typing.universe_of",
"Pulse.Syntax.Base.var",
"Pulse.Typing.fresh_wrt",
"Pulse.Syntax.Naming.freevars",
"Pulse.Typing.tot_typing",
"Pulse.Typing.Env.push_binding",
"Pulse.Syntax.Base.ppname_default",
"Pulse.Syntax.Naming.open_term",
"Pulse.Syntax.Base.tm_vprop",
"FStar.Ghost.erased",
"FStar.Reflection.Typing.tot_typing",
"Pulse.Typing.elab_env",
"FStar.Reflection.Typing.mk_abs",
"Pulse.Elaborate.Pure.elab_term",
"FStar.Stubs.Reflection.V2.Data.Q_Explicit",
"FStar.Reflection.Typing.mk_arrow",
"Pulse.Syntax.Base.eq_tm",
"Prims.bool",
"Pulse.Typing.Env.fail",
"FStar.Pervasives.Native.Some",
"Pulse.Syntax.Base.range",
"Pulse.Syntax.Base.__proj__Mkst_term__item__range",
"Prims.string",
"FStar.Printf.sprintf",
"Pulse.Syntax.Printer.term_to_string",
"FStar.Stubs.Tactics.Types.equiv_token",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__res",
"Pulse.Syntax.Base.st_comp_of_comp",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__u",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__pre",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__post",
"Pulse.Typing.T_Equiv",
"Pulse.Typing.st_equiv",
"Pulse.Typing.ST_VPropEquiv",
"Pulse.Typing.VE_Refl",
"Pulse.Syntax.Base.comp_pre",
"Pulse.Syntax.Base.comp_res",
"Pulse.Syntax.Base.comp_post",
"FStar.Pervasives.dtuple4",
"Pulse.Typing.Metatheory.Base.st_comp_typing_inversion",
"FStar.Pervasives.Native.fst",
"Pulse.Typing.st_comp_typing",
"Pulse.Typing.Metatheory.Base.iname_typing",
"Pulse.Typing.Metatheory.Base.comp_typing_inversion",
"Pulse.Typing.Metatheory.Base.st_typing_correctness",
"Pulse.Syntax.Base.comp",
"Pulse.Syntax.Base.with_st_comp",
"Pulse.Syntax.Base.Mkst_comp",
"Pulse.Syntax.Base.st_comp",
"FStar.Reflection.Typing.equiv",
"FStar.Reflection.Typing.Rel_eq_token",
"FStar.Squash.return_squash",
"FStar.Pervasives.Native.option",
"Pulse.Checker.Pure.check_equiv"
] | [] | false | true | false | false | false | let match_comp_res_with_post_hint
(#g: env)
(#t: st_term)
(#c: comp_st)
(d: st_typing g t c)
(post_hint: post_hint_opt g)
: T.Tac (t': st_term & c': comp_st & st_typing g t' c') =
| match post_hint with
| None -> (| t, c, d |)
| Some { ret_ty = ret_ty } ->
let cres = comp_res c in
if eq_tm cres ret_ty
then (| t, c, d |)
else
match Pulse.Checker.Pure.check_equiv g cres ret_ty with
| None ->
fail g
(Some t.range)
(Printf.sprintf "Could not prove equiv for computed type %s and expected type %s"
(P.term_to_string cres)
(P.term_to_string ret_ty))
| Some tok ->
let d_equiv:RT.equiv _ (elab_term cres) (elab_term ret_ty) =
RT.Rel_eq_token _ _ _ (FStar.Squash.return_squash tok)
in
let c' = with_st_comp c ({ (st_comp_of_comp c) with res = ret_ty }) in
let (| cres_typing , cpre_typing , x , cpost_typing |) =
st_comp_typing_inversion (fst <| comp_typing_inversion (st_typing_correctness d))
in
let d_stequiv:st_equiv g c c' =
ST_VPropEquiv _
c
c'
_
cpre_typing
cres_typing
cpost_typing
d_equiv
(VE_Refl _ _)
(VE_Refl _ _)
in
(| t, c', T_Equiv _ _ _ _ d d_stequiv |) | false |
AlgHeap.fst | AlgHeap.abides_sublist | val abides_sublist (#a: _) (l1 l2: ops) (c: tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)] | val abides_sublist (#a: _) (l1 l2: ops) (c: tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)] | let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 32,
"end_line": 99,
"start_col": 0,
"start_line": 95
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l1: AlgHeap.ops -> l2: AlgHeap.ops -> c: AlgHeap.tree0 a
-> FStar.Pervasives.Lemma (requires AlgHeap.abides l1 c /\ AlgHeap.sublist l1 l2)
(ensures AlgHeap.abides l2 c)
[SMTPat (AlgHeap.abides l2 c); SMTPat (AlgHeap.sublist l1 l2)] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"AlgHeap.ops",
"AlgHeap.tree0",
"AlgHeap.abides_sublist_nopat",
"Prims.unit",
"Prims.l_and",
"AlgHeap.abides",
"AlgHeap.sublist",
"Prims.squash",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.prop",
"Prims.logical",
"Prims.Nil"
] | [] | true | false | true | false | false | let abides_sublist #a (l1: ops) (l2: ops) (c: tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)] =
| abides_sublist_nopat l1 l2 c | false |
Vale.AES.X64.GCMdecryptOpt.fst | Vale.AES.X64.GCMdecryptOpt.va_qcode_Gcm_blocks_wrapped | val va_qcode_Gcm_blocks_wrapped
(va_mods: va_mods_t)
(alg: algorithm)
(offset: int)
(auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b: buffer128)
(iv: supported_iv_LE)
(scratch_b: buffer128)
(key: (seq nat32))
(round_keys: (seq quad32))
(keys_b hkeys_b: buffer128)
(expected_tag: (seq nat8))
: (va_quickCode unit (va_code_Gcm_blocks_wrapped alg offset)) | val va_qcode_Gcm_blocks_wrapped
(va_mods: va_mods_t)
(alg: algorithm)
(offset: int)
(auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b: buffer128)
(iv: supported_iv_LE)
(scratch_b: buffer128)
(key: (seq nat32))
(round_keys: (seq quad32))
(keys_b hkeys_b: buffer128)
(expected_tag: (seq nat8))
: (va_quickCode unit (va_code_Gcm_blocks_wrapped alg offset)) | let va_qcode_Gcm_blocks_wrapped (va_mods:va_mods_t) (alg:algorithm) (offset:int) (auth_b:buffer128)
(abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128)
(out128_b:buffer128) (inout_b:buffer128) (iv_b:buffer128) (iv:supported_iv_LE)
(scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128)
(hkeys_b:buffer128) (expected_tag:(seq nat8)) : (va_quickCode unit (va_code_Gcm_blocks_wrapped
alg offset)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 0) (va_get_stack va_s) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 8) (va_get_stack va_s) in let
(out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 16) (va_get_stack va_s) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 24) (va_get_stack va_s) in let
(in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 32) (va_get_stack va_s) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 40) (va_get_stack va_s) in let
(len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset
+ 48) (va_get_stack va_s) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 56) (va_get_stack va_s) in let
(plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s
+ offset + 64) (va_get_stack va_s) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 739 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b
iv_b scratch_b key round_keys keys_b hkeys_b) (fun (va_s:va_state) _ -> va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 741 column 37 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(8 `op_Multiply` va_get_reg64 rRsi va_old_s >= 0 /\ 8 `op_Multiply` va_get_reg64 rRsi va_old_s
<= 18446744073709551615 /\ 8 `op_Multiply` plain_num_bytes >= 0 /\ 8 `op_Multiply`
plain_num_bytes <= 18446744073709551615) (fun _ -> let (va_arg55:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) (8
`op_Multiply` va_get_reg64 rRsi va_old_s) 1) (8 `op_Multiply` plain_num_bytes) 0) in let
(va_arg54:Vale.Def.Types_s.quad32) = va_get_xmm 8 va_s in let
(va_arg53:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.X64.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 0 va_s)) in let
(va_arg52:Vale.Def.Types_s.quad32) = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2
va_old_s) in let (va_arg51:Vale.AES.GCM_s.supported_iv_LE) = iv in let (va_arg50:Prims.nat) =
va_get_reg64 rRsi va_old_s in let (va_arg49:Prims.nat) = plain_num_bytes in let
(va_arg48:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s) inout_b in let (va_arg47:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b in let
(va_arg46:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s) out128x6_b in let (va_arg45:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b in let
(va_arg44:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) in128_b in let (va_arg43:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b in
let (va_arg42:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_old_s) abytes_b in let (va_arg41:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) auth_b in let
(va_arg40:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = key in let
(va_arg39:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 741 column 37 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCM.gcm_blocks_dec_helper_simplified va_arg39 va_arg40 va_arg41
va_arg42 va_arg43 va_arg44 va_arg45 va_arg46 va_arg47 va_arg48 va_arg49 va_arg50 va_arg51
va_arg52 va_arg53 va_arg54 va_arg55) (let (auth_raw_quads:(FStar.Seq.Base.seq
Vale.X64.Decls.quad32)) = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) auth_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_old_s)
abytes_b) in va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 751 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun a_1906 (s_1907:(FStar.Seq.Base.seq a_1906)) (i_1908:Prims.nat) (j_1909:Prims.nat) -> let
(j_1869:Prims.nat) = j_1909 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1908
j_1869) (Prims.op_LessThanOrEqual j_1869 (FStar.Seq.Base.length #a_1906 s_1907))))
Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0 (va_get_reg64
rRsi va_old_s)) (fun _ -> let (auth_bytes:(FStar.Seq.Base.seq Vale.Def.Types_s.nat8)) =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
auth_raw_quads) 0 (va_get_reg64 rRsi va_old_s) in let (va_arg38:Vale.Def.Types_s.quad32) =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_old_s) in let
(va_arg37:Vale.AES.GCM_s.supported_iv_LE) = iv in let (va_arg36:Prims.nat) = plain_num_bytes in
let (va_arg35:(FStar.Seq.Base.seq Vale.Def.Words_s.nat8)) = expected_tag in let
(va_arg34:(FStar.Seq.Base.seq Vale.Def.Words_s.nat8)) = auth_bytes in let
(va_arg33:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s) inout_b in let (va_arg32:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b in let
(va_arg31:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s) out128x6_b in let (va_arg30:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b in let
(va_arg29:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) in128_b in let (va_arg28:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b in
let (va_arg27:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = key in let
(va_arg26:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 752 column 37 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCM.gcm_blocks_helper_dec_simplified va_arg26 va_arg27 va_arg28
va_arg29 va_arg30 va_arg31 va_arg32 va_arg33 va_arg34 va_arg35 va_arg36 va_arg37 va_arg38)
(va_QEmpty (())))))))) | {
"file_name": "obj/Vale.AES.X64.GCMdecryptOpt.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 26,
"end_line": 1455,
"start_col": 0,
"start_line": 1370
} | module Vale.AES.X64.GCMdecryptOpt
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open FStar.Seq
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_s
open Vale.AES.GCTR_s
open Vale.AES.GCTR
open Vale.AES.GCM
open Vale.AES.GHash_s
open Vale.AES.GHash
open Vale.AES.GCM_s
open Vale.AES.X64.AES
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.Poly1305.Math
open Vale.AES.GCM_helpers
open Vale.AES.X64.GHash
open Vale.AES.X64.GCTR
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.X64.Stack_i
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.InsBasic
open Vale.X64.InsMem
open Vale.X64.InsVector
open Vale.X64.InsStack
open Vale.X64.InsAes
open Vale.X64.QuickCode
open Vale.X64.QuickCodes
open Vale.AES.X64.GF128_Mul
open Vale.X64.Stack
open Vale.X64.CPU_Features_s
open Vale.Math.Poly2.Bits_s
open Vale.AES.X64.AESopt
open Vale.AES.X64.AESGCM
open Vale.AES.X64.AESopt2
open Vale.Lib.Meta
open Vale.AES.X64.GCMencryptOpt
open Vale.AES.OptPublic
open Vale.Lib.Basic
#reset-options "--z3rlimit 20 --max_ifuel 0"
//-- Gcm_extra_bytes
val va_code_Gcm_extra_bytes : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_extra_bytes alg =
(va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0)
(va_op_reg_opr64_reg64 rRax) 0 Secret) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 10)
(va_op_xmm_xmm 0)) (va_CCons (va_code_Ghash_extra_bytes ()) (va_CCons (va_code_Mov128
(va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_CCons (va_code_Pshufb (va_op_xmm_xmm 0)
(va_op_xmm_xmm 9)) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons (va_code_Pxor
(va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_CCons (va_code_Store128_buffer
(va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret)
(va_CNil ()))))))))))
val va_codegen_success_Gcm_extra_bytes : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_extra_bytes alg =
(va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0)
(va_op_reg_opr64_reg64 rRax) 0 Secret) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm
10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Ghash_extra_bytes ()) (va_pbool_and
(va_codegen_success_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_pbool_and
(va_codegen_success_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and
(va_codegen_success_AESEncryptBlock alg) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm
10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Store128_buffer
(va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret)
(va_ttrue ())))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_extra_bytes (va_mods:va_mods_t) (alg:algorithm) (inout_b:buffer128) (key:(seq
nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat)
(old_hash:quad32) (completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit
(va_code_Gcm_extra_bytes alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (len:(va_int_range
1 1)) = 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 188 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRax) 0 Secret inout_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 189 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (fun (va_s:va_state) _ -> let
(hash_input:quad32) = va_get_xmm 0 va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 193 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_extra_bytes hkeys_b total_bytes old_hash h_LE completed_quads) (fun
(va_s:va_state) _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 194 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.equal #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s)
inout_b) (FStar.Seq.Base.create #quad32 1 hash_input)) (let (snap:(FStar.Seq.Base.seq
Vale.X64.Decls.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 198 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 199 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 200 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AESEncryptBlock alg (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 11 va_s)) key
round_keys keys_b) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 201 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.AES_s.aes_encrypt_LE_reveal ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 204 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 205 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax)
(va_op_xmm_xmm 10) 0 Secret inout_b 0) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 207 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.gctr_partial_reveal ()) (va_QEmpty (()))))))))))))))
val va_lemma_Gcm_extra_bytes : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
inout_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> total_bytes:nat -> old_hash:quad32 -> completed_quads:(seq quad32) ->
h_LE:quad32
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_extra_bytes alg) va_s0 /\ va_get_ok va_s0 /\ (let
(len:(va_int_range 1 1)) = 1 in sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b
inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b inout_b /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax va_s0) inout_b
len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys
keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0
va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32
(Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length
#quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply`
FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes
`op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16
`op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
(Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads =
FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0)
inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes =
Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) /\ va_state_eq va_sM
(va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM (va_update_ok va_sM
(va_update_mem va_sM va_s0))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_extra_bytes va_b0 va_s0 alg inout_b key round_keys keys_b hkeys_b total_bytes
old_hash completed_quads h_LE =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_extra_bytes va_mods alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_extra_bytes alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 121 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (len:(va_int_range 1 1)) = 1 in label va_range1
"***** POSTCONDITION NOT MET AT line 174 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 177 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg len (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0)) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 180 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let raw_quads = FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 181 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 182 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 183 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let input_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 186 column 59 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(l_and (FStar.Seq.Base.length #Vale.Def.Types_s.quad32 input_quads > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE old_hash input_quads)))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm
7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32)
(completed_quads:(seq quad32)) (h_LE:quad32) (va_s0:va_state) (va_k:(va_state -> unit -> Type0))
: Type0 =
(va_get_ok va_s0 /\ (let (len:(va_int_range 1 1)) = 1 in sse_enabled /\
Vale.X64.Decls.buffers_disjoint128 keys_b inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b
inout_b /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax
va_s0) inout_b len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys
keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0
va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32
(Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length
#quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply`
FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes
`op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16
`op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
(Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes) /\ (forall
(va_x_mem:vale_heap) (va_x_rcx:nat64) (va_x_r11:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32)
(va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32)
(va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm10:quad32) (va_x_heap5:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 5
va_x_heap5 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7
(va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3
(va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR11
va_x_r11 (va_upd_reg64 rRcx va_x_rcx (va_upd_mem va_x_mem va_s0)))))))))))))) in va_get_ok
va_sM /\ (let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads =
FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0)
inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes =
Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) ==> va_k va_sM (())))
val va_wpProof_Gcm_extra_bytes : alg:algorithm -> inout_b:buffer128 -> key:(seq nat32) ->
round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> total_bytes:nat ->
old_hash:quad32 -> completed_quads:(seq quad32) -> h_LE: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_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_extra_bytes alg) ([va_Mod_flags;
va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5;
va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11;
va_Mod_reg64 rRcx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash
completed_quads h_LE va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_extra_bytes (va_code_Gcm_extra_bytes alg) va_s0 alg inout_b key
round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10
va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm
7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32)
(completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit (va_code_Gcm_extra_bytes alg)) =
(va_QProc (va_code_Gcm_extra_bytes alg) ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10;
va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm
2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem])
(va_wp_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash
completed_quads h_LE) (va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE))
//--
//-- Gcm_blocks128
val va_code_Gcm_blocks128 : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks128 alg =
(va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi))
(va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_CCons
(va_code_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_CCons
(va_code_Ghash_buffer ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdi)
(va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx)
(va_op_opr64_reg64 rR12)) (va_CCons (va_code_Gctr_blocks128 alg) (va_CNil ())))))))))
val va_codegen_success_Gcm_blocks128 : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks128 alg =
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi))
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx))
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax))
(va_pbool_and (va_codegen_success_Ghash_buffer ()) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_pbool_and
(va_codegen_success_Gctr_blocks128 alg) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks128 (va_mods:va_mods_t) (alg:algorithm) (in_b:buffer128) (out_b:buffer128)
(key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32)
: (va_quickCode unit (va_code_Gcm_blocks128 alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 274 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 275 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 276 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 277 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_buffer hkeys_b in_b h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_old_s))) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 278 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 279 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 280 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gctr_blocks128 alg in_b out_b key round_keys keys_b) (va_QEmpty (()))))))))))
val va_lemma_Gcm_blocks128 : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> in_b:buffer128 ->
out_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> h_LE:quad32
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks128 alg) va_s0 /\ va_get_ok va_s0 /\
(sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b out_b /\
Vale.X64.Decls.buffers_disjoint128 hkeys_b out_b /\ (Vale.X64.Decls.buffers_disjoint128 in_b
out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16
`op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply`
va_get_reg64 rRdx va_s0 < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b)
(Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx
va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\
va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8
va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0)
(va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM ==
va_get_xmm 8 va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b ==
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ (va_get_reg64 rRdx va_s0 > 0 ==>
l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==> FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b)))) /\ va_state_eq va_sM (va_update_flags va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 10 va_sM (va_update_xmm 11 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rR10 va_sM
(va_update_reg64 rR11 va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRbx va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_blocks128 va_b0 va_s0 alg in_b out_b key round_keys keys_b hkeys_b h_LE =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11;
va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm
2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks128 va_mods alg in_b out_b key round_keys keys_b hkeys_b h_LE in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks128 alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 210 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 255 column 53 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 261 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 262 column 45 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0) (va_get_reg64 rRdx
va_s0)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 265 column 93 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM == va_get_xmm 8 va_s0)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b == Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) out_b)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 267 column 131 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRdx va_s0 > 0 ==> l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==>
FStar.Seq.Base.length #Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm
8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2;
va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_blocks128 (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32) (va_s0:va_state)
(va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b out_b /\
Vale.X64.Decls.buffers_disjoint128 hkeys_b out_b /\ (Vale.X64.Decls.buffers_disjoint128 in_b
out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16
`op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply`
va_get_reg64 rRdx va_s0 < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b)
(Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx
va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\
va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8
va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret) /\ (forall (va_x_mem:vale_heap) (va_x_rbx:nat64) (va_x_rdi:nat64) (va_x_r11:nat64)
(va_x_r10:nat64) (va_x_rdx:nat64) (va_x_r12:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32)
(va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32)
(va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm11:quad32) (va_x_xmm10:quad32)
(va_x_heap1:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 11 va_x_xmm11
(va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5
(va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1
(va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64
rR10 va_x_r10 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRbx
va_x_rbx (va_upd_mem va_x_mem va_s0))))))))))))))))))) in va_get_ok va_sM /\
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0)
(va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM ==
va_get_xmm 8 va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b ==
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ (va_get_reg64 rRdx va_s0 > 0 ==>
l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==> FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b)))) ==> va_k va_sM (())))
val va_wpProof_Gcm_blocks128 : alg:algorithm -> in_b:buffer128 -> out_b:buffer128 -> key:(seq
nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> h_LE: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_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b
h_LE va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks128 alg) ([va_Mod_flags;
va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6;
va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0;
va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10; va_Mod_reg64 rR11; va_Mod_reg64 rRdi;
va_Mod_reg64 rRbx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_blocks128 (va_code_Gcm_blocks128 alg) va_s0 alg in_b out_b key
round_keys keys_b hkeys_b h_LE in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 1 va_sM (va_update_xmm 10
va_sM (va_update_xmm 11 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6
va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2
va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR12 va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rRdi va_sM (va_update_reg64 rRbx va_sM (va_update_ok va_sM (va_update_mem
va_sM va_s0))))))))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm
8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2;
va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_blocks128 (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32) : (va_quickCode
unit (va_code_Gcm_blocks128 alg)) =
(va_QProc (va_code_Gcm_blocks128 alg) ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10;
va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm
3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64
rR10; va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_mem])
(va_wp_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE)
(va_wpProof_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE))
//--
//-- Gcm_blocks
#push-options "--z3rlimit 1000"
val va_code_Gcm_blocks : alg:algorithm -> offset:int -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks alg offset =
(va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx))
(va_CCons (va_code_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9) (va_const_opr64
32)) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRsp)
(offset + 0)) (va_CCons (va_code_Gcm_blocks_auth ()) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8)) (va_CCons
(va_code_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp) (offset + 16))
(va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp)
(offset + 24)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13))
(va_CCons (va_code_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64
rR8) 0 Public) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_reg_opr64_reg64 rRbp) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_Load_one_lsb
(va_op_xmm_xmm 10)) (va_CCons (va_code_VPaddd (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)
(va_op_xmm_xmm 10)) (va_CCons (va_code_AES_GCM_decrypt_6mult alg) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11) (va_op_reg_opr64_reg64
rRbp) 32 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx))
(va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp)
(offset + 32)) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRdi)
(va_op_reg_opr64_reg64 rRsp) (offset + 40)) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 48)) (va_CCons
(va_code_Mov64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRdx)) (va_CCons
(va_code_InitPshufbMask (va_op_xmm_xmm 9) (va_op_reg_opr64_reg64 rR12)) (va_CCons
(va_code_Pshufb (va_op_xmm_xmm 11) (va_op_xmm_xmm 9)) (va_CCons (va_code_Gcm_blocks128 alg)
(va_CCons (va_code_Stack_lemma ()) (va_CCons (va_code_Add64 (va_op_dst_opr64_reg64 rR14)
(va_opr_code_Stack (va_op_reg64_reg64 rRsp) (offset + 24) Public)) (va_CCons (va_code_IMul64
(va_op_dst_opr64_reg64 rR14) (va_const_opr64 16)) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rR13) (va_op_reg_opr64_reg64 rRsp) (offset + 64)) (va_CCons (va_IfElse
(va_cmp_gt (va_op_cmp_reg64 rR13) (va_op_cmp_reg64 rR14)) (va_Block (va_CCons
(va_code_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 56))
(va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR13)) (va_CCons
(va_code_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 15)) (va_CCons
(va_code_Gcm_extra_bytes alg) (va_CCons (va_Block (va_CNil ())) (va_CNil ()))))))) (va_Block
(va_CNil ()))) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15))
(va_CCons (va_code_Gcm_make_length_quad ()) (va_CCons (va_code_Ghash_register ()) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRbp) 0 Secret) (va_CCons (va_code_Gctr_register alg) (va_CCons (va_Block (va_CNil ()))
(va_CNil ()))))))))))))))))))))))))))))))))))))
val va_codegen_success_Gcm_blocks : alg:algorithm -> offset:int -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks alg offset =
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx))
(va_pbool_and (va_codegen_success_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9)
(va_const_opr64 32)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64
rRbx) (va_op_reg_opr64_reg64 rRsp) (offset + 0)) (va_pbool_and
(va_codegen_success_Gcm_blocks_auth ()) (va_pbool_and (va_codegen_success_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8)) (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp)
(offset + 16)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRdx)
(va_op_reg_opr64_reg64 rRsp) (offset + 24)) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13)) (va_pbool_and (va_codegen_success_Mov128
(va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_Load128_buffer
(va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rR8) 0 Public)
(va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_reg_opr64_reg64 rRbp) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and
(va_codegen_success_Load_one_lsb (va_op_xmm_xmm 10)) (va_pbool_and (va_codegen_success_VPaddd
(va_op_xmm_xmm 1) (va_op_xmm_xmm 1) (va_op_xmm_xmm 10)) (va_pbool_and
(va_codegen_success_AES_GCM_decrypt_6mult alg) (va_pbool_and (va_codegen_success_Load128_buffer
(va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11) (va_op_reg_opr64_reg64 rRbp) 32 Secret)
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx))
(va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRax)
(va_op_reg_opr64_reg64 rRsp) (offset + 32)) (va_pbool_and (va_codegen_success_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 40)) (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp)
(offset + 48)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR14)
(va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_InitPshufbMask (va_op_xmm_xmm 9)
(va_op_reg_opr64_reg64 rR12)) (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 11)
(va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_Gcm_blocks128 alg) (va_pbool_and
(va_codegen_success_Stack_lemma ()) (va_pbool_and (va_codegen_success_Add64
(va_op_dst_opr64_reg64 rR14) (va_opr_code_Stack (va_op_reg64_reg64 rRsp) (offset + 24) Public))
(va_pbool_and (va_codegen_success_IMul64 (va_op_dst_opr64_reg64 rR14) (va_const_opr64 16))
(va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rR13)
(va_op_reg_opr64_reg64 rRsp) (offset + 64)) (va_pbool_and (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp)
(offset + 56)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR10)
(va_op_opr64_reg64 rR13)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rR10)
(va_const_opr64 15)) (va_codegen_success_Gcm_extra_bytes alg)))) (va_pbool_and
(va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15)) (va_pbool_and
(va_codegen_success_Gcm_make_length_quad ()) (va_pbool_and (va_codegen_success_Ghash_register
()) (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRbp) 0 Secret) (va_pbool_and
(va_codegen_success_Gctr_register alg) (va_ttrue ()))))))))))))))))))))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks (va_mods:va_mods_t) (alg:algorithm) (offset:int) (auth_b:buffer128)
(abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128)
(out128_b:buffer128) (inout_b:buffer128) (iv_b:buffer128) (scratch_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit
(va_code_Gcm_blocks alg offset)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 0) (va_get_stack va_s) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 8) (va_get_stack va_s) in let
(out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 16) (va_get_stack va_s) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 24) (va_get_stack va_s) in let
(in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 32) (va_get_stack va_s) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 40) (va_get_stack va_s) in let
(len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset
+ 48) (va_get_stack va_s) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 56) (va_get_stack va_s) in let
(plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s
+ offset + 64) (va_get_stack va_s) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_old_s)) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 463 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 464 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9) (va_const_opr64 32))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 465 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRsp) (offset + 0))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 466 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks_auth auth_b abytes_b hkeys_b h_LE) (fun (va_s:va_state)
(auth_quad_seq:(seq quad32)) -> let (y_0:quad32) = Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 0 0 0 0 in let (y_auth_bytes:quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 473 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 474 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp) (offset + 16))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 475 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 24))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 476 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 477 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (fun (va_s:va_state) _ -> let
(iv_BE:Vale.X64.Decls.quad32) = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2
va_old_s) in let (ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32
iv_BE 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 483 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64
rR8) 0 Public iv_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 485 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_reg_opr64_reg64 rRbp)
(va_op_xmm_xmm 1) 0 Secret scratch_b 0) (fun (va_s:va_state) _ -> let (j0:quad32) = va_get_xmm
1 va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 487 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load_one_lsb (va_op_xmm_xmm 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 489 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_VPaddd (va_op_xmm_xmm 1) (va_op_xmm_xmm 1) (va_op_xmm_xmm 10)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 491 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AES_GCM_decrypt_6mult alg h_LE iv_b in128x6_b out128x6_b scratch_b key round_keys
keys_b hkeys_b) (fun (va_s:va_state) _ -> let (y_cipher128x6:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in let (auth_in:(seq quad32)) =
auth_quad_seq in let (va_arg138:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) =
Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b in let
(va_arg137:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg136:Vale.Def.Types_s.quad32) = y_auth_bytes in let (va_arg135:Vale.Def.Types_s.quad32) =
y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 494 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_ghash_incremental0_append h_LE va_arg135 va_arg136
y_cipher128x6 va_arg137 va_arg138) (let auth_in = FStar.Seq.Base.append #quad32 auth_in
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 498 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11)
(va_op_reg_opr64_reg64 rRbp) 32 Secret scratch_b 2) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 499 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 500 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 32))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 501 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 40))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 502 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 48))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 503 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 504 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_InitPshufbMask (va_op_xmm_xmm 9) (va_op_reg_opr64_reg64 rR12)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 505 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pshufb (va_op_xmm_xmm 11) (va_op_xmm_xmm 9)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 506 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks128 alg in128_b out128_b key round_keys keys_b hkeys_b h_LE) (fun
(va_s:va_state) _ -> let (y_cipher128:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in let (va_arg134:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b in let
(va_arg133:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg132:Vale.Def.Types_s.quad32) = y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 508 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_ghash_incremental0_append h_LE va_arg132 y_cipher128x6
y_cipher128 va_arg133 va_arg134) (let auth_in = FStar.Seq.Base.append #quad32 auth_in
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 512 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Stack_lemma (va_op_reg64_reg64 rRsp) (offset + 24) Public) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 512 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Add64 (va_op_dst_opr64_reg64 rR14) (va_opr_code_Stack (va_op_reg64_reg64 rRsp)
(offset + 24) Public)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 513 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_IMul64 (va_op_dst_opr64_reg64 rR14) (va_const_opr64 16)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 514 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rR13) (va_op_reg_opr64_reg64 rRsp) (offset + 64))
(fun (va_s:va_state) _ -> let (y_inout:Vale.Def.Types_s.quad32) = y_cipher128 in let
(plain_byte_seq:(seq quad32)) = empty_seq_quad32 in let (cipher_byte_seq:(seq quad32)) =
empty_seq_quad32 in let (va_arg131:Vale.Def.Types_s.quad32) = va_get_xmm 11 va_s in let
(va_arg130:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in let
(va_arg129:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = cipher_byte_seq in let
(va_arg128:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = plain_byte_seq in let
(va_arg127:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 519 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.gctr_partial_opaque_init va_arg127 va_arg128 va_arg129 va_arg130
va_arg131) (let (total_bytes:(va_int_at_least 0)) = FStar.Seq.Base.length #quad32 auth_quad_seq
`op_Multiply` 16 + plain_num_bytes in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 523 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_qIf va_mods (Cmp_gt (va_op_cmp_reg64 rR13) (va_op_cmp_reg64 rR14)) (qblock va_mods (fun
(va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 525 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 56))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 526 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR13)) (fun (va_s:va_state) _
-> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 527 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.Poly1305.Math.lemma_poly_bits64 ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 528 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 15)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 532 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes y_0 auth_in
h_LE) (fun (va_s:va_state) _ -> let y_inout = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm
8 va_s) in let (raw_auth_quads:(FStar.Seq.Base.seq quad32)) = FStar.Seq.Base.append #quad32
auth_in (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b) in va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 536 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun a_1906 (s_1907:(FStar.Seq.Base.seq a_1906)) (i_1908:Prims.nat) (j_1909:Prims.nat) -> let
(j_1869:Prims.nat) = j_1909 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1908
j_1869) (Prims.op_LessThanOrEqual j_1869 (FStar.Seq.Base.length #a_1906 s_1907))))
Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 total_bytes)
(fun _ -> let (auth_input_bytes:(FStar.Seq.Base.seq Vale.Def.Types_s.nat8)) =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
raw_auth_quads) 0 total_bytes in let (padded_auth_bytes:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in let auth_in =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes in let plain_byte_seq =
Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b in let cipher_byte_seq =
Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b in va_QEmpty ((auth_in,
cipher_byte_seq, plain_byte_seq, y_inout)))))))))) (qblock va_mods (fun (va_s:va_state) ->
va_QEmpty ((auth_in, cipher_byte_seq, plain_byte_seq, y_inout))))) (fun (va_s:va_state) va_g ->
let ((auth_in:(seq quad32)), (cipher_byte_seq:(seq quad32)), (plain_byte_seq:(seq quad32)),
(y_inout:Vale.Def.Types_s.quad32)) = va_g in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 547 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 548 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_make_length_quad ()) (fun (va_s:va_state) _ -> let
(length_quad32:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 0
va_s) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 551 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_register hkeys_b h_LE y_inout) (fun (va_s:va_state) _ -> let
(y_final:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s)
in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 554 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRbp) 0 Secret scratch_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 557 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gctr_register alg key round_keys keys_b) (fun (va_s:va_state) _ -> let
(va_arg126:Vale.Def.Types_s.quad32) = va_get_xmm 8 va_s in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 560 column 40 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.Arch.Types.le_seq_quad32_to_bytes_of_singleton va_arg126)
(va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 561 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun (icb_BE_677:Vale.Def.Types_s.quad32) (plain_LE_678:Vale.Def.Types_s.quad32)
(alg_679:Vale.AES.AES_common_s.algorithm) (key_680:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32))
(i_681:Prims.int) -> Vale.AES.AES_s.is_aes_key_LE alg_679 key_680) j0 y_final alg key 0) (fun _
-> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 561 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 8 va_s == Vale.AES.GCTR_s.gctr_encrypt_block j0 y_final alg key 0) (let
(plain128:(FStar.Seq.Base.seq Vale.X64.Decls.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in let
(cipher128:(FStar.Seq.Base.seq Vale.X64.Decls.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) in128_b) in va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 566 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.length #quad32 plain_byte_seq == 0 ==> FStar.Seq.Base.equal
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 plain128 plain_byte_seq)
plain128) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 567 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.length #quad32 cipher_byte_seq == 0 ==> FStar.Seq.Base.equal
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 cipher128 cipher_byte_seq)
cipher128) (let (va_arg125:Vale.Def.Types_s.quad32) = Vale.AES.GCTR.inc32lite ctr_BE_2 len128x6
in let (va_arg124:Vale.Def.Types_s.quad32) = ctr_BE_2 in let (va_arg123:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) = key in let (va_arg122:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32))
= Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b in let
(va_arg121:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) in128_b in let (va_arg120:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) out128x6_b in let
(va_arg119:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_old_s) in128x6_b in let (va_arg118:Prims.nat) = len128 in let
(va_arg117:Prims.nat) = len128x6 in let (va_arg116:Vale.AES.AES_common_s.algorithm) = alg in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 569 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.lemma_gctr_partial_append va_arg116 va_arg117 va_arg118
va_arg119 va_arg120 va_arg121 va_arg122 va_arg123 va_arg124 va_arg125) (let
(va_arg115:Vale.Def.Types_s.quad32) = Vale.AES.GCTR.inc32lite (Vale.AES.GCTR.inc32lite ctr_BE_2
len128x6) len128 in let (va_arg114:Vale.Def.Types_s.quad32) = ctr_BE_2 in let
(va_arg113:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in let
(va_arg112:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = cipher_byte_seq in let
(va_arg111:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = plain_byte_seq in let
(va_arg110:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b) in let
(va_arg109:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in let (va_arg108:Prims.nat) =
FStar.Seq.Base.length #quad32 plain_byte_seq in let (va_arg107:Prims.nat) = len128x6 + len128
in let (va_arg106:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 575 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.lemma_gctr_partial_append va_arg106 va_arg107 va_arg108
va_arg109 va_arg110 va_arg111 va_arg112 va_arg113 va_arg114 va_arg115) (let
(va_arg105:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg104:Vale.Def.Types_s.quad32) = y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 583 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_hash_append2 h_LE va_arg104 y_inout y_final va_arg105
length_quad32) (let auth_in = FStar.Seq.Base.append #quad32 auth_in (FStar.Seq.Base.create
#Vale.Def.Types_s.quad32 1 length_quad32) in let (va_arg103:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = auth_in in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 585 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.ghash_incremental_to_ghash h_LE va_arg103) (va_QEmpty
(()))))))))))))))))))))))))))))))))))))))))))))))))
val va_lemma_Gcm_blocks : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> offset:int ->
auth_b:buffer128 -> abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 ->
in128_b:buffer128 -> out128_b:buffer128 -> inout_b:buffer128 -> iv_b:buffer128 ->
scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks alg offset) va_s0 /\ va_get_ok va_s0 /\
(let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in sse_enabled /\ movbe_enabled /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp
va_s0 + offset + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet
1 va_s0) (va_get_reg64 rRdi va_s0) auth_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2
va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6
va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) in128_ptr in128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1
va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) inout_ptr inout_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0) hkeys_b 8
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet
1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b
(va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer128
scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) /\
Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32
/\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let
(ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in let
(plain_in:(seq quad32)) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) then FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) else FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in let (cipher_out:(seq quad32)) = (if (plain_num_bytes
> (len128x6 + len128) `op_Multiply` 128 `op_Division` 8) then FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) else
FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM)
out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b)) in let
(cipher_bound:nat) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128 `op_Division`
8) then (len128x6 + len128 + 1) else (len128x6 + len128)) in Vale.AES.GCTR.gctr_partial alg
cipher_bound plain_in cipher_out key ctr_BE_2 /\ (let (length_quad:quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) (8
`op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply` plain_num_bytes) 0) in let
(raw_auth_quads:(seq quad32)) = (if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) then FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b) else Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0)
auth_b) in let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64 rRsi va_s0) in let
(padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in let
(auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes in let
(raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 (FStar.Seq.Base.append #quad32
auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in let (total_bytes:nat) =
FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 + plain_num_bytes in let
(raw_quad_seq:(seq quad32)) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) then (let (ab:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32 raw_quad_seq
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let (pb:(seq
nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32 pb) else
raw_quad_seq) in let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 raw_quad_seq
(FStar.Seq.Base.create #quad32 1 length_quad) in va_get_xmm 8 va_sM ==
Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE h_LE auth_quad_seq) alg
key 0))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM
(va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm
13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm
9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM
(va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM
(va_update_reg64 rRbp va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0)))))))))))))))))))))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_blocks va_b0 va_s0 alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5;
va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14;
va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12;
va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp;
va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx;
va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks va_mods alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks alg offset) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 283 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
let (h_LE:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.X64.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 0 va_s0)) in label va_range1
"***** POSTCONDITION NOT MET AT line 396 column 56 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 397 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 398 column 57 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 399 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 400 column 58 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet
6 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 403 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(plain_num_bytes < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 404 column 38 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRsi va_s0 < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 406 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 408 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (ctr_BE_1:quad32) = iv_BE in label va_range1
"***** POSTCONDITION NOT MET AT line 409 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in label va_range1
"***** POSTCONDITION NOT MET AT line 412 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (plain_in:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in label va_range1
"***** POSTCONDITION NOT MET AT line 421 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (cipher_out:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_sM) out128_b)) in label va_range1
"***** POSTCONDITION NOT MET AT line 430 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (cipher_bound:nat) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> len128x6 + len128 + 1) (fun _ -> len128x6 + len128) in label
va_range1
"***** POSTCONDITION NOT MET AT line 434 column 77 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg cipher_bound plain_in cipher_out key ctr_BE_2) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 438 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (length_quad:quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 0 0 0 0) (8 `op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply`
plain_num_bytes) 0) in label va_range1
"***** POSTCONDITION NOT MET AT line 440 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_auth_quads:(seq quad32)) = va_if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b)) (fun _ -> Vale.X64.Decls.s128 (va_get_mem_heaplet 1
va_s0) auth_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 444 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64 rRsi va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 445 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in label
va_range1
"***** POSTCONDITION NOT MET AT line 446 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes
in label va_range1
"***** POSTCONDITION NOT MET AT line 448 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 (FStar.Seq.Base.append #quad32
auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 452 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (total_bytes:nat) = FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 +
plain_num_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 453 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_quad_seq:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply`
128 `op_Division` 8) (fun _ -> let (ab:(seq nat8)) = FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32
raw_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let
(pb:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32
pb) (fun _ -> raw_quad_seq) in label va_range1
"***** POSTCONDITION NOT MET AT line 460 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 raw_quad_seq
(FStar.Seq.Base.create #quad32 1 length_quad) in label va_range1
"***** POSTCONDITION NOT MET AT line 461 column 106 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 8 va_sM == Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE
h_LE auth_quad_seq) alg key 0)))))))))))))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_blocks (alg:algorithm) (offset:int) (auth_b:buffer128) (abytes_b:buffer128)
(in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128) (out128_b:buffer128)
(inout_b:buffer128) (iv_b:buffer128) (scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
let (h_LE:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.X64.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 0 va_s0)) in sse_enabled /\
movbe_enabled /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0)
(va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet
1 va_s0) (va_get_reg64 rRdi va_s0) auth_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2
va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6
va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) in128_ptr in128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1
va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) inout_ptr inout_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0) hkeys_b 8
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)))) /\ (forall (va_x_mem:vale_heap)
(va_x_rax:nat64) (va_x_rbx:nat64) (va_x_rcx:nat64) (va_x_rdx:nat64) (va_x_rdi:nat64)
(va_x_rsi:nat64) (va_x_rbp:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64)
(va_x_r11:nat64) (va_x_r12:nat64) (va_x_r13:nat64) (va_x_r14:nat64) (va_x_r15:nat64)
(va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32)
(va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm9:quad32)
(va_x_xmm10:quad32) (va_x_xmm11:quad32) (va_x_xmm12:quad32) (va_x_xmm13:quad32)
(va_x_xmm14:quad32) (va_x_xmm15:quad32) (va_x_heap1:vale_heap) (va_x_heap2:vale_heap)
(va_x_heap3:vale_heap) (va_x_heap5:vale_heap) (va_x_heap6:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 6
va_x_heap6 (va_upd_mem_heaplet 5 va_x_heap5 (va_upd_mem_heaplet 3 va_x_heap3
(va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 15 va_x_xmm15
(va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12 (va_upd_xmm 11
va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (va_upd_xmm 8 va_x_xmm8
(va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4
(va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0
(va_upd_reg64 rR15 va_x_r15 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13
(va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10
(va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRbp va_x_rbp (va_upd_reg64
rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRcx
va_x_rcx (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem
va_s0))))))))))))))))))))))))))))))))))))) in va_get_ok va_sM /\ (let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet
1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b
(va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer128
scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) /\
Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32
/\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let
(ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in let
(plain_in:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in let (cipher_out:(seq quad32)) = va_if
(plain_num_bytes > (len128x6 + len128) `op_Multiply` 128 `op_Division` 8) (fun _ ->
FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_sM) out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM)
inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) in let (cipher_bound:nat) = va_if (plain_num_bytes > (len128x6 + len128)
`op_Multiply` 128 `op_Division` 8) (fun _ -> len128x6 + len128 + 1) (fun _ -> len128x6 +
len128) in Vale.AES.GCTR.gctr_partial alg cipher_bound plain_in cipher_out key ctr_BE_2 /\ (let
(length_quad:quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) (8
`op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply` plain_num_bytes) 0) in let
(raw_auth_quads:(seq quad32)) = va_if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b)) (fun _ -> Vale.X64.Decls.s128 (va_get_mem_heaplet 1
va_s0) auth_b) in let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64
rRsi va_s0) in let (padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits
auth_input_bytes in let (auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32
padded_auth_bytes in let (raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32
(FStar.Seq.Base.append #quad32 auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0)
in128x6_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in let (total_bytes:nat)
= FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 + plain_num_bytes in let
(raw_quad_seq:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> let (ab:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32 raw_quad_seq
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let (pb:(seq
nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32 pb) (fun
_ -> raw_quad_seq) in let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32
raw_quad_seq (FStar.Seq.Base.create #quad32 1 length_quad) in va_get_xmm 8 va_sM ==
Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE h_LE auth_quad_seq) alg
key 0))) ==> va_k va_sM (())))
val va_wpProof_Gcm_blocks : alg:algorithm -> offset:int -> auth_b:buffer128 -> abytes_b:buffer128
-> in128x6_b:buffer128 -> out128x6_b:buffer128 -> in128_b:buffer128 -> out128_b:buffer128 ->
inout_b:buffer128 -> iv_b:buffer128 -> scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq
quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit ->
Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b
in128_b out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks alg offset) ([va_Mod_flags;
va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2;
va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm
11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5;
va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15;
va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10;
va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi;
va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) va_s0
va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b
iv_b scratch_b key round_keys keys_b hkeys_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_blocks (va_code_Gcm_blocks alg offset) va_s0 alg offset auth_b
abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b scratch_b key round_keys keys_b
hkeys_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM
(va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm
13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm
9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM
(va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM
(va_update_reg64 rRbp va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))))))))))))))))))))))))))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_blocks (alg:algorithm) (offset:int) (auth_b:buffer128) (abytes_b:buffer128)
(in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128) (out128_b:buffer128)
(inout_b:buffer128) (iv_b:buffer128) (scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit (va_code_Gcm_blocks alg
offset)) =
(va_QProc (va_code_Gcm_blocks alg offset) ([va_Mod_flags; va_Mod_mem_heaplet 6;
va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1;
va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10;
va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm
3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64
rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64
rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64
rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_Gcm_blocks alg offset auth_b
abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b scratch_b key round_keys keys_b
hkeys_b) (va_wpProof_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b))
#pop-options
//--
//-- Gcm_blocks_wrapped
#push-options "--z3rlimit 60"
val va_code_Gcm_blocks_wrapped : alg:algorithm -> offset:int -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks_wrapped alg offset =
(va_Block (va_CCons (va_code_Gcm_blocks alg offset) (va_CCons (va_Block (va_CNil ())) (va_CCons
(va_Block (va_CNil ())) (va_CNil ())))))
val va_codegen_success_Gcm_blocks_wrapped : alg:algorithm -> offset:int -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks_wrapped alg offset =
(va_pbool_and (va_codegen_success_Gcm_blocks alg offset) (va_ttrue ())) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Stack.fsti.checked",
"Vale.X64.QuickCodes.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.InsVector.fsti.checked",
"Vale.X64.InsStack.fsti.checked",
"Vale.X64.InsMem.fsti.checked",
"Vale.X64.InsBasic.fsti.checked",
"Vale.X64.InsAes.fsti.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Lib.Meta.fsti.checked",
"Vale.Lib.Basic.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_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",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.X64.GHash.fsti.checked",
"Vale.AES.X64.GF128_Mul.fsti.checked",
"Vale.AES.X64.GCTR.fsti.checked",
"Vale.AES.X64.GCMencryptOpt.fsti.checked",
"Vale.AES.X64.AESopt2.fsti.checked",
"Vale.AES.X64.AESopt.fsti.checked",
"Vale.AES.X64.AESGCM.fsti.checked",
"Vale.AES.X64.AES.fsti.checked",
"Vale.AES.OptPublic.fsti.checked",
"Vale.AES.GHash_s.fst.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_s.fst.checked",
"Vale.AES.GCTR.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"Vale.AES.GCM.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_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.X64.GCMdecryptOpt.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Lib.Basic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"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.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_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": "Vale.Def.Types_s",
"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": "FStar.Seq",
"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.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"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.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_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": "Vale.Def.Types_s",
"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": "FStar.Seq",
"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.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 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": 60,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
va_mods: Vale.X64.QuickCode.va_mods_t ->
alg: Vale.AES.AES_common_s.algorithm ->
offset: Prims.int ->
auth_b: Vale.X64.Memory.buffer128 ->
abytes_b: Vale.X64.Memory.buffer128 ->
in128x6_b: Vale.X64.Memory.buffer128 ->
out128x6_b: Vale.X64.Memory.buffer128 ->
in128_b: Vale.X64.Memory.buffer128 ->
out128_b: Vale.X64.Memory.buffer128 ->
inout_b: Vale.X64.Memory.buffer128 ->
iv_b: Vale.X64.Memory.buffer128 ->
iv: Vale.AES.GCM_s.supported_iv_LE ->
scratch_b: Vale.X64.Memory.buffer128 ->
key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 ->
round_keys: FStar.Seq.Base.seq Vale.X64.Decls.quad32 ->
keys_b: Vale.X64.Memory.buffer128 ->
hkeys_b: Vale.X64.Memory.buffer128 ->
expected_tag: FStar.Seq.Base.seq Vale.X64.Memory.nat8
-> Vale.X64.QuickCode.va_quickCode Prims.unit
(Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_blocks_wrapped alg offset) | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.QuickCode.va_mods_t",
"Vale.AES.AES_common_s.algorithm",
"Prims.int",
"Vale.X64.Memory.buffer128",
"Vale.AES.GCM_s.supported_iv_LE",
"FStar.Seq.Base.seq",
"Vale.X64.Memory.nat32",
"Vale.X64.Decls.quad32",
"Vale.X64.Memory.nat8",
"Vale.X64.QuickCodes.qblock",
"Prims.unit",
"Prims.Cons",
"Vale.X64.Decls.va_code",
"Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_blocks",
"Vale.X64.Machine_s.Block",
"Vale.X64.Decls.ins",
"Vale.X64.Decls.ocmp",
"Prims.Nil",
"Vale.X64.Machine_s.precode",
"Vale.X64.Decls.va_state",
"Vale.X64.QuickCodes.va_QBind",
"Vale.X64.QuickCodes.va_range1",
"Vale.AES.X64.GCMdecryptOpt.va_quick_Gcm_blocks",
"Vale.X64.QuickCodes.va_qAssertSquash",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_Multiply",
"Vale.X64.Decls.va_get_reg64",
"Vale.X64.Machine_s.rRsi",
"Prims.op_LessThanOrEqual",
"Prims.squash",
"Vale.X64.QuickCodes.va_qPURE",
"Prims.pure_post",
"Prims.op_Addition",
"FStar.Seq.Base.length",
"Vale.Def.Types_s.quad32",
"Prims.op_LessThan",
"Prims.eq2",
"Prims.nat",
"Vale.AES.AES_s.is_aes_key_LE",
"Vale.AES.GCM_s.compute_iv_BE",
"Prims.op_Equality",
"Vale.AES.AES_s.aes_encrypt_LE",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Words_s.nat32",
"Vale.Def.Types_s.reverse_bytes_quad32",
"Vale.Def.Types_s.insert_nat64",
"Vale.AES.GCTR.gctr_partial",
"Prims.op_GreaterThan",
"Prims.bool",
"FStar.Seq.Base.append",
"Vale.AES.GCTR_s.inc32",
"Vale.AES.GCTR_s.gctr_encrypt_block",
"Vale.AES.GHash_s.ghash_LE",
"Vale.Def.Types_s.le_bytes_to_seq_quad32",
"Vale.AES.GCTR_s.pad_to_128_bits",
"FStar.Seq.Base.slice",
"Vale.Def.Words_s.nat8",
"Vale.Def.Types_s.le_seq_quad32_to_bytes",
"FStar.Seq.Base.create",
"Prims.l_Forall",
"Prims.l_imp",
"Vale.Def.Types_s.le_quad32_to_bytes",
"Vale.AES.GCM.gcm_decrypt_LE_tag",
"Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE",
"Vale.AES.GCM.gcm_blocks_dec_helper_simplified",
"Prims.op_AmpAmp",
"Vale.Def.Types_s.nat8",
"FStar.Pervasives.Native.fst",
"Vale.AES.GCM_s.gcm_decrypt_LE",
"Vale.AES.GCM.gcm_blocks_helper_dec_simplified",
"Vale.X64.QuickCodes.va_QEmpty",
"Vale.X64.Decls.s128",
"Vale.X64.Decls.va_get_mem_heaplet",
"Vale.X64.Decls.buffer128_read",
"Vale.X64.QuickCodes.quickCodes",
"Vale.X64.Decls.va_get_xmm",
"Vale.Def.Types_s.nat32",
"Vale.Def.Words_s.nat64",
"Vale.X64.Stack_i.load_stack64",
"Vale.X64.Machine_s.rRsp",
"Vale.X64.Decls.va_get_stack",
"Vale.X64.State.vale_state",
"Vale.X64.QuickCode.va_quickCode",
"Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_blocks_wrapped"
] | [] | false | false | false | false | false | let va_qcode_Gcm_blocks_wrapped
(va_mods: va_mods_t)
(alg: algorithm)
(offset: int)
(auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b: buffer128)
(iv: supported_iv_LE)
(scratch_b: buffer128)
(key: (seq nat32))
(round_keys: (seq quad32))
(keys_b hkeys_b: buffer128)
(expected_tag: (seq nat8))
: (va_quickCode unit (va_code_Gcm_blocks_wrapped alg offset)) =
| (qblock va_mods
(fun (va_s: va_state) ->
let va_old_s:va_state = va_s in
let abytes_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 0) (va_get_stack va_s)
in
let in128x6_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 8) (va_get_stack va_s)
in
let out128x6_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 16) (va_get_stack va_s)
in
let len128x6:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 24) (va_get_stack va_s)
in
let in128_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 32) (va_get_stack va_s)
in
let out128_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 40) (va_get_stack va_s)
in
let len128:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 48) (va_get_stack va_s)
in
let inout_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 56) (va_get_stack va_s)
in
let plain_num_bytes:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 64) (va_get_stack va_s)
in
va_QBind va_range1
"***** PRECONDITION NOT MET AT line 739 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b
inout_b iv_b scratch_b key round_keys keys_b hkeys_b)
(fun (va_s: va_state) _ ->
va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 741 column 37 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(8 `op_Multiply` (va_get_reg64 rRsi va_old_s) >= 0 /\
8 `op_Multiply` (va_get_reg64 rRsi va_old_s) <= 18446744073709551615 /\
8 `op_Multiply` plain_num_bytes >= 0 /\
8 `op_Multiply` plain_num_bytes <= 18446744073709551615)
(fun _ ->
let va_arg55:Vale.Def.Types_s.quad32 =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
(8 `op_Multiply` (va_get_reg64 rRsi va_old_s))
1)
(8 `op_Multiply` plain_num_bytes)
0)
in
let va_arg54:Vale.Def.Types_s.quad32 = va_get_xmm 8 va_s in
let va_arg53:Vale.Def.Types_s.quad32 =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b
2
(va_get_mem_heaplet 0 va_s))
in
let va_arg52:Vale.Def.Types_s.quad32 =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_old_s)
in
let va_arg51:Vale.AES.GCM_s.supported_iv_LE = iv in
let va_arg50:Prims.nat = va_get_reg64 rRsi va_old_s in
let va_arg49:Prims.nat = plain_num_bytes in
let va_arg48:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32) =
Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b
in
let va_arg47:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32) =
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b
in
let va_arg46:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32) =
Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) out128x6_b
in
let va_arg45:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32) =
Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b
in
let va_arg44:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32) =
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b
in
let va_arg43:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32) =
Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b
in
let va_arg42:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32) =
Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_old_s) abytes_b
in
let va_arg41:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32) =
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) auth_b
in
let va_arg40:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32) = key in
let va_arg39:Vale.AES.AES_common_s.algorithm = alg in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 741 column 37 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_: unit) ->
Vale.AES.GCM.gcm_blocks_dec_helper_simplified va_arg39 va_arg40 va_arg41
va_arg42 va_arg43 va_arg44 va_arg45 va_arg46 va_arg47 va_arg48 va_arg49
va_arg50 va_arg51 va_arg52 va_arg53 va_arg54 va_arg55)
(let auth_raw_quads:(FStar.Seq.Base.seq Vale.X64.Decls.quad32) =
FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) auth_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_old_s) abytes_b)
in
va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 751 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun
a_1906
(s_1907: (FStar.Seq.Base.seq a_1906))
(i_1908: Prims.nat)
(j_1909: Prims.nat)
->
let j_1869:Prims.nat = j_1909 in
Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1908 j_1869)
(Prims.op_LessThanOrEqual j_1869
(FStar.Seq.Base.length #a_1906 s_1907)))) Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads)
0
(va_get_reg64 rRsi va_old_s))
(fun _ ->
let auth_bytes:(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads)
0
(va_get_reg64 rRsi va_old_s)
in
let va_arg38:Vale.Def.Types_s.quad32 =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_old_s)
in
let va_arg37:Vale.AES.GCM_s.supported_iv_LE = iv in
let va_arg36:Prims.nat = plain_num_bytes in
let va_arg35:(FStar.Seq.Base.seq Vale.Def.Words_s.nat8) =
expected_tag
in
let va_arg34:(FStar.Seq.Base.seq Vale.Def.Words_s.nat8) =
auth_bytes
in
let va_arg33:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32) =
Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b
in
let va_arg32:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32) =
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b
in
let va_arg31:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32) =
Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) out128x6_b
in
let va_arg30:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32) =
Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b
in
let va_arg29:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32) =
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b
in
let va_arg28:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32) =
Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b
in
let va_arg27:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32) = key in
let va_arg26:Vale.AES.AES_common_s.algorithm = alg in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 752 column 37 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_: unit) ->
Vale.AES.GCM.gcm_blocks_helper_dec_simplified va_arg26 va_arg27
va_arg28 va_arg29 va_arg30 va_arg31 va_arg32 va_arg33 va_arg34
va_arg35 va_arg36 va_arg37 va_arg38)
(va_QEmpty (())))))))) | false |
Vale.AES.X64.GCMdecryptOpt.fst | Vale.AES.X64.GCMdecryptOpt.va_qcode_Gcm_blocks_decrypt_stdcall | val va_qcode_Gcm_blocks_decrypt_stdcall
(va_mods: va_mods_t)
(win: bool)
(alg: algorithm)
(auth_b: buffer128)
(auth_bytes auth_num: nat64)
(keys_b iv_b: buffer128)
(iv: supported_iv_LE)
(hkeys_b abytes_b in128x6_b out128x6_b: buffer128)
(len128x6_num: nat64)
(in128_b out128_b: buffer128)
(len128_num: nat64)
(inout_b: buffer128)
(cipher_num: nat64)
(scratch_b tag_b: buffer128)
(key: (seq nat32))
: (va_quickCode unit (va_code_Gcm_blocks_decrypt_stdcall win alg)) | val va_qcode_Gcm_blocks_decrypt_stdcall
(va_mods: va_mods_t)
(win: bool)
(alg: algorithm)
(auth_b: buffer128)
(auth_bytes auth_num: nat64)
(keys_b iv_b: buffer128)
(iv: supported_iv_LE)
(hkeys_b abytes_b in128x6_b out128x6_b: buffer128)
(len128x6_num: nat64)
(in128_b out128_b: buffer128)
(len128_num: nat64)
(inout_b: buffer128)
(cipher_num: nat64)
(scratch_b tag_b: buffer128)
(key: (seq nat32))
: (va_quickCode unit (va_code_Gcm_blocks_decrypt_stdcall win alg)) | let va_qcode_Gcm_blocks_decrypt_stdcall (va_mods:va_mods_t) (win:bool) (alg:algorithm)
(auth_b:buffer128) (auth_bytes:nat64) (auth_num:nat64) (keys_b:buffer128) (iv_b:buffer128)
(iv:supported_iv_LE) (hkeys_b:buffer128) (abytes_b:buffer128) (in128x6_b:buffer128)
(out128x6_b:buffer128) (len128x6_num:nat64) (in128_b:buffer128) (out128_b:buffer128)
(len128_num:nat64) (inout_b:buffer128) (cipher_num:nat64) (scratch_b:buffer128) (tag_b:buffer128)
(key:(seq nat32)) : (va_quickCode unit (va_code_Gcm_blocks_decrypt_stdcall win alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(auth_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s)
(fun _ -> va_get_reg64 rRdi va_s) in let (auth_num_bytes:(va_int_range 0 18446744073709551615))
= va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in let
(auth_len:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rR8 va_s)
(fun _ -> va_get_reg64 rRdx va_s) in let (keys_ptr:(va_int_range 0 18446744073709551615)) =
va_if win (fun _ -> va_get_reg64 rR9 va_s) (fun _ -> va_get_reg64 rRcx va_s) in let
(iv_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 32 + 8 + 0) (va_get_stack va_s)) (fun _
-> va_get_reg64 rR8 va_s) in let (xip:(va_int_range 0 18446744073709551615)) = va_if win (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 32 + 8 + 8) (va_get_stack va_s))
(fun _ -> va_get_reg64 rR9 va_s) in let (abytes_ptr:(va_int_range 0 18446744073709551615)) =
va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 16)
(va_get_stack va_s)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 0)
(va_get_stack va_s)) in let (in128x6_ptr:(va_int_range 0 18446744073709551615)) = va_if win
(fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 24) (va_get_stack va_s))
(fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 8) (va_get_stack va_s))
in let (out128x6_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 32) (va_get_stack va_s)) (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 16) (va_get_stack va_s)) in let
(len128x6:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 40) (va_get_stack va_s)) (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 24) (va_get_stack va_s)) in let
(in128_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 48) (va_get_stack va_s)) (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 32) (va_get_stack va_s)) in let
(out128_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 56) (va_get_stack va_s)) (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 40) (va_get_stack va_s)) in let
(len128:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 64) (va_get_stack va_s)) (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 48) (va_get_stack va_s)) in let
(inout_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 72) (va_get_stack va_s)) (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 56) (va_get_stack va_s)) in let
(cipher_num_bytes:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 80) (va_get_stack va_s)) (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 64) (va_get_stack va_s)) in let
(scratch_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 88) (va_get_stack va_s)) (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 72) (va_get_stack va_s)) in let
(tag_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 96) (va_get_stack va_s)) (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 80) (va_get_stack va_s)) in
va_QBind va_range1
"***** PRECONDITION NOT MET AT line 989 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_CreateHeaplets ([declare_buffer128 auth_b 1 Secret Immutable; declare_buffer128
abytes_b 7 Secret Immutable; declare_buffer128 in128x6_b 6 Secret Immutable; declare_buffer128
in128_b 1 Secret Immutable; declare_buffer128 hkeys_b 0 Secret Immutable; declare_buffer128
tag_b 0 Secret Immutable; declare_buffer128 keys_b 0 Secret Immutable; declare_buffer128 iv_b 2
Public Mutable; declare_buffer128 scratch_b 3 Secret Mutable; declare_buffer128 out128x6_b 6
Secret Mutable; declare_buffer128 out128_b 1 Secret Mutable; declare_buffer128 inout_b 5 Secret
Mutable])) (fun (va_s:va_state) _ -> va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 1003 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun (alg_10639:Vale.AES.AES_common_s.algorithm) (key_10640:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) (input_LE_10641:Vale.Def.Types_s.quad32) ->
Vale.AES.AES_s.is_aes_key_LE alg_10639 key_10640) alg key (Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 0 0 0 0)) (fun _ -> let (va_arg69:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)) in let (va_arg68:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s) hkeys_b in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 1003 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_hkeys_reqs_pub_priv va_arg68 va_arg69) (va_qAssert
va_range1
"***** PRECONDITION NOT MET AT line 1004 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s + 40) (va_get_stack va_s))
(va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 1005 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(~win ==> Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s + 80) (va_get_stack va_s))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 1006 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Save_registers win) (fun (va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 1009 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1011 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1012 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRsi) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1013 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR8)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 1014 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR9)) (fun (va_s:va_state) _ ->
va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 1015 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRsp va_s + 224 == va_get_reg64 rRsp va_old_s) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 1016 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s + 224 + 40) (va_get_stack va_s))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1017 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsp) (224 + 40 + 0))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1018 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRsp) (224 + 40 + 8))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1019 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRbp) (va_op_reg_opr64_reg64 rRsp) (224 + 40 +
88)) (va_QEmpty (())))))))))))) (qblock va_mods (fun (va_s:va_state) -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 1023 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRsp va_s + 64 == va_get_reg64 rRsp va_old_s) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 1024 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s + 64 + 80) (va_get_stack va_s))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1025 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRbp) (va_op_reg_opr64_reg64 rRsp) (64 + 8 + 72))
(va_QEmpty (()))))))) (fun (va_s:va_state) va_g -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1028 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks_wrapped alg (Vale.X64.Decls.total_if #int win (224 + 56) (64 + 8)) auth_b
abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b iv scratch_b key
(Vale.X64.Decls.buffer128_as_seq (va_get_mem_heaplet 0 va_old_s) keys_b) keys_b hkeys_b
(Vale.Def.Types_s.le_quad32_to_bytes (Vale.X64.Decls.buffer128_read tag_b 0 (va_get_mem_heaplet
0 va_old_s)))) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1048 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rR15) (va_op_reg_opr64_reg64 rRsp)
(Vale.X64.Decls.total_if #int win (224 + 40 + 96) (64 + 8 + 80))) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 1049 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rR15) 0 Secret tag_b 0) (fun (va_s:va_state) _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 1050 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 0 va_s == Vale.X64.Decls.buffer128_read tag_b 0 (va_get_mem_heaplet 0 va_s))
(va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 1051 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 0 va_s == Vale.X64.Decls.buffer128_read tag_b 0 (va_get_mem_heaplet 0 va_old_s))
(let (alleged_tag_quad:quad32) = va_get_xmm 0 va_s in let (computed_tag:quad32) = va_get_xmm 8
va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 1054 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_XmmEqual (va_op_xmm_xmm 0) (va_op_xmm_xmm 8)) (fun (va_s:va_state) _ -> let
(auth_raw_quads:(FStar.Seq.Base.seq Vale.X64.Decls.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) auth_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_old_s) abytes_b) in va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 1057 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun a_1906 (s_1907:(FStar.Seq.Base.seq a_1906)) (i_1908:Prims.nat) (j_1909:Prims.nat) -> let
(j_1869:Prims.nat) = j_1909 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1908
j_1869) (Prims.op_LessThanOrEqual j_1869 (FStar.Seq.Base.length #a_1906 s_1907))))
Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0
auth_num_bytes) (fun _ -> let (auth_bytes:(FStar.Seq.Base.seq Vale.Def.Types_s.nat8)) =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
auth_raw_quads) 0 auth_num_bytes in let (cipher_raw_quads:(FStar.Seq.Base.seq
Vale.X64.Decls.quad32)) = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_old_s) inout_b) in va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 1059 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun a_1906 (s_1907:(FStar.Seq.Base.seq a_1906)) (i_1908:Prims.nat) (j_1909:Prims.nat) -> let
(j_1869:Prims.nat) = j_1909 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1908
j_1869) (Prims.op_LessThanOrEqual j_1869 (FStar.Seq.Base.length #a_1906 s_1907))))
Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads) 0
cipher_num_bytes) (fun _ -> let (cipher_bytes:(FStar.Seq.Base.seq Vale.Def.Types_s.nat8)) =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
cipher_raw_quads) 0 cipher_num_bytes in let (va_arg67:Vale.Def.Types_s.quad32) = computed_tag
in let (va_arg66:Vale.Def.Types_s.quad32) = alleged_tag_quad in let
(va_arg65:Vale.Def.Words_s.nat64) = va_get_reg64 rRax va_s in let (va_arg64:(FStar.Seq.Base.seq
Vale.Def.Words_s.nat8)) = auth_bytes in let (va_arg63:(FStar.Seq.Base.seq
Vale.Def.Words_s.nat8)) = cipher_bytes in let (va_arg62:Vale.AES.GCM_s.supported_iv_LE) = iv in
let (va_arg61:(FStar.Seq.Base.seq Vale.Def.Words_s.nat8)) =
Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key in let
(va_arg60:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 1060 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCM.decrypt_helper va_arg60 va_arg61 va_arg62 va_arg63 va_arg64
va_arg65 va_arg66 va_arg67) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1066 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1067 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Restore_registers win (va_get_reg64 rRsp va_old_s) (va_get_xmm 6 va_old_s)
(va_get_xmm 7 va_old_s) (va_get_xmm 8 va_old_s) (va_get_xmm 9 va_old_s) (va_get_xmm 10
va_old_s) (va_get_xmm 11 va_old_s) (va_get_xmm 12 va_old_s) (va_get_xmm 13 va_old_s)
(va_get_xmm 14 va_old_s) (va_get_xmm 15 va_old_s)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1068 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1070 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_DestroyHeaplets ()) (va_QEmpty (()))))))))))))))))))))))) | {
"file_name": "obj/Vale.AES.X64.GCMdecryptOpt.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 71,
"end_line": 2140,
"start_col": 0,
"start_line": 1964
} | module Vale.AES.X64.GCMdecryptOpt
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open FStar.Seq
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_s
open Vale.AES.GCTR_s
open Vale.AES.GCTR
open Vale.AES.GCM
open Vale.AES.GHash_s
open Vale.AES.GHash
open Vale.AES.GCM_s
open Vale.AES.X64.AES
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.Poly1305.Math
open Vale.AES.GCM_helpers
open Vale.AES.X64.GHash
open Vale.AES.X64.GCTR
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.X64.Stack_i
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.InsBasic
open Vale.X64.InsMem
open Vale.X64.InsVector
open Vale.X64.InsStack
open Vale.X64.InsAes
open Vale.X64.QuickCode
open Vale.X64.QuickCodes
open Vale.AES.X64.GF128_Mul
open Vale.X64.Stack
open Vale.X64.CPU_Features_s
open Vale.Math.Poly2.Bits_s
open Vale.AES.X64.AESopt
open Vale.AES.X64.AESGCM
open Vale.AES.X64.AESopt2
open Vale.Lib.Meta
open Vale.AES.X64.GCMencryptOpt
open Vale.AES.OptPublic
open Vale.Lib.Basic
#reset-options "--z3rlimit 20 --max_ifuel 0"
//-- Gcm_extra_bytes
val va_code_Gcm_extra_bytes : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_extra_bytes alg =
(va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0)
(va_op_reg_opr64_reg64 rRax) 0 Secret) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 10)
(va_op_xmm_xmm 0)) (va_CCons (va_code_Ghash_extra_bytes ()) (va_CCons (va_code_Mov128
(va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_CCons (va_code_Pshufb (va_op_xmm_xmm 0)
(va_op_xmm_xmm 9)) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons (va_code_Pxor
(va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_CCons (va_code_Store128_buffer
(va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret)
(va_CNil ()))))))))))
val va_codegen_success_Gcm_extra_bytes : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_extra_bytes alg =
(va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0)
(va_op_reg_opr64_reg64 rRax) 0 Secret) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm
10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Ghash_extra_bytes ()) (va_pbool_and
(va_codegen_success_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_pbool_and
(va_codegen_success_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and
(va_codegen_success_AESEncryptBlock alg) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm
10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Store128_buffer
(va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret)
(va_ttrue ())))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_extra_bytes (va_mods:va_mods_t) (alg:algorithm) (inout_b:buffer128) (key:(seq
nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat)
(old_hash:quad32) (completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit
(va_code_Gcm_extra_bytes alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (len:(va_int_range
1 1)) = 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 188 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRax) 0 Secret inout_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 189 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (fun (va_s:va_state) _ -> let
(hash_input:quad32) = va_get_xmm 0 va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 193 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_extra_bytes hkeys_b total_bytes old_hash h_LE completed_quads) (fun
(va_s:va_state) _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 194 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.equal #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s)
inout_b) (FStar.Seq.Base.create #quad32 1 hash_input)) (let (snap:(FStar.Seq.Base.seq
Vale.X64.Decls.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 198 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 199 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 200 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AESEncryptBlock alg (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 11 va_s)) key
round_keys keys_b) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 201 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.AES_s.aes_encrypt_LE_reveal ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 204 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 205 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax)
(va_op_xmm_xmm 10) 0 Secret inout_b 0) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 207 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.gctr_partial_reveal ()) (va_QEmpty (()))))))))))))))
val va_lemma_Gcm_extra_bytes : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
inout_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> total_bytes:nat -> old_hash:quad32 -> completed_quads:(seq quad32) ->
h_LE:quad32
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_extra_bytes alg) va_s0 /\ va_get_ok va_s0 /\ (let
(len:(va_int_range 1 1)) = 1 in sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b
inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b inout_b /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax va_s0) inout_b
len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys
keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0
va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32
(Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length
#quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply`
FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes
`op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16
`op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
(Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads =
FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0)
inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes =
Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) /\ va_state_eq va_sM
(va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM (va_update_ok va_sM
(va_update_mem va_sM va_s0))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_extra_bytes va_b0 va_s0 alg inout_b key round_keys keys_b hkeys_b total_bytes
old_hash completed_quads h_LE =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_extra_bytes va_mods alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_extra_bytes alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 121 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (len:(va_int_range 1 1)) = 1 in label va_range1
"***** POSTCONDITION NOT MET AT line 174 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 177 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg len (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0)) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 180 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let raw_quads = FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 181 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 182 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 183 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let input_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 186 column 59 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(l_and (FStar.Seq.Base.length #Vale.Def.Types_s.quad32 input_quads > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE old_hash input_quads)))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm
7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32)
(completed_quads:(seq quad32)) (h_LE:quad32) (va_s0:va_state) (va_k:(va_state -> unit -> Type0))
: Type0 =
(va_get_ok va_s0 /\ (let (len:(va_int_range 1 1)) = 1 in sse_enabled /\
Vale.X64.Decls.buffers_disjoint128 keys_b inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b
inout_b /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax
va_s0) inout_b len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys
keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0
va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32
(Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length
#quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply`
FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes
`op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16
`op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
(Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes) /\ (forall
(va_x_mem:vale_heap) (va_x_rcx:nat64) (va_x_r11:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32)
(va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32)
(va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm10:quad32) (va_x_heap5:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 5
va_x_heap5 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7
(va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3
(va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR11
va_x_r11 (va_upd_reg64 rRcx va_x_rcx (va_upd_mem va_x_mem va_s0)))))))))))))) in va_get_ok
va_sM /\ (let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads =
FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0)
inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes =
Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) ==> va_k va_sM (())))
val va_wpProof_Gcm_extra_bytes : alg:algorithm -> inout_b:buffer128 -> key:(seq nat32) ->
round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> total_bytes:nat ->
old_hash:quad32 -> completed_quads:(seq quad32) -> h_LE: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_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_extra_bytes alg) ([va_Mod_flags;
va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5;
va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11;
va_Mod_reg64 rRcx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash
completed_quads h_LE va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_extra_bytes (va_code_Gcm_extra_bytes alg) va_s0 alg inout_b key
round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10
va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm
7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32)
(completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit (va_code_Gcm_extra_bytes alg)) =
(va_QProc (va_code_Gcm_extra_bytes alg) ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10;
va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm
2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem])
(va_wp_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash
completed_quads h_LE) (va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE))
//--
//-- Gcm_blocks128
val va_code_Gcm_blocks128 : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks128 alg =
(va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi))
(va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_CCons
(va_code_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_CCons
(va_code_Ghash_buffer ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdi)
(va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx)
(va_op_opr64_reg64 rR12)) (va_CCons (va_code_Gctr_blocks128 alg) (va_CNil ())))))))))
val va_codegen_success_Gcm_blocks128 : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks128 alg =
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi))
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx))
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax))
(va_pbool_and (va_codegen_success_Ghash_buffer ()) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_pbool_and
(va_codegen_success_Gctr_blocks128 alg) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks128 (va_mods:va_mods_t) (alg:algorithm) (in_b:buffer128) (out_b:buffer128)
(key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32)
: (va_quickCode unit (va_code_Gcm_blocks128 alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 274 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 275 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 276 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 277 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_buffer hkeys_b in_b h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_old_s))) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 278 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 279 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 280 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gctr_blocks128 alg in_b out_b key round_keys keys_b) (va_QEmpty (()))))))))))
val va_lemma_Gcm_blocks128 : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> in_b:buffer128 ->
out_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> h_LE:quad32
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks128 alg) va_s0 /\ va_get_ok va_s0 /\
(sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b out_b /\
Vale.X64.Decls.buffers_disjoint128 hkeys_b out_b /\ (Vale.X64.Decls.buffers_disjoint128 in_b
out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16
`op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply`
va_get_reg64 rRdx va_s0 < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b)
(Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx
va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\
va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8
va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0)
(va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM ==
va_get_xmm 8 va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b ==
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ (va_get_reg64 rRdx va_s0 > 0 ==>
l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==> FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b)))) /\ va_state_eq va_sM (va_update_flags va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 10 va_sM (va_update_xmm 11 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rR10 va_sM
(va_update_reg64 rR11 va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRbx va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_blocks128 va_b0 va_s0 alg in_b out_b key round_keys keys_b hkeys_b h_LE =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11;
va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm
2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks128 va_mods alg in_b out_b key round_keys keys_b hkeys_b h_LE in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks128 alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 210 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 255 column 53 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 261 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 262 column 45 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0) (va_get_reg64 rRdx
va_s0)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 265 column 93 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM == va_get_xmm 8 va_s0)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b == Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) out_b)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 267 column 131 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRdx va_s0 > 0 ==> l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==>
FStar.Seq.Base.length #Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm
8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2;
va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_blocks128 (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32) (va_s0:va_state)
(va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b out_b /\
Vale.X64.Decls.buffers_disjoint128 hkeys_b out_b /\ (Vale.X64.Decls.buffers_disjoint128 in_b
out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16
`op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply`
va_get_reg64 rRdx va_s0 < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b)
(Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx
va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\
va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8
va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret) /\ (forall (va_x_mem:vale_heap) (va_x_rbx:nat64) (va_x_rdi:nat64) (va_x_r11:nat64)
(va_x_r10:nat64) (va_x_rdx:nat64) (va_x_r12:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32)
(va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32)
(va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm11:quad32) (va_x_xmm10:quad32)
(va_x_heap1:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 11 va_x_xmm11
(va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5
(va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1
(va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64
rR10 va_x_r10 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRbx
va_x_rbx (va_upd_mem va_x_mem va_s0))))))))))))))))))) in va_get_ok va_sM /\
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0)
(va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM ==
va_get_xmm 8 va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b ==
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ (va_get_reg64 rRdx va_s0 > 0 ==>
l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==> FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b)))) ==> va_k va_sM (())))
val va_wpProof_Gcm_blocks128 : alg:algorithm -> in_b:buffer128 -> out_b:buffer128 -> key:(seq
nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> h_LE: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_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b
h_LE va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks128 alg) ([va_Mod_flags;
va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6;
va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0;
va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10; va_Mod_reg64 rR11; va_Mod_reg64 rRdi;
va_Mod_reg64 rRbx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_blocks128 (va_code_Gcm_blocks128 alg) va_s0 alg in_b out_b key
round_keys keys_b hkeys_b h_LE in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 1 va_sM (va_update_xmm 10
va_sM (va_update_xmm 11 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6
va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2
va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR12 va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rRdi va_sM (va_update_reg64 rRbx va_sM (va_update_ok va_sM (va_update_mem
va_sM va_s0))))))))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm
8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2;
va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_blocks128 (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32) : (va_quickCode
unit (va_code_Gcm_blocks128 alg)) =
(va_QProc (va_code_Gcm_blocks128 alg) ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10;
va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm
3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64
rR10; va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_mem])
(va_wp_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE)
(va_wpProof_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE))
//--
//-- Gcm_blocks
#push-options "--z3rlimit 1000"
val va_code_Gcm_blocks : alg:algorithm -> offset:int -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks alg offset =
(va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx))
(va_CCons (va_code_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9) (va_const_opr64
32)) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRsp)
(offset + 0)) (va_CCons (va_code_Gcm_blocks_auth ()) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8)) (va_CCons
(va_code_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp) (offset + 16))
(va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp)
(offset + 24)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13))
(va_CCons (va_code_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64
rR8) 0 Public) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_reg_opr64_reg64 rRbp) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_Load_one_lsb
(va_op_xmm_xmm 10)) (va_CCons (va_code_VPaddd (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)
(va_op_xmm_xmm 10)) (va_CCons (va_code_AES_GCM_decrypt_6mult alg) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11) (va_op_reg_opr64_reg64
rRbp) 32 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx))
(va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp)
(offset + 32)) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRdi)
(va_op_reg_opr64_reg64 rRsp) (offset + 40)) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 48)) (va_CCons
(va_code_Mov64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRdx)) (va_CCons
(va_code_InitPshufbMask (va_op_xmm_xmm 9) (va_op_reg_opr64_reg64 rR12)) (va_CCons
(va_code_Pshufb (va_op_xmm_xmm 11) (va_op_xmm_xmm 9)) (va_CCons (va_code_Gcm_blocks128 alg)
(va_CCons (va_code_Stack_lemma ()) (va_CCons (va_code_Add64 (va_op_dst_opr64_reg64 rR14)
(va_opr_code_Stack (va_op_reg64_reg64 rRsp) (offset + 24) Public)) (va_CCons (va_code_IMul64
(va_op_dst_opr64_reg64 rR14) (va_const_opr64 16)) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rR13) (va_op_reg_opr64_reg64 rRsp) (offset + 64)) (va_CCons (va_IfElse
(va_cmp_gt (va_op_cmp_reg64 rR13) (va_op_cmp_reg64 rR14)) (va_Block (va_CCons
(va_code_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 56))
(va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR13)) (va_CCons
(va_code_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 15)) (va_CCons
(va_code_Gcm_extra_bytes alg) (va_CCons (va_Block (va_CNil ())) (va_CNil ()))))))) (va_Block
(va_CNil ()))) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15))
(va_CCons (va_code_Gcm_make_length_quad ()) (va_CCons (va_code_Ghash_register ()) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRbp) 0 Secret) (va_CCons (va_code_Gctr_register alg) (va_CCons (va_Block (va_CNil ()))
(va_CNil ()))))))))))))))))))))))))))))))))))))
val va_codegen_success_Gcm_blocks : alg:algorithm -> offset:int -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks alg offset =
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx))
(va_pbool_and (va_codegen_success_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9)
(va_const_opr64 32)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64
rRbx) (va_op_reg_opr64_reg64 rRsp) (offset + 0)) (va_pbool_and
(va_codegen_success_Gcm_blocks_auth ()) (va_pbool_and (va_codegen_success_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8)) (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp)
(offset + 16)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRdx)
(va_op_reg_opr64_reg64 rRsp) (offset + 24)) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13)) (va_pbool_and (va_codegen_success_Mov128
(va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_Load128_buffer
(va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rR8) 0 Public)
(va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_reg_opr64_reg64 rRbp) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and
(va_codegen_success_Load_one_lsb (va_op_xmm_xmm 10)) (va_pbool_and (va_codegen_success_VPaddd
(va_op_xmm_xmm 1) (va_op_xmm_xmm 1) (va_op_xmm_xmm 10)) (va_pbool_and
(va_codegen_success_AES_GCM_decrypt_6mult alg) (va_pbool_and (va_codegen_success_Load128_buffer
(va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11) (va_op_reg_opr64_reg64 rRbp) 32 Secret)
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx))
(va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRax)
(va_op_reg_opr64_reg64 rRsp) (offset + 32)) (va_pbool_and (va_codegen_success_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 40)) (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp)
(offset + 48)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR14)
(va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_InitPshufbMask (va_op_xmm_xmm 9)
(va_op_reg_opr64_reg64 rR12)) (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 11)
(va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_Gcm_blocks128 alg) (va_pbool_and
(va_codegen_success_Stack_lemma ()) (va_pbool_and (va_codegen_success_Add64
(va_op_dst_opr64_reg64 rR14) (va_opr_code_Stack (va_op_reg64_reg64 rRsp) (offset + 24) Public))
(va_pbool_and (va_codegen_success_IMul64 (va_op_dst_opr64_reg64 rR14) (va_const_opr64 16))
(va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rR13)
(va_op_reg_opr64_reg64 rRsp) (offset + 64)) (va_pbool_and (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp)
(offset + 56)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR10)
(va_op_opr64_reg64 rR13)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rR10)
(va_const_opr64 15)) (va_codegen_success_Gcm_extra_bytes alg)))) (va_pbool_and
(va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15)) (va_pbool_and
(va_codegen_success_Gcm_make_length_quad ()) (va_pbool_and (va_codegen_success_Ghash_register
()) (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRbp) 0 Secret) (va_pbool_and
(va_codegen_success_Gctr_register alg) (va_ttrue ()))))))))))))))))))))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks (va_mods:va_mods_t) (alg:algorithm) (offset:int) (auth_b:buffer128)
(abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128)
(out128_b:buffer128) (inout_b:buffer128) (iv_b:buffer128) (scratch_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit
(va_code_Gcm_blocks alg offset)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 0) (va_get_stack va_s) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 8) (va_get_stack va_s) in let
(out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 16) (va_get_stack va_s) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 24) (va_get_stack va_s) in let
(in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 32) (va_get_stack va_s) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 40) (va_get_stack va_s) in let
(len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset
+ 48) (va_get_stack va_s) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 56) (va_get_stack va_s) in let
(plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s
+ offset + 64) (va_get_stack va_s) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_old_s)) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 463 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 464 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9) (va_const_opr64 32))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 465 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRsp) (offset + 0))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 466 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks_auth auth_b abytes_b hkeys_b h_LE) (fun (va_s:va_state)
(auth_quad_seq:(seq quad32)) -> let (y_0:quad32) = Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 0 0 0 0 in let (y_auth_bytes:quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 473 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 474 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp) (offset + 16))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 475 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 24))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 476 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 477 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (fun (va_s:va_state) _ -> let
(iv_BE:Vale.X64.Decls.quad32) = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2
va_old_s) in let (ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32
iv_BE 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 483 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64
rR8) 0 Public iv_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 485 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_reg_opr64_reg64 rRbp)
(va_op_xmm_xmm 1) 0 Secret scratch_b 0) (fun (va_s:va_state) _ -> let (j0:quad32) = va_get_xmm
1 va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 487 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load_one_lsb (va_op_xmm_xmm 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 489 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_VPaddd (va_op_xmm_xmm 1) (va_op_xmm_xmm 1) (va_op_xmm_xmm 10)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 491 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AES_GCM_decrypt_6mult alg h_LE iv_b in128x6_b out128x6_b scratch_b key round_keys
keys_b hkeys_b) (fun (va_s:va_state) _ -> let (y_cipher128x6:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in let (auth_in:(seq quad32)) =
auth_quad_seq in let (va_arg138:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) =
Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b in let
(va_arg137:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg136:Vale.Def.Types_s.quad32) = y_auth_bytes in let (va_arg135:Vale.Def.Types_s.quad32) =
y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 494 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_ghash_incremental0_append h_LE va_arg135 va_arg136
y_cipher128x6 va_arg137 va_arg138) (let auth_in = FStar.Seq.Base.append #quad32 auth_in
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 498 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11)
(va_op_reg_opr64_reg64 rRbp) 32 Secret scratch_b 2) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 499 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 500 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 32))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 501 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 40))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 502 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 48))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 503 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 504 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_InitPshufbMask (va_op_xmm_xmm 9) (va_op_reg_opr64_reg64 rR12)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 505 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pshufb (va_op_xmm_xmm 11) (va_op_xmm_xmm 9)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 506 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks128 alg in128_b out128_b key round_keys keys_b hkeys_b h_LE) (fun
(va_s:va_state) _ -> let (y_cipher128:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in let (va_arg134:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b in let
(va_arg133:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg132:Vale.Def.Types_s.quad32) = y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 508 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_ghash_incremental0_append h_LE va_arg132 y_cipher128x6
y_cipher128 va_arg133 va_arg134) (let auth_in = FStar.Seq.Base.append #quad32 auth_in
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 512 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Stack_lemma (va_op_reg64_reg64 rRsp) (offset + 24) Public) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 512 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Add64 (va_op_dst_opr64_reg64 rR14) (va_opr_code_Stack (va_op_reg64_reg64 rRsp)
(offset + 24) Public)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 513 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_IMul64 (va_op_dst_opr64_reg64 rR14) (va_const_opr64 16)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 514 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rR13) (va_op_reg_opr64_reg64 rRsp) (offset + 64))
(fun (va_s:va_state) _ -> let (y_inout:Vale.Def.Types_s.quad32) = y_cipher128 in let
(plain_byte_seq:(seq quad32)) = empty_seq_quad32 in let (cipher_byte_seq:(seq quad32)) =
empty_seq_quad32 in let (va_arg131:Vale.Def.Types_s.quad32) = va_get_xmm 11 va_s in let
(va_arg130:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in let
(va_arg129:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = cipher_byte_seq in let
(va_arg128:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = plain_byte_seq in let
(va_arg127:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 519 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.gctr_partial_opaque_init va_arg127 va_arg128 va_arg129 va_arg130
va_arg131) (let (total_bytes:(va_int_at_least 0)) = FStar.Seq.Base.length #quad32 auth_quad_seq
`op_Multiply` 16 + plain_num_bytes in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 523 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_qIf va_mods (Cmp_gt (va_op_cmp_reg64 rR13) (va_op_cmp_reg64 rR14)) (qblock va_mods (fun
(va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 525 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 56))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 526 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR13)) (fun (va_s:va_state) _
-> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 527 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.Poly1305.Math.lemma_poly_bits64 ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 528 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 15)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 532 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes y_0 auth_in
h_LE) (fun (va_s:va_state) _ -> let y_inout = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm
8 va_s) in let (raw_auth_quads:(FStar.Seq.Base.seq quad32)) = FStar.Seq.Base.append #quad32
auth_in (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b) in va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 536 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun a_1906 (s_1907:(FStar.Seq.Base.seq a_1906)) (i_1908:Prims.nat) (j_1909:Prims.nat) -> let
(j_1869:Prims.nat) = j_1909 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1908
j_1869) (Prims.op_LessThanOrEqual j_1869 (FStar.Seq.Base.length #a_1906 s_1907))))
Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 total_bytes)
(fun _ -> let (auth_input_bytes:(FStar.Seq.Base.seq Vale.Def.Types_s.nat8)) =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
raw_auth_quads) 0 total_bytes in let (padded_auth_bytes:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in let auth_in =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes in let plain_byte_seq =
Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b in let cipher_byte_seq =
Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b in va_QEmpty ((auth_in,
cipher_byte_seq, plain_byte_seq, y_inout)))))))))) (qblock va_mods (fun (va_s:va_state) ->
va_QEmpty ((auth_in, cipher_byte_seq, plain_byte_seq, y_inout))))) (fun (va_s:va_state) va_g ->
let ((auth_in:(seq quad32)), (cipher_byte_seq:(seq quad32)), (plain_byte_seq:(seq quad32)),
(y_inout:Vale.Def.Types_s.quad32)) = va_g in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 547 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 548 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_make_length_quad ()) (fun (va_s:va_state) _ -> let
(length_quad32:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 0
va_s) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 551 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_register hkeys_b h_LE y_inout) (fun (va_s:va_state) _ -> let
(y_final:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s)
in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 554 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRbp) 0 Secret scratch_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 557 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gctr_register alg key round_keys keys_b) (fun (va_s:va_state) _ -> let
(va_arg126:Vale.Def.Types_s.quad32) = va_get_xmm 8 va_s in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 560 column 40 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.Arch.Types.le_seq_quad32_to_bytes_of_singleton va_arg126)
(va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 561 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun (icb_BE_677:Vale.Def.Types_s.quad32) (plain_LE_678:Vale.Def.Types_s.quad32)
(alg_679:Vale.AES.AES_common_s.algorithm) (key_680:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32))
(i_681:Prims.int) -> Vale.AES.AES_s.is_aes_key_LE alg_679 key_680) j0 y_final alg key 0) (fun _
-> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 561 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 8 va_s == Vale.AES.GCTR_s.gctr_encrypt_block j0 y_final alg key 0) (let
(plain128:(FStar.Seq.Base.seq Vale.X64.Decls.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in let
(cipher128:(FStar.Seq.Base.seq Vale.X64.Decls.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) in128_b) in va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 566 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.length #quad32 plain_byte_seq == 0 ==> FStar.Seq.Base.equal
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 plain128 plain_byte_seq)
plain128) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 567 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.length #quad32 cipher_byte_seq == 0 ==> FStar.Seq.Base.equal
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 cipher128 cipher_byte_seq)
cipher128) (let (va_arg125:Vale.Def.Types_s.quad32) = Vale.AES.GCTR.inc32lite ctr_BE_2 len128x6
in let (va_arg124:Vale.Def.Types_s.quad32) = ctr_BE_2 in let (va_arg123:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) = key in let (va_arg122:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32))
= Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b in let
(va_arg121:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) in128_b in let (va_arg120:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) out128x6_b in let
(va_arg119:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_old_s) in128x6_b in let (va_arg118:Prims.nat) = len128 in let
(va_arg117:Prims.nat) = len128x6 in let (va_arg116:Vale.AES.AES_common_s.algorithm) = alg in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 569 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.lemma_gctr_partial_append va_arg116 va_arg117 va_arg118
va_arg119 va_arg120 va_arg121 va_arg122 va_arg123 va_arg124 va_arg125) (let
(va_arg115:Vale.Def.Types_s.quad32) = Vale.AES.GCTR.inc32lite (Vale.AES.GCTR.inc32lite ctr_BE_2
len128x6) len128 in let (va_arg114:Vale.Def.Types_s.quad32) = ctr_BE_2 in let
(va_arg113:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in let
(va_arg112:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = cipher_byte_seq in let
(va_arg111:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = plain_byte_seq in let
(va_arg110:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b) in let
(va_arg109:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in let (va_arg108:Prims.nat) =
FStar.Seq.Base.length #quad32 plain_byte_seq in let (va_arg107:Prims.nat) = len128x6 + len128
in let (va_arg106:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 575 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.lemma_gctr_partial_append va_arg106 va_arg107 va_arg108
va_arg109 va_arg110 va_arg111 va_arg112 va_arg113 va_arg114 va_arg115) (let
(va_arg105:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg104:Vale.Def.Types_s.quad32) = y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 583 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_hash_append2 h_LE va_arg104 y_inout y_final va_arg105
length_quad32) (let auth_in = FStar.Seq.Base.append #quad32 auth_in (FStar.Seq.Base.create
#Vale.Def.Types_s.quad32 1 length_quad32) in let (va_arg103:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = auth_in in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 585 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.ghash_incremental_to_ghash h_LE va_arg103) (va_QEmpty
(()))))))))))))))))))))))))))))))))))))))))))))))))
val va_lemma_Gcm_blocks : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> offset:int ->
auth_b:buffer128 -> abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 ->
in128_b:buffer128 -> out128_b:buffer128 -> inout_b:buffer128 -> iv_b:buffer128 ->
scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks alg offset) va_s0 /\ va_get_ok va_s0 /\
(let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in sse_enabled /\ movbe_enabled /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp
va_s0 + offset + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet
1 va_s0) (va_get_reg64 rRdi va_s0) auth_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2
va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6
va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) in128_ptr in128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1
va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) inout_ptr inout_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0) hkeys_b 8
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet
1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b
(va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer128
scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) /\
Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32
/\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let
(ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in let
(plain_in:(seq quad32)) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) then FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) else FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in let (cipher_out:(seq quad32)) = (if (plain_num_bytes
> (len128x6 + len128) `op_Multiply` 128 `op_Division` 8) then FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) else
FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM)
out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b)) in let
(cipher_bound:nat) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128 `op_Division`
8) then (len128x6 + len128 + 1) else (len128x6 + len128)) in Vale.AES.GCTR.gctr_partial alg
cipher_bound plain_in cipher_out key ctr_BE_2 /\ (let (length_quad:quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) (8
`op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply` plain_num_bytes) 0) in let
(raw_auth_quads:(seq quad32)) = (if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) then FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b) else Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0)
auth_b) in let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64 rRsi va_s0) in let
(padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in let
(auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes in let
(raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 (FStar.Seq.Base.append #quad32
auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in let (total_bytes:nat) =
FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 + plain_num_bytes in let
(raw_quad_seq:(seq quad32)) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) then (let (ab:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32 raw_quad_seq
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let (pb:(seq
nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32 pb) else
raw_quad_seq) in let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 raw_quad_seq
(FStar.Seq.Base.create #quad32 1 length_quad) in va_get_xmm 8 va_sM ==
Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE h_LE auth_quad_seq) alg
key 0))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM
(va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm
13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm
9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM
(va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM
(va_update_reg64 rRbp va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0)))))))))))))))))))))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_blocks va_b0 va_s0 alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5;
va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14;
va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12;
va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp;
va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx;
va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks va_mods alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks alg offset) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 283 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
let (h_LE:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.X64.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 0 va_s0)) in label va_range1
"***** POSTCONDITION NOT MET AT line 396 column 56 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 397 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 398 column 57 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 399 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 400 column 58 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet
6 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 403 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(plain_num_bytes < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 404 column 38 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRsi va_s0 < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 406 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 408 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (ctr_BE_1:quad32) = iv_BE in label va_range1
"***** POSTCONDITION NOT MET AT line 409 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in label va_range1
"***** POSTCONDITION NOT MET AT line 412 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (plain_in:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in label va_range1
"***** POSTCONDITION NOT MET AT line 421 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (cipher_out:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_sM) out128_b)) in label va_range1
"***** POSTCONDITION NOT MET AT line 430 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (cipher_bound:nat) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> len128x6 + len128 + 1) (fun _ -> len128x6 + len128) in label
va_range1
"***** POSTCONDITION NOT MET AT line 434 column 77 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg cipher_bound plain_in cipher_out key ctr_BE_2) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 438 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (length_quad:quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 0 0 0 0) (8 `op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply`
plain_num_bytes) 0) in label va_range1
"***** POSTCONDITION NOT MET AT line 440 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_auth_quads:(seq quad32)) = va_if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b)) (fun _ -> Vale.X64.Decls.s128 (va_get_mem_heaplet 1
va_s0) auth_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 444 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64 rRsi va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 445 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in label
va_range1
"***** POSTCONDITION NOT MET AT line 446 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes
in label va_range1
"***** POSTCONDITION NOT MET AT line 448 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 (FStar.Seq.Base.append #quad32
auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 452 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (total_bytes:nat) = FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 +
plain_num_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 453 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_quad_seq:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply`
128 `op_Division` 8) (fun _ -> let (ab:(seq nat8)) = FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32
raw_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let
(pb:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32
pb) (fun _ -> raw_quad_seq) in label va_range1
"***** POSTCONDITION NOT MET AT line 460 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 raw_quad_seq
(FStar.Seq.Base.create #quad32 1 length_quad) in label va_range1
"***** POSTCONDITION NOT MET AT line 461 column 106 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 8 va_sM == Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE
h_LE auth_quad_seq) alg key 0)))))))))))))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_blocks (alg:algorithm) (offset:int) (auth_b:buffer128) (abytes_b:buffer128)
(in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128) (out128_b:buffer128)
(inout_b:buffer128) (iv_b:buffer128) (scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
let (h_LE:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.X64.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 0 va_s0)) in sse_enabled /\
movbe_enabled /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0)
(va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet
1 va_s0) (va_get_reg64 rRdi va_s0) auth_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2
va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6
va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) in128_ptr in128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1
va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) inout_ptr inout_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0) hkeys_b 8
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)))) /\ (forall (va_x_mem:vale_heap)
(va_x_rax:nat64) (va_x_rbx:nat64) (va_x_rcx:nat64) (va_x_rdx:nat64) (va_x_rdi:nat64)
(va_x_rsi:nat64) (va_x_rbp:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64)
(va_x_r11:nat64) (va_x_r12:nat64) (va_x_r13:nat64) (va_x_r14:nat64) (va_x_r15:nat64)
(va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32)
(va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm9:quad32)
(va_x_xmm10:quad32) (va_x_xmm11:quad32) (va_x_xmm12:quad32) (va_x_xmm13:quad32)
(va_x_xmm14:quad32) (va_x_xmm15:quad32) (va_x_heap1:vale_heap) (va_x_heap2:vale_heap)
(va_x_heap3:vale_heap) (va_x_heap5:vale_heap) (va_x_heap6:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 6
va_x_heap6 (va_upd_mem_heaplet 5 va_x_heap5 (va_upd_mem_heaplet 3 va_x_heap3
(va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 15 va_x_xmm15
(va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12 (va_upd_xmm 11
va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (va_upd_xmm 8 va_x_xmm8
(va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4
(va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0
(va_upd_reg64 rR15 va_x_r15 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13
(va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10
(va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRbp va_x_rbp (va_upd_reg64
rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRcx
va_x_rcx (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem
va_s0))))))))))))))))))))))))))))))))))))) in va_get_ok va_sM /\ (let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet
1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b
(va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer128
scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) /\
Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32
/\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let
(ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in let
(plain_in:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in let (cipher_out:(seq quad32)) = va_if
(plain_num_bytes > (len128x6 + len128) `op_Multiply` 128 `op_Division` 8) (fun _ ->
FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_sM) out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM)
inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) in let (cipher_bound:nat) = va_if (plain_num_bytes > (len128x6 + len128)
`op_Multiply` 128 `op_Division` 8) (fun _ -> len128x6 + len128 + 1) (fun _ -> len128x6 +
len128) in Vale.AES.GCTR.gctr_partial alg cipher_bound plain_in cipher_out key ctr_BE_2 /\ (let
(length_quad:quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) (8
`op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply` plain_num_bytes) 0) in let
(raw_auth_quads:(seq quad32)) = va_if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b)) (fun _ -> Vale.X64.Decls.s128 (va_get_mem_heaplet 1
va_s0) auth_b) in let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64
rRsi va_s0) in let (padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits
auth_input_bytes in let (auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32
padded_auth_bytes in let (raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32
(FStar.Seq.Base.append #quad32 auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0)
in128x6_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in let (total_bytes:nat)
= FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 + plain_num_bytes in let
(raw_quad_seq:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> let (ab:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32 raw_quad_seq
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let (pb:(seq
nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32 pb) (fun
_ -> raw_quad_seq) in let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32
raw_quad_seq (FStar.Seq.Base.create #quad32 1 length_quad) in va_get_xmm 8 va_sM ==
Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE h_LE auth_quad_seq) alg
key 0))) ==> va_k va_sM (())))
val va_wpProof_Gcm_blocks : alg:algorithm -> offset:int -> auth_b:buffer128 -> abytes_b:buffer128
-> in128x6_b:buffer128 -> out128x6_b:buffer128 -> in128_b:buffer128 -> out128_b:buffer128 ->
inout_b:buffer128 -> iv_b:buffer128 -> scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq
quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit ->
Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b
in128_b out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks alg offset) ([va_Mod_flags;
va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2;
va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm
11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5;
va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15;
va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10;
va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi;
va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) va_s0
va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b
iv_b scratch_b key round_keys keys_b hkeys_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_blocks (va_code_Gcm_blocks alg offset) va_s0 alg offset auth_b
abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b scratch_b key round_keys keys_b
hkeys_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM
(va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm
13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm
9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM
(va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM
(va_update_reg64 rRbp va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))))))))))))))))))))))))))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_blocks (alg:algorithm) (offset:int) (auth_b:buffer128) (abytes_b:buffer128)
(in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128) (out128_b:buffer128)
(inout_b:buffer128) (iv_b:buffer128) (scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit (va_code_Gcm_blocks alg
offset)) =
(va_QProc (va_code_Gcm_blocks alg offset) ([va_Mod_flags; va_Mod_mem_heaplet 6;
va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1;
va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10;
va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm
3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64
rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64
rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64
rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_Gcm_blocks alg offset auth_b
abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b scratch_b key round_keys keys_b
hkeys_b) (va_wpProof_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b))
#pop-options
//--
//-- Gcm_blocks_wrapped
#push-options "--z3rlimit 60"
val va_code_Gcm_blocks_wrapped : alg:algorithm -> offset:int -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks_wrapped alg offset =
(va_Block (va_CCons (va_code_Gcm_blocks alg offset) (va_CCons (va_Block (va_CNil ())) (va_CCons
(va_Block (va_CNil ())) (va_CNil ())))))
val va_codegen_success_Gcm_blocks_wrapped : alg:algorithm -> offset:int -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks_wrapped alg offset =
(va_pbool_and (va_codegen_success_Gcm_blocks alg offset) (va_ttrue ()))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks_wrapped (va_mods:va_mods_t) (alg:algorithm) (offset:int) (auth_b:buffer128)
(abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128)
(out128_b:buffer128) (inout_b:buffer128) (iv_b:buffer128) (iv:supported_iv_LE)
(scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128)
(hkeys_b:buffer128) (expected_tag:(seq nat8)) : (va_quickCode unit (va_code_Gcm_blocks_wrapped
alg offset)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 0) (va_get_stack va_s) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 8) (va_get_stack va_s) in let
(out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 16) (va_get_stack va_s) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 24) (va_get_stack va_s) in let
(in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 32) (va_get_stack va_s) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 40) (va_get_stack va_s) in let
(len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset
+ 48) (va_get_stack va_s) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 56) (va_get_stack va_s) in let
(plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s
+ offset + 64) (va_get_stack va_s) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 739 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b
iv_b scratch_b key round_keys keys_b hkeys_b) (fun (va_s:va_state) _ -> va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 741 column 37 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(8 `op_Multiply` va_get_reg64 rRsi va_old_s >= 0 /\ 8 `op_Multiply` va_get_reg64 rRsi va_old_s
<= 18446744073709551615 /\ 8 `op_Multiply` plain_num_bytes >= 0 /\ 8 `op_Multiply`
plain_num_bytes <= 18446744073709551615) (fun _ -> let (va_arg55:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) (8
`op_Multiply` va_get_reg64 rRsi va_old_s) 1) (8 `op_Multiply` plain_num_bytes) 0) in let
(va_arg54:Vale.Def.Types_s.quad32) = va_get_xmm 8 va_s in let
(va_arg53:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.X64.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 0 va_s)) in let
(va_arg52:Vale.Def.Types_s.quad32) = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2
va_old_s) in let (va_arg51:Vale.AES.GCM_s.supported_iv_LE) = iv in let (va_arg50:Prims.nat) =
va_get_reg64 rRsi va_old_s in let (va_arg49:Prims.nat) = plain_num_bytes in let
(va_arg48:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s) inout_b in let (va_arg47:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b in let
(va_arg46:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s) out128x6_b in let (va_arg45:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b in let
(va_arg44:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) in128_b in let (va_arg43:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b in
let (va_arg42:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_old_s) abytes_b in let (va_arg41:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) auth_b in let
(va_arg40:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = key in let
(va_arg39:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 741 column 37 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCM.gcm_blocks_dec_helper_simplified va_arg39 va_arg40 va_arg41
va_arg42 va_arg43 va_arg44 va_arg45 va_arg46 va_arg47 va_arg48 va_arg49 va_arg50 va_arg51
va_arg52 va_arg53 va_arg54 va_arg55) (let (auth_raw_quads:(FStar.Seq.Base.seq
Vale.X64.Decls.quad32)) = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) auth_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_old_s)
abytes_b) in va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 751 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun a_1906 (s_1907:(FStar.Seq.Base.seq a_1906)) (i_1908:Prims.nat) (j_1909:Prims.nat) -> let
(j_1869:Prims.nat) = j_1909 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1908
j_1869) (Prims.op_LessThanOrEqual j_1869 (FStar.Seq.Base.length #a_1906 s_1907))))
Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0 (va_get_reg64
rRsi va_old_s)) (fun _ -> let (auth_bytes:(FStar.Seq.Base.seq Vale.Def.Types_s.nat8)) =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
auth_raw_quads) 0 (va_get_reg64 rRsi va_old_s) in let (va_arg38:Vale.Def.Types_s.quad32) =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_old_s) in let
(va_arg37:Vale.AES.GCM_s.supported_iv_LE) = iv in let (va_arg36:Prims.nat) = plain_num_bytes in
let (va_arg35:(FStar.Seq.Base.seq Vale.Def.Words_s.nat8)) = expected_tag in let
(va_arg34:(FStar.Seq.Base.seq Vale.Def.Words_s.nat8)) = auth_bytes in let
(va_arg33:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s) inout_b in let (va_arg32:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b in let
(va_arg31:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s) out128x6_b in let (va_arg30:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b in let
(va_arg29:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) in128_b in let (va_arg28:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b in
let (va_arg27:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = key in let
(va_arg26:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 752 column 37 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCM.gcm_blocks_helper_dec_simplified va_arg26 va_arg27 va_arg28
va_arg29 va_arg30 va_arg31 va_arg32 va_arg33 va_arg34 va_arg35 va_arg36 va_arg37 va_arg38)
(va_QEmpty (()))))))))
val va_lemma_Gcm_blocks_wrapped : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> offset:int ->
auth_b:buffer128 -> abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 ->
in128_b:buffer128 -> out128_b:buffer128 -> inout_b:buffer128 -> iv_b:buffer128 ->
iv:supported_iv_LE -> scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) ->
keys_b:buffer128 -> hkeys_b:buffer128 -> expected_tag:(seq nat8)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks_wrapped alg offset) va_s0 /\ va_get_ok
va_s0 /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in sse_enabled /\ movbe_enabled /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp
va_s0 + offset + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet
1 va_s0) (va_get_reg64 rRdi va_s0) auth_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2
va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6
va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) in128_ptr in128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1
va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) inout_ptr inout_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0) hkeys_b 8
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\ (let iv_BE =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let h_LE =
Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
in iv_BE == Vale.AES.GCM_s.compute_iv_BE h_LE iv))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in Vale.X64.Decls.modifies_buffer128 out128_b
(va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128
iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\
Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM) /\ Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0)
(va_get_mem_heaplet 5 va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b
(va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\
va_get_reg64 rRsi va_s0 < pow2_32 /\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0
(va_get_mem_heaplet 2 va_s0) in let auth_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_s0) abytes_b) in let auth_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
auth_raw_quads) 0 (va_get_reg64 rRsi va_s0) in let plain_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0)
in128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) in let plain_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
plain_raw_quads) 0 plain_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) in let cipher_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
cipher_raw_quads) 0 plain_num_bytes in l_and (l_and (l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.nat8 auth_bytes < pow2_32) (FStar.Seq.Base.length #Vale.Def.Types_s.nat8
plain_bytes < pow2_32)) (cipher_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq
Vale.Def.Types_s.nat8) #bool (Vale.AES.GCM_s.gcm_decrypt_LE alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes expected_tag)))
(Vale.Def.Types_s.le_quad32_to_bytes (va_get_xmm 8 va_sM) == Vale.AES.GCM.gcm_decrypt_LE_tag
alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM (va_update_mem_heaplet
5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 1
va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12
va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm 9 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM
(va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM
(va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRbp va_sM
(va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRdx va_sM
(va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_blocks_wrapped va_b0 va_s0 alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b expected_tag =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5;
va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14;
va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12;
va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp;
va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx;
va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks_wrapped va_mods alg offset auth_b abytes_b in128x6_b out128x6_b
in128_b out128_b inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b expected_tag in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks_wrapped alg offset) va_qc
va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 588 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 711 column 56 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 712 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 713 column 57 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 714 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 715 column 58 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet
6 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 718 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(plain_num_bytes < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 719 column 38 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRsi va_s0 < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 721 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 723 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let auth_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_s0)
abytes_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 724 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let auth_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0 (va_get_reg64 rRsi va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 725 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let plain_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 726 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let plain_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads) 0 plain_num_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 727 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let cipher_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 728 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let cipher_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads) 0 plain_num_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 737 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(l_and (l_and (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 auth_bytes < pow2_32)
(FStar.Seq.Base.length #Vale.Def.Types_s.nat8 plain_bytes < pow2_32)) (cipher_bytes ==
__proj__Mktuple2__item___1 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv
plain_bytes auth_bytes expected_tag))) (Vale.Def.Types_s.le_quad32_to_bytes (va_get_xmm 8
va_sM) == Vale.AES.GCM.gcm_decrypt_LE_tag alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE
key) iv plain_bytes auth_bytes))))))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_blocks_wrapped (alg:algorithm) (offset:int) (auth_b:buffer128) (abytes_b:buffer128)
(in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128) (out128_b:buffer128)
(inout_b:buffer128) (iv_b:buffer128) (iv:supported_iv_LE) (scratch_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (expected_tag:(seq nat8))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
sse_enabled /\ movbe_enabled /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 +
offset + 0) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 32) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 48) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 64) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) auth_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0) (va_get_reg64 rR8 va_s0) iv_b 1
(va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6
va_s0) in128x6_ptr in128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6 va_s0) out128x6_ptr out128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1
va_s0) in128_ptr in128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) out128_ptr out128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5
va_s0) inout_ptr inout_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128
(va_get_mem_heaplet 3 va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0)
hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\ (let iv_BE =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let h_LE =
Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
in iv_BE == Vale.AES.GCM_s.compute_iv_BE h_LE iv)) /\ (forall (va_x_mem:vale_heap)
(va_x_rax:nat64) (va_x_rbx:nat64) (va_x_rcx:nat64) (va_x_rdx:nat64) (va_x_rdi:nat64)
(va_x_rsi:nat64) (va_x_rbp:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64)
(va_x_r11:nat64) (va_x_r12:nat64) (va_x_r13:nat64) (va_x_r14:nat64) (va_x_r15:nat64)
(va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32)
(va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm9:quad32)
(va_x_xmm10:quad32) (va_x_xmm11:quad32) (va_x_xmm12:quad32) (va_x_xmm13:quad32)
(va_x_xmm14:quad32) (va_x_xmm15:quad32) (va_x_heap1:vale_heap) (va_x_heap2:vale_heap)
(va_x_heap3:vale_heap) (va_x_heap5:vale_heap) (va_x_heap6:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 6
va_x_heap6 (va_upd_mem_heaplet 5 va_x_heap5 (va_upd_mem_heaplet 3 va_x_heap3
(va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 15 va_x_xmm15
(va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12 (va_upd_xmm 11
va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (va_upd_xmm 8 va_x_xmm8
(va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4
(va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0
(va_upd_reg64 rR15 va_x_r15 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13
(va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10
(va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRbp va_x_rbp (va_upd_reg64
rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRcx
va_x_rcx (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem
va_s0))))))))))))))))))))))))))))))))))))) in va_get_ok va_sM /\ (let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in Vale.X64.Decls.modifies_buffer128 out128_b
(va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128
iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\
Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM) /\ Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0)
(va_get_mem_heaplet 5 va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b
(va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\
va_get_reg64 rRsi va_s0 < pow2_32 /\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0
(va_get_mem_heaplet 2 va_s0) in let auth_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_s0) abytes_b) in let auth_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
auth_raw_quads) 0 (va_get_reg64 rRsi va_s0) in let plain_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0)
in128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) in let plain_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
plain_raw_quads) 0 plain_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) in let cipher_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
cipher_raw_quads) 0 plain_num_bytes in l_and (l_and (l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.nat8 auth_bytes < pow2_32) (FStar.Seq.Base.length #Vale.Def.Types_s.nat8
plain_bytes < pow2_32)) (cipher_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq
Vale.Def.Types_s.nat8) #bool (Vale.AES.GCM_s.gcm_decrypt_LE alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes expected_tag)))
(Vale.Def.Types_s.le_quad32_to_bytes (va_get_xmm 8 va_sM) == Vale.AES.GCM.gcm_decrypt_LE_tag
alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) ==> va_k
va_sM (())))
val va_wpProof_Gcm_blocks_wrapped : alg:algorithm -> offset:int -> auth_b:buffer128 ->
abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 -> in128_b:buffer128 ->
out128_b:buffer128 -> inout_b:buffer128 -> iv_b:buffer128 -> iv:supported_iv_LE ->
scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> expected_tag:(seq nat8) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gcm_blocks_wrapped alg offset auth_b abytes_b in128x6_b
out128x6_b in128_b out128_b inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b
expected_tag va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks_wrapped alg offset)
([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3;
va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_blocks_wrapped alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b
inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b expected_tag va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_blocks_wrapped (va_code_Gcm_blocks_wrapped alg offset) va_s0
alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b iv scratch_b key
round_keys keys_b hkeys_b expected_tag in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM
(va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm
13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm
9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM
(va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM
(va_update_reg64 rRbp va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))))))))))))))))))))))))))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_blocks_wrapped (alg:algorithm) (offset:int) (auth_b:buffer128)
(abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128)
(out128_b:buffer128) (inout_b:buffer128) (iv_b:buffer128) (iv:supported_iv_LE)
(scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128)
(hkeys_b:buffer128) (expected_tag:(seq nat8)) : (va_quickCode unit (va_code_Gcm_blocks_wrapped
alg offset)) =
(va_QProc (va_code_Gcm_blocks_wrapped alg offset) ([va_Mod_flags; va_Mod_mem_heaplet 6;
va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1;
va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10;
va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm
3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64
rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64
rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64
rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_Gcm_blocks_wrapped alg offset
auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b iv scratch_b key round_keys
keys_b hkeys_b expected_tag) (va_wpProof_Gcm_blocks_wrapped alg offset auth_b abytes_b
in128x6_b out128x6_b in128_b out128_b inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b
expected_tag))
#pop-options
//--
//-- Gcm_blocks_decrypt_stdcall
#push-options "--z3rlimit 1600"
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks_decrypt_stdcall win alg =
(va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (va_Block (va_CNil ())) (va_CCons
(va_code_Save_registers win) (va_CCons (if win then va_Block (va_CCons (va_code_Mov64
(va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Mov64
(va_op_dst_opr64_reg64 rRsi) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_Mov64
(va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR8)) (va_CCons (va_code_Mov64
(va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR9)) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsp) (224 + 40 + 0)) (va_CCons
(va_code_Load64_stack (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRsp) (224 + 40 + 8))
(va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRbp) (va_op_reg_opr64_reg64 rRsp) (224
+ 40 + 88)) (va_CNil ())))))))) else va_Block (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rRbp) (va_op_reg_opr64_reg64 rRsp) (64 + 8 + 72)) (va_CNil ())))
(va_CCons (va_code_Gcm_blocks_wrapped alg (Vale.X64.Decls.total_if #int win (224 + 56) (64 +
8))) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rR15) (va_op_reg_opr64_reg64 rRsp)
(Vale.X64.Decls.total_if #int win (224 + 40 + 96) (64 + 8 + 80))) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rR15) 0 Secret) (va_CCons (va_code_XmmEqual (va_op_xmm_xmm 0) (va_op_xmm_xmm 8)) (va_CCons
(va_Block (va_CNil ())) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Mov64
(va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Restore_registers
win) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons
(va_code_DestroyHeaplets ()) (va_CNil ()))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks_decrypt_stdcall win alg =
(va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and
(va_codegen_success_Save_registers win) (va_pbool_and (if win then va_pbool_and
(va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRcx)) (va_pbool_and
(va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRsi) (va_op_opr64_reg64 rRdx)) (va_pbool_and
(va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR8)) (va_pbool_and
(va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR9)) (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsp) (224
+ 40 + 0)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rR9)
(va_op_reg_opr64_reg64 rRsp) (224 + 40 + 8)) (va_pbool_and (va_codegen_success_Load64_stack
(va_op_dst_opr64_reg64 rRbp) (va_op_reg_opr64_reg64 rRsp) (224 + 40 + 88)) (va_ttrue ())))))))
else va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRbp)
(va_op_reg_opr64_reg64 rRsp) (64 + 8 + 72)) (va_ttrue ())) (va_pbool_and
(va_codegen_success_Gcm_blocks_wrapped alg (Vale.X64.Decls.total_if #int win (224 + 56) (64 +
8))) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rR15)
(va_op_reg_opr64_reg64 rRsp) (Vale.X64.Decls.total_if #int win (224 + 40 + 96) (64 + 8 + 80)))
(va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm
0) (va_op_reg_opr64_reg64 rR15) 0 Secret) (va_pbool_and (va_codegen_success_XmmEqual
(va_op_xmm_xmm 0) (va_op_xmm_xmm 8)) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rRax)) (va_pbool_and
(va_codegen_success_Restore_registers win) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and
(va_codegen_success_DestroyHeaplets ()) (va_ttrue ())))))))))))) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Stack.fsti.checked",
"Vale.X64.QuickCodes.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.InsVector.fsti.checked",
"Vale.X64.InsStack.fsti.checked",
"Vale.X64.InsMem.fsti.checked",
"Vale.X64.InsBasic.fsti.checked",
"Vale.X64.InsAes.fsti.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Lib.Meta.fsti.checked",
"Vale.Lib.Basic.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_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",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.X64.GHash.fsti.checked",
"Vale.AES.X64.GF128_Mul.fsti.checked",
"Vale.AES.X64.GCTR.fsti.checked",
"Vale.AES.X64.GCMencryptOpt.fsti.checked",
"Vale.AES.X64.AESopt2.fsti.checked",
"Vale.AES.X64.AESopt.fsti.checked",
"Vale.AES.X64.AESGCM.fsti.checked",
"Vale.AES.X64.AES.fsti.checked",
"Vale.AES.OptPublic.fsti.checked",
"Vale.AES.GHash_s.fst.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_s.fst.checked",
"Vale.AES.GCTR.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"Vale.AES.GCM.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_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.X64.GCMdecryptOpt.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Lib.Basic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"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.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_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": "Vale.Def.Types_s",
"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": "FStar.Seq",
"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.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"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.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_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": "Vale.Def.Types_s",
"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": "FStar.Seq",
"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.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 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": 1600,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
va_mods: Vale.X64.QuickCode.va_mods_t ->
win: Prims.bool ->
alg: Vale.AES.AES_common_s.algorithm ->
auth_b: Vale.X64.Memory.buffer128 ->
auth_bytes: Vale.X64.Memory.nat64 ->
auth_num: Vale.X64.Memory.nat64 ->
keys_b: Vale.X64.Memory.buffer128 ->
iv_b: Vale.X64.Memory.buffer128 ->
iv: Vale.AES.GCM_s.supported_iv_LE ->
hkeys_b: Vale.X64.Memory.buffer128 ->
abytes_b: Vale.X64.Memory.buffer128 ->
in128x6_b: Vale.X64.Memory.buffer128 ->
out128x6_b: Vale.X64.Memory.buffer128 ->
len128x6_num: Vale.X64.Memory.nat64 ->
in128_b: Vale.X64.Memory.buffer128 ->
out128_b: Vale.X64.Memory.buffer128 ->
len128_num: Vale.X64.Memory.nat64 ->
inout_b: Vale.X64.Memory.buffer128 ->
cipher_num: Vale.X64.Memory.nat64 ->
scratch_b: Vale.X64.Memory.buffer128 ->
tag_b: Vale.X64.Memory.buffer128 ->
key: FStar.Seq.Base.seq Vale.X64.Memory.nat32
-> Vale.X64.QuickCode.va_quickCode Prims.unit
(Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_blocks_decrypt_stdcall win alg) | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.QuickCode.va_mods_t",
"Prims.bool",
"Vale.AES.AES_common_s.algorithm",
"Vale.X64.Memory.buffer128",
"Vale.X64.Memory.nat64",
"Vale.AES.GCM_s.supported_iv_LE",
"FStar.Seq.Base.seq",
"Vale.X64.Memory.nat32",
"Vale.X64.QuickCodes.qblock",
"Prims.unit",
"Prims.Cons",
"Vale.X64.Decls.va_code",
"Vale.X64.InsMem.va_code_CreateHeaplets",
"Vale.X64.Machine_s.Block",
"Vale.X64.Decls.ins",
"Vale.X64.Decls.ocmp",
"Prims.Nil",
"Vale.X64.Machine_s.precode",
"Vale.AES.X64.GCMencryptOpt.va_code_Save_registers",
"Vale.X64.QuickCodes.if_code",
"Vale.X64.QuickCodes.block",
"Vale.X64.InsBasic.va_code_Mov64",
"Vale.X64.Decls.va_op_dst_opr64_reg64",
"Vale.X64.Machine_s.rRdi",
"Vale.X64.Decls.va_op_opr64_reg64",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Machine_s.rRsi",
"Vale.X64.Machine_s.rRdx",
"Vale.X64.Machine_s.rR8",
"Vale.X64.Machine_s.rR9",
"Vale.X64.InsStack.va_code_Load64_stack",
"Vale.X64.Decls.va_op_reg_opr64_reg64",
"Vale.X64.Machine_s.rRsp",
"Prims.op_Addition",
"Vale.X64.Machine_s.rRbp",
"Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_blocks_wrapped",
"Vale.X64.Decls.total_if",
"Prims.int",
"Vale.X64.Machine_s.rR15",
"Vale.X64.InsVector.va_code_Load128_buffer",
"Vale.X64.Decls.va_op_heaplet_mem_heaplet",
"Vale.X64.Decls.va_op_xmm_xmm",
"Vale.Arch.HeapTypes_s.Secret",
"Vale.X64.InsVector.va_code_XmmEqual",
"Vale.X64.Machine_s.rRax",
"Vale.AES.X64.GCMencryptOpt.va_code_Restore_registers",
"Vale.X64.InsMem.va_code_DestroyHeaplets",
"Vale.X64.Decls.va_state",
"Vale.X64.QuickCodes.va_QBind",
"Vale.X64.QuickCodes.va_range1",
"Vale.X64.InsMem.va_quick_CreateHeaplets",
"Vale.Arch.HeapImpl.buffer_info",
"Vale.X64.InsMem.declare_buffer128",
"Vale.Arch.HeapImpl.Immutable",
"Vale.Arch.HeapTypes_s.Public",
"Vale.Arch.HeapImpl.Mutable",
"Vale.X64.QuickCodes.va_qAssertSquash",
"Vale.AES.AES_s.is_aes_key_LE",
"Prims.squash",
"Vale.X64.QuickCodes.va_qPURE",
"Prims.pure_post",
"Prims.l_and",
"Prims.l_True",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.l_iff",
"Vale.AES.OptPublic.hkeys_reqs_pub",
"Vale.AES.GHash.hkeys_reqs_priv",
"Vale.AES.GHash.lemma_hkeys_reqs_pub_priv",
"Vale.X64.QuickCodes.va_qAssert",
"Prims.b2t",
"Vale.X64.Stack_i.valid_src_stack64",
"Vale.X64.Decls.va_get_reg64",
"Vale.X64.Decls.va_get_stack",
"Prims.l_not",
"Vale.AES.X64.GCMencryptOpt.va_quick_Save_registers",
"Vale.X64.QuickCodes.va_qInlineIf",
"Vale.X64.QuickCodes.va_QSeq",
"Vale.X64.InsBasic.va_quick_Mov64",
"Prims.eq2",
"Vale.X64.InsStack.va_quick_Load64_stack",
"Vale.X64.QuickCodes.va_QEmpty",
"Vale.X64.QuickCodes.quickCodes",
"Vale.AES.X64.GCMdecryptOpt.va_quick_Gcm_blocks_wrapped",
"Vale.X64.Decls.buffer128_as_seq",
"Vale.X64.Decls.va_get_mem_heaplet",
"Vale.Def.Types_s.le_quad32_to_bytes",
"Vale.X64.Decls.buffer128_read",
"Vale.X64.InsVector.va_quick_Load128_buffer",
"Vale.X64.Decls.quad32",
"Vale.X64.Decls.va_get_xmm",
"Vale.X64.InsVector.va_quick_XmmEqual",
"Prims.op_AmpAmp",
"Prims.op_LessThanOrEqual",
"FStar.Seq.Base.length",
"Vale.Def.Types_s.nat8",
"Vale.Def.Types_s.le_seq_quad32_to_bytes",
"Prims.nat",
"Vale.AES.AES_common_s.is_aes_key",
"Prims.op_LessThan",
"Vale.Def.Words_s.nat8",
"Prims.op_Equality",
"Vale.Def.Types_s.quad32",
"Prims.op_GreaterThan",
"Prims.logical",
"Vale.AES.GCM.gcm_decrypt_LE_tag",
"FStar.Pervasives.Native.snd",
"Vale.AES.GCM_s.gcm_decrypt_LE",
"Vale.AES.GCM.decrypt_helper",
"Vale.AES.X64.GCMencryptOpt.va_quick_Restore_registers",
"Vale.X64.InsMem.va_quick_DestroyHeaplets",
"Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE",
"Vale.Def.Words_s.nat64",
"FStar.Seq.Base.slice",
"FStar.Seq.Base.append",
"Vale.X64.Decls.s128",
"Vale.Def.Types_s.reverse_bytes_quad32",
"Vale.AES.AES_s.aes_encrypt_LE",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Vale.X64.Decls.va_int_range",
"Vale.X64.Decls.va_if",
"Vale.X64.Stack_i.load_stack64",
"Vale.Def.Types_s.nat64",
"Vale.X64.State.vale_state",
"Vale.X64.QuickCode.va_quickCode",
"Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_blocks_decrypt_stdcall"
] | [] | false | false | false | false | false | let va_qcode_Gcm_blocks_decrypt_stdcall
(va_mods: va_mods_t)
(win: bool)
(alg: algorithm)
(auth_b: buffer128)
(auth_bytes auth_num: nat64)
(keys_b iv_b: buffer128)
(iv: supported_iv_LE)
(hkeys_b abytes_b in128x6_b out128x6_b: buffer128)
(len128x6_num: nat64)
(in128_b out128_b: buffer128)
(len128_num: nat64)
(inout_b: buffer128)
(cipher_num: nat64)
(scratch_b tag_b: buffer128)
(key: (seq nat32))
: (va_quickCode unit (va_code_Gcm_blocks_decrypt_stdcall win alg)) =
| (qblock va_mods
(fun (va_s: va_state) ->
let va_old_s:va_state = va_s in
let auth_ptr:(va_int_range 0 18446744073709551615) =
va_if win (fun _ -> va_get_reg64 rRcx va_s) (fun _ -> va_get_reg64 rRdi va_s)
in
let auth_num_bytes:(va_int_range 0 18446744073709551615) =
va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s)
in
let auth_len:(va_int_range 0 18446744073709551615) =
va_if win (fun _ -> va_get_reg64 rR8 va_s) (fun _ -> va_get_reg64 rRdx va_s)
in
let keys_ptr:(va_int_range 0 18446744073709551615) =
va_if win (fun _ -> va_get_reg64 rR9 va_s) (fun _ -> va_get_reg64 rRcx va_s)
in
let iv_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 32 + 8 + 0)
(va_get_stack va_s))
(fun _ -> va_get_reg64 rR8 va_s)
in
let xip:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 32 + 8 + 8)
(va_get_stack va_s))
(fun _ -> va_get_reg64 rR9 va_s)
in
let abytes_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 16) (va_get_stack va_s)
)
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 0) (va_get_stack va_s))
in
let in128x6_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 24) (va_get_stack va_s)
)
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 8) (va_get_stack va_s))
in
let out128x6_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 32) (va_get_stack va_s)
)
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 16) (va_get_stack va_s))
in
let len128x6:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 40) (va_get_stack va_s)
)
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 24) (va_get_stack va_s))
in
let in128_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 48) (va_get_stack va_s)
)
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 32) (va_get_stack va_s))
in
let out128_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 56) (va_get_stack va_s)
)
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 40) (va_get_stack va_s))
in
let len128:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 64) (va_get_stack va_s)
)
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 48) (va_get_stack va_s))
in
let inout_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 72) (va_get_stack va_s)
)
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 56) (va_get_stack va_s))
in
let cipher_num_bytes:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 80) (va_get_stack va_s)
)
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 64) (va_get_stack va_s))
in
let scratch_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 88) (va_get_stack va_s)
)
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 72) (va_get_stack va_s))
in
let tag_ptr:(va_int_range 0 18446744073709551615) =
va_if win
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 96) (va_get_stack va_s)
)
(fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 80) (va_get_stack va_s))
in
va_QBind va_range1
"***** PRECONDITION NOT MET AT line 989 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_CreateHeaplets ([
declare_buffer128 auth_b 1 Secret Immutable;
declare_buffer128 abytes_b 7 Secret Immutable;
declare_buffer128 in128x6_b 6 Secret Immutable;
declare_buffer128 in128_b 1 Secret Immutable;
declare_buffer128 hkeys_b 0 Secret Immutable;
declare_buffer128 tag_b 0 Secret Immutable;
declare_buffer128 keys_b 0 Secret Immutable;
declare_buffer128 iv_b 2 Public Mutable;
declare_buffer128 scratch_b 3 Secret Mutable;
declare_buffer128 out128x6_b 6 Secret Mutable;
declare_buffer128 out128_b 1 Secret Mutable;
declare_buffer128 inout_b 5 Secret Mutable
]))
(fun (va_s: va_state) _ ->
va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 1003 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun
(alg_10639: Vale.AES.AES_common_s.algorithm)
(key_10640: (FStar.Seq.Base.seq Vale.Def.Types_s.nat32))
(input_LE_10641: Vale.Def.Types_s.quad32)
->
Vale.AES.AES_s.is_aes_key_LE alg_10639 key_10640) alg
key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))
(fun _ ->
let va_arg69:Vale.Def.Types_s.quad32 =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg
key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))
in
let va_arg68:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32) =
Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s) hkeys_b
in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 1003 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_: unit) -> Vale.AES.GHash.lemma_hkeys_reqs_pub_priv va_arg68 va_arg69)
(va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 1004 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==>
Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s + 40)
(va_get_stack va_s))
(va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 1005 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(~win ==>
Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s + 80)
(va_get_stack va_s))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 1006 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Save_registers win)
(fun (va_s: va_state) _ ->
va_QBind va_range1
"***** PRECONDITION NOT MET AT line 1009 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_qInlineIf va_mods
win
(qblock va_mods
(fun (va_s: va_state) ->
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1011 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi)
(va_op_opr64_reg64 rRcx))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1012 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRsi
)
(va_op_opr64_reg64 rRdx))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1013 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64
rRdx)
(va_op_opr64_reg64 rR8))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 1014 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64
rRcx)
(va_op_opr64_reg64 rR9))
(fun (va_s: va_state) _ ->
va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 1015 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRsp va_s +
224 ==
va_get_reg64 rRsp va_old_s
)
(va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 1016 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Stack_i.valid_src_stack64
(va_get_reg64 rRsp
va_s +
224 +
40)
(va_get_stack va_s))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1017 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack
(va_op_dst_opr64_reg64
rR8)
(va_op_reg_opr64_reg64
rRsp)
(224 + 40 + 0))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1018 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack
(va_op_dst_opr64_reg64
rR9)
(va_op_reg_opr64_reg64
rRsp)
(224 + 40 +
8))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1019 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack
(va_op_dst_opr64_reg64
rRbp
)
(va_op_reg_opr64_reg64
rRsp
)
(224 +
40 +
88))
(va_QEmpty (()
))))))))
))))
(qblock va_mods
(fun (va_s: va_state) ->
va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 1023 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRsp va_s + 64 ==
va_get_reg64 rRsp va_old_s)
(va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 1024 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64
rRsp
va_s +
64 +
80)
(va_get_stack va_s))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1025 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64
rRbp)
(va_op_reg_opr64_reg64 rRsp)
(64 + 8 + 72))
(va_QEmpty (())))))))
(fun (va_s: va_state) va_g ->
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1028 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks_wrapped alg
(Vale.X64.Decls.total_if #int
win
(224 + 56)
(64 + 8)) auth_b abytes_b in128x6_b out128x6_b
in128_b out128_b inout_b iv_b iv scratch_b key
(Vale.X64.Decls.buffer128_as_seq (va_get_mem_heaplet
0
va_old_s)
keys_b) keys_b hkeys_b
(Vale.Def.Types_s.le_quad32_to_bytes (Vale.X64.Decls.buffer128_read
tag_b
0
(va_get_mem_heaplet 0 va_old_s))))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1048 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rR15
)
(va_op_reg_opr64_reg64 rRsp)
(Vale.X64.Decls.total_if #int
win
(224 + 40 + 96)
(64 + 8 + 80)))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 1049 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet
0)
(va_op_xmm_xmm 0)
(va_op_reg_opr64_reg64 rR15)
0
Secret
tag_b
0)
(fun (va_s: va_state) _ ->
va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 1050 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 0 va_s ==
Vale.X64.Decls.buffer128_read tag_b
0
(va_get_mem_heaplet 0 va_s))
(va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 1051 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 0 va_s ==
Vale.X64.Decls.buffer128_read tag_b
0
(va_get_mem_heaplet 0 va_old_s))
(let alleged_tag_quad:quad32 =
va_get_xmm 0 va_s
in
let computed_tag:quad32 =
va_get_xmm 8 va_s
in
va_QBind va_range1
"***** PRECONDITION NOT MET AT line 1054 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_XmmEqual (va_op_xmm_xmm
0)
(va_op_xmm_xmm 8))
(fun (va_s: va_state) _ ->
let auth_raw_quads:(FStar.Seq.Base.seq
Vale.X64.Decls.quad32) =
FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet
1
va_old_s)
auth_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet
7
va_old_s)
abytes_b)
in
va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 1057 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun
a_1906
(s_1907:
(FStar.Seq.Base.seq
a_1906))
(i_1908: Prims.nat)
(j_1909: Prims.nat)
->
let j_1869:Prims.nat
=
j_1909
in
Prims.b2t (Prims.op_AmpAmp
(Prims.op_LessThanOrEqual
i_1908
j_1869)
(Prims.op_LessThanOrEqual
j_1869
(FStar.Seq.Base.length
#a_1906
s_1907
)))) Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes
auth_raw_quads)
0
auth_num_bytes)
(fun _ ->
let auth_bytes:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat8
) =
FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes
auth_raw_quads
)
0
auth_num_bytes
in
let cipher_raw_quads:(FStar.Seq.Base.seq
Vale.X64.Decls.quad32
) =
FStar.Seq.Base.append
#Vale.X64.Decls.quad32
(FStar.Seq.Base.append
#Vale.X64.Decls.quad32
(Vale.X64.Decls.s128
(va_get_mem_heaplet
6
va_old_s
)
in128x6_b)
(Vale.X64.Decls.s128
(va_get_mem_heaplet
1
va_old_s
)
in128_b))
(Vale.X64.Decls.s128
(va_get_mem_heaplet
5
va_old_s)
inout_b)
in
va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 1059 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun
a_1906
(s_1907:
(FStar.Seq.Base.seq
a_1906))
(i_1908:
Prims.nat)
(j_1909:
Prims.nat)
->
let j_1869:Prims.nat
=
j_1909
in
Prims.b2t (Prims.op_AmpAmp
(Prims.op_LessThanOrEqual
i_1908
j_1869
)
(Prims.op_LessThanOrEqual
j_1869
(FStar.Seq.Base.length
#a_1906
s_1907
))
)) Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes
cipher_raw_quads
)
0
cipher_num_bytes
)
(fun _ ->
let cipher_bytes:(
FStar.Seq.Base.seq
Vale.Def.Types_s.nat8
) =
FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes
cipher_raw_quads
)
0
cipher_num_bytes
in
let va_arg67:Vale.Def.Types_s.quad32
=
computed_tag
in
let va_arg66:Vale.Def.Types_s.quad32
=
alleged_tag_quad
in
let va_arg65:Vale.Def.Words_s.nat64
=
va_get_reg64 rRax
va_s
in
let va_arg64:(FStar.Seq.Base.seq
Vale.Def.Words_s.nat8
) =
auth_bytes
in
let va_arg63:(FStar.Seq.Base.seq
Vale.Def.Words_s.nat8
) =
cipher_bytes
in
let va_arg62:Vale.AES.GCM_s.supported_iv_LE
=
iv
in
let va_arg61:(FStar.Seq.Base.seq
Vale.Def.Words_s.nat8
) =
Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE
key
in
let va_arg60:Vale.AES.AES_common_s.algorithm
=
alg
in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 1060 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun
(_: unit)
->
Vale.AES.GCM.decrypt_helper
va_arg60
va_arg61
va_arg62
va_arg63
va_arg64
va_arg65
va_arg66
va_arg67
)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1066 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64
(va_op_dst_opr64_reg64
rRcx
)
(va_op_opr64_reg64
rRax
))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1067 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Restore_registers
win
(va_get_reg64
rRsp
va_old_s
)
(va_get_xmm
6
va_old_s
)
(va_get_xmm
7
va_old_s
)
(va_get_xmm
8
va_old_s
)
(va_get_xmm
9
va_old_s
)
(va_get_xmm
10
va_old_s
)
(va_get_xmm
11
va_old_s
)
(va_get_xmm
12
va_old_s
)
(va_get_xmm
13
va_old_s
)
(va_get_xmm
14
va_old_s
)
(va_get_xmm
15
va_old_s
))
(va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 1068 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64
(
va_op_dst_opr64_reg64
rRax
)
(
va_op_opr64_reg64
rRcx
)
)
(va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 1070 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(
va_quick_DestroyHeaplets
()
)
(
va_QEmpty
(
()
)
)
))
))))))))))
))))))))) | false |
Hacl.Bignum.ModInv.fst | Hacl.Bignum.ModInv.bn_check_mod_inv_prime_st | val bn_check_mod_inv_prime_st : t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0 | let bn_check_mod_inv_prime_st (t:limb_t) (len:BN.meta_len t) =
n:lbignum t len
-> a:lbignum t len ->
Stack (limb t)
(requires fun h -> live h n /\ live h a /\ disjoint n a)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.bn_check_mod_inv_prime (as_seq h0 n) (as_seq h0 a)) | {
"file_name": "code/bignum/Hacl.Bignum.ModInv.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 62,
"end_line": 29,
"start_col": 0,
"start_line": 23
} | module Hacl.Bignum.ModInv
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
module ST = FStar.HyperStack.ST
module S = Hacl.Spec.Bignum.ModInv
module BN = Hacl.Bignum
module BE = Hacl.Bignum.Exponentiation
module BM = Hacl.Bignum.Montgomery
module SD = Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.ModInv.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.ModInv.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.ModInv",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.meta_len",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Bignum.Definitions.limb",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Lib.Buffer.disjoint",
"Lib.Buffer.modifies0",
"Prims.eq2",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.ModInv.bn_check_mod_inv_prime",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.as_seq"
] | [] | false | false | false | false | true | let bn_check_mod_inv_prime_st (t: limb_t) (len: BN.meta_len t) =
| n: lbignum t len -> a: lbignum t len
-> Stack (limb t)
(requires fun h -> live h n /\ live h a /\ disjoint n a)
(ensures
fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_check_mod_inv_prime (as_seq h0 n) (as_seq h0 a)) | false |
|
AlgHeap.fst | AlgHeap.st_monotonic | val st_monotonic (#a: _) (w: st_wp0 a) : Type0 | val st_monotonic (#a: _) (w: st_wp0 a) : Type0 | let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2 | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 83,
"end_line": 219,
"start_col": 0,
"start_line": 216
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | w: AlgHeap.st_wp0 a -> Type0 | Prims.Tot | [
"total"
] | [] | [
"AlgHeap.st_wp0",
"Prims.l_Forall",
"AlgHeap.state",
"FStar.Pervasives.Native.tuple2",
"Prims.logical",
"Prims.l_imp",
"FStar.Pervasives.Native.Mktuple2"
] | [] | false | false | false | true | true | let st_monotonic #a (w: st_wp0 a) : Type0 =
| forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2 | false |
AlgHeap.fst | AlgHeap.abides | val abides (#a: _) (labs: ops) (f: tree0 a) : prop | val abides (#a: _) (labs: ops) (f: tree0 a) : prop | let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 5,
"end_line": 52,
"start_col": 0,
"start_line": 47
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | labs: AlgHeap.ops -> f: AlgHeap.tree0 a -> Prims.prop | Prims.Tot | [
"total"
] | [] | [
"AlgHeap.ops",
"AlgHeap.tree0",
"AlgHeap.op",
"AlgHeap.op_inp",
"AlgHeap.op_out",
"Prims.l_and",
"Prims.b2t",
"FStar.List.Tot.Base.mem",
"Prims.l_Forall",
"AlgHeap.abides",
"Prims.l_True",
"Prims.prop"
] | [
"recursion"
] | false | false | false | true | true | let rec abides #a (labs: ops) (f: tree0 a) : prop =
| match f with
| Op a i k -> mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True | false |
Hacl.Bignum.ModInv.fst | Hacl.Bignum.ModInv.bn_mod_inv_prime_st | val bn_mod_inv_prime_st : t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0 | let bn_mod_inv_prime_st (t:limb_t) (len:BN.meta_len t) =
nBits:size_t
-> n:lbignum t len
-> a:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h res /\
disjoint res n /\ disjoint res a /\ disjoint n a /\
v nBits / bits t < v len /\ pow2 (v nBits) < bn_v h n /\
S.bn_mod_inv_prime_pre (as_seq h n) (as_seq h a))
(ensures fun h0 r h1 -> modifies (loc res) h0 h1 /\
bn_v h1 res * bn_v h0 a % bn_v h0 n = 1) | {
"file_name": "code/bignum/Hacl.Bignum.ModInv.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 44,
"end_line": 114,
"start_col": 0,
"start_line": 101
} | module Hacl.Bignum.ModInv
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
module ST = FStar.HyperStack.ST
module S = Hacl.Spec.Bignum.ModInv
module BN = Hacl.Bignum
module BE = Hacl.Bignum.Exponentiation
module BM = Hacl.Bignum.Montgomery
module SD = Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let bn_check_mod_inv_prime_st (t:limb_t) (len:BN.meta_len t) =
n:lbignum t len
-> a:lbignum t len ->
Stack (limb t)
(requires fun h -> live h n /\ live h a /\ disjoint n a)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.bn_check_mod_inv_prime (as_seq h0 n) (as_seq h0 a))
inline_for_extraction noextract
val bn_check_mod_inv_prime: #t:limb_t -> len:BN.meta_len t -> bn_check_mod_inv_prime_st t len
let bn_check_mod_inv_prime #t len n a =
let m0 = BM.bn_check_modulus n in
let m1 = BN.bn_is_zero_mask len a in
let m2 = BN.bn_lt_mask len a n in
m0 &. (lognot m1) &. m2
inline_for_extraction noextract
val bn_mod_inv_prime_n2:
#t:limb_t
-> len:BN.meta_len t
-> n:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h -> 1 < bn_v h n /\
live h n /\ live h res /\ disjoint res n)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mod_inv_prime_n2 (as_seq h0 n))
let bn_mod_inv_prime_n2 #t len n res =
let c = BN.bn_sub1 len n (uint #t #SEC 2) res in
LowStar.Ignore.ignore c;
()
inline_for_extraction noextract
let bn_mod_inv_prime_precomp_st (t:limb_t) (len:BN.meta_len t) =
n:lbignum t len
-> mu:limb t
-> r2:lbignum t len
-> a:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h r2 /\ live h a /\ live h res /\
disjoint res n /\ disjoint res a /\ disjoint n a /\
disjoint res r2 /\ disjoint a r2 /\ disjoint n r2 /\
S.bn_mod_inv_prime_pre (as_seq h n) (as_seq h a) /\
bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n /\
(1 + bn_v h n * v mu) % pow2 (bits t) == 0)
(ensures fun h0 r h1 -> modifies (loc res) h0 h1 /\
bn_v h1 res * bn_v h0 a % bn_v h0 n = 1)
inline_for_extraction noextract
val mk_bn_mod_inv_prime_precomp:
#t:limb_t
-> len:BN.meta_len t
-> bn_mod_exp_precomp:BE.bn_mod_exp_precomp_st t len ->
bn_mod_inv_prime_precomp_st t len
let mk_bn_mod_inv_prime_precomp #t len bn_mod_exp_precomp n mu r2 a res =
let h0 = ST.get () in
push_frame ();
let n2 = create len (uint #t #SEC 0) in
bn_mod_inv_prime_n2 #t len n n2;
SD.bn_eval_bound (as_seq h0 n) (v len);
bn_mod_exp_precomp n mu r2 a (size (bits t) *! len) n2 res;
let h1 = ST.get () in
assert (bn_v h1 res == Lib.NatMod.pow_mod #(bn_v h0 n) (bn_v h0 a) (bn_v h1 n2));
S.mod_inv_prime_lemma (bn_v h0 n) (bn_v h0 a);
pop_frame () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.ModInv.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.ModInv.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.ModInv",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.meta_len",
"Lib.IntTypes.size_t",
"Hacl.Bignum.Definitions.lbignum",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.disjoint",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_Division",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.bits",
"Prims.pow2",
"Hacl.Bignum.Definitions.bn_v",
"Hacl.Spec.Bignum.ModInv.bn_mod_inv_prime_pre",
"Lib.Buffer.as_seq",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"FStar.Mul.op_Star"
] | [] | false | false | false | false | true | let bn_mod_inv_prime_st (t: limb_t) (len: BN.meta_len t) =
| nBits: size_t -> n: lbignum t len -> a: lbignum t len -> res: lbignum t len
-> Stack unit
(requires
fun h ->
live h n /\ live h a /\ live h res /\ disjoint res n /\ disjoint res a /\ disjoint n a /\
v nBits / bits t < v len /\ pow2 (v nBits) < bn_v h n /\
S.bn_mod_inv_prime_pre (as_seq h n) (as_seq h a))
(ensures fun h0 r h1 -> modifies (loc res) h0 h1 /\ bn_v h1 res * bn_v h0 a % bn_v h0 n = 1) | false |
|
Hacl.Bignum.ModInv.fst | Hacl.Bignum.ModInv.bn_check_mod_inv_prime | val bn_check_mod_inv_prime: #t:limb_t -> len:BN.meta_len t -> bn_check_mod_inv_prime_st t len | val bn_check_mod_inv_prime: #t:limb_t -> len:BN.meta_len t -> bn_check_mod_inv_prime_st t len | let bn_check_mod_inv_prime #t len n a =
let m0 = BM.bn_check_modulus n in
let m1 = BN.bn_is_zero_mask len a in
let m2 = BN.bn_lt_mask len a n in
m0 &. (lognot m1) &. m2 | {
"file_name": "code/bignum/Hacl.Bignum.ModInv.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 25,
"end_line": 38,
"start_col": 0,
"start_line": 34
} | module Hacl.Bignum.ModInv
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
module ST = FStar.HyperStack.ST
module S = Hacl.Spec.Bignum.ModInv
module BN = Hacl.Bignum
module BE = Hacl.Bignum.Exponentiation
module BM = Hacl.Bignum.Montgomery
module SD = Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let bn_check_mod_inv_prime_st (t:limb_t) (len:BN.meta_len t) =
n:lbignum t len
-> a:lbignum t len ->
Stack (limb t)
(requires fun h -> live h n /\ live h a /\ disjoint n a)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.bn_check_mod_inv_prime (as_seq h0 n) (as_seq h0 a))
inline_for_extraction noextract | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.ModInv.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.ModInv.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.ModInv",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | len: Hacl.Bignum.meta_len t -> Hacl.Bignum.ModInv.bn_check_mod_inv_prime_st t len | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.meta_len",
"Hacl.Bignum.Definitions.lbignum",
"Lib.IntTypes.op_Amp_Dot",
"Lib.IntTypes.SEC",
"Lib.IntTypes.lognot",
"Hacl.Bignum.Definitions.limb",
"Hacl.Bignum.bn_lt_mask",
"Hacl.Bignum.bn_is_zero_mask",
"Hacl.Bignum.Montgomery.bn_check_modulus"
] | [] | false | false | false | false | false | let bn_check_mod_inv_prime #t len n a =
| let m0 = BM.bn_check_modulus n in
let m1 = BN.bn_is_zero_mask len a in
let m2 = BN.bn_lt_mask len a n in
m0 &. (lognot m1) &. m2 | false |
AlgHeap.fst | AlgHeap.interp_as_fun | val interp_as_fun (#a: _) (t: rwtree a) : (state -> a & state) | val interp_as_fun (#a: _) (t: rwtree a) : (state -> a & state) | let interp_as_fun #a (t : rwtree a) : (state -> a & state) =
interp_rdwr_tree t | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 20,
"end_line": 255,
"start_col": 0,
"start_line": 254
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0)
unfold
let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p)
unfold
let read_wp : st_wp state = fun s0 p -> p (s0, s0)
unfold
let write_wp : state -> st_wp unit = fun s _ p -> p ((), s)
(* Also doable with handlers *)
let rec interp_as_wp #a (t : rwtree a) : st_wp a =
match t with
| Return x -> return_wp x
| Op Read _ k ->
bind_wp read_wp (fun s -> interp_as_wp (k s))
| Op Write s k ->
bind_wp (write_wp s) (fun (o:unit) -> interp_as_wp (k o))
let rec interp_rdwr_tree #a (t : tree a [Read;Write]) (s:state) : Tot (a & state) =
match t with
| Return x -> (x, s)
| Op Read _ k ->
interp_rdwr_tree (k s) s
| Op Write s k ->
interp_rdwr_tree (k ()) s | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: AlgHeap.rwtree a -> _: AlgHeap.state -> a * AlgHeap.state | Prims.Tot | [
"total"
] | [] | [
"AlgHeap.rwtree",
"AlgHeap.interp_rdwr_tree",
"AlgHeap.state",
"FStar.Pervasives.Native.tuple2"
] | [] | false | false | false | true | false | let interp_as_fun #a (t: rwtree a) : (state -> a & state) =
| interp_rdwr_tree t | false |
AlgHeap.fst | AlgHeap.sublist | val sublist : l1: AlgHeap.ops -> l2: AlgHeap.ops -> Prims.logical | let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2 | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 59,
"end_line": 67,
"start_col": 0,
"start_line": 67
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l1: AlgHeap.ops -> l2: AlgHeap.ops -> Prims.logical | Prims.Tot | [
"total"
] | [] | [
"AlgHeap.ops",
"Prims.l_Forall",
"AlgHeap.op",
"Prims.l_imp",
"Prims.b2t",
"FStar.List.Tot.Base.mem",
"Prims.logical"
] | [] | false | false | false | true | true | let sublist (l1 l2: ops) =
| forall x. mem x l1 ==> mem x l2 | false |
|
AlgHeap.fst | AlgHeap.st_wp | val st_wp : a: Type -> Type | let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp} | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 49,
"end_line": 221,
"start_col": 0,
"start_line": 221
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Type -> Type | Prims.Tot | [
"total"
] | [] | [
"AlgHeap.st_wp0",
"AlgHeap.st_monotonic"
] | [] | false | false | false | true | true | let st_wp (a: Type) =
| wp: st_wp0 a {st_monotonic wp} | false |
|
AlgHeap.fst | AlgHeap.stronger | val stronger : (#a:Type) -> st_wp a -> st_wp a -> Type0 | val stronger : (#a:Type) -> st_wp a -> st_wp a -> Type0 | let stronger w1 w2 = forall p s. w1 p s ==> w2 p s | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 50,
"end_line": 260,
"start_col": 0,
"start_line": 260
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0)
unfold
let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p)
unfold
let read_wp : st_wp state = fun s0 p -> p (s0, s0)
unfold
let write_wp : state -> st_wp unit = fun s _ p -> p ((), s)
(* Also doable with handlers *)
let rec interp_as_wp #a (t : rwtree a) : st_wp a =
match t with
| Return x -> return_wp x
| Op Read _ k ->
bind_wp read_wp (fun s -> interp_as_wp (k s))
| Op Write s k ->
bind_wp (write_wp s) (fun (o:unit) -> interp_as_wp (k o))
let rec interp_rdwr_tree #a (t : tree a [Read;Write]) (s:state) : Tot (a & state) =
match t with
| Return x -> (x, s)
| Op Read _ k ->
interp_rdwr_tree (k s) s
| Op Write s k ->
interp_rdwr_tree (k ()) s
let interp_as_fun #a (t : rwtree a) : (state -> a & state) =
interp_rdwr_tree t
(* Bug: defining this as a FStar.Preorder.preorder
causes stupid failures ahead *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | w1: AlgHeap.st_wp a -> w2: AlgHeap.st_wp a -> Type0 | Prims.Tot | [
"total"
] | [] | [
"AlgHeap.st_wp",
"Prims.l_Forall",
"AlgHeap.state",
"FStar.Pervasives.Native.tuple2",
"Prims.l_imp"
] | [] | false | false | false | true | true | let stronger w1 w2 =
| forall p s. w1 p s ==> w2 p s | false |
Vale.Inline.X64.Fadd_inline.fst | Vale.Inline.X64.Fadd_inline.fadd | val fadd
(out:u256)
(f1:u256)
(f2:u256)
: Stack unit
(requires fun h ->
adx_enabled /\ bmi2_enabled /\
B.live h f1 /\ B.live h f2 /\ B.live h out /\
(B.disjoint out f1 \/ out == f1) /\
(B.disjoint out f2 \/ out == f2) /\
(B.disjoint f1 f2 \/ f1 == f2))
(ensures fun h0 _ h1 ->
B.modifies (B.loc_buffer out) h0 h1 /\
(as_nat out h1) % prime == (as_nat f1 h0 + as_nat f2 h0) % prime) | val fadd
(out:u256)
(f1:u256)
(f2:u256)
: Stack unit
(requires fun h ->
adx_enabled /\ bmi2_enabled /\
B.live h f1 /\ B.live h f2 /\ B.live h out /\
(B.disjoint out f1 \/ out == f1) /\
(B.disjoint out f2 \/ out == f2) /\
(B.disjoint f1 f2 \/ f1 == f2))
(ensures fun h0 _ h1 ->
B.modifies (B.loc_buffer out) h0 h1 /\
(as_nat out h1) % prime == (as_nat f1 h0 + as_nat f2 h0) % prime) | let fadd out f1 f2
= DV.length_eq (get_downview out);
DV.length_eq (get_downview f1);
DV.length_eq (get_downview f2);
let (x, _) = lowstar_fadd_normal_t out f1 f2 () in
() | {
"file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 6,
"end_line": 287,
"start_col": 0,
"start_line": 282
} | module Vale.Inline.X64.Fadd_inline
open FStar.Mul
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
module PR = Vale.X64.Print_Inline_s
module FU = Vale.Curve25519.X64.FastUtil
module FH = Vale.Curve25519.X64.FastHybrid
module FW = Vale.Curve25519.X64.FastWide
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
let as_t (#a:Type) (x:normal a) : a = x
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__]
let b64 = buf_t TUInt64 TUInt64
[@__reduce__]
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__]
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__]
let tuint64 = TD_Base TUInt64
[@__reduce__]
let dom: IX64.arity_ok 3 td =
let y = [t64_mod; t64_no_mod; tuint64] in
assert_norm (List.length y = 3);
y
(* Need to rearrange the order of arguments *)
[@__reduce__]
let add1_pre : VSig.vale_pre dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state) ->
FU.va_req_Fast_add1 c va_s0
(as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2)
[@__reduce__]
let add1_post : VSig.vale_post dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f
#set-options "--z3rlimit 50"
let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) ->
let open MS in
if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true
else false
let add1_xmms_modified = fun _ -> false
[@__reduce__]
let add1_lemma'
(code:V.va_code)
(_win:bool)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
add1_pre code out f1 f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions va_s0 va_s1 add1_regs_modified add1_xmms_modified /\
add1_post code out f1 f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
(va_s1, f)
(* Prove that add1_lemma' has the required type *)
let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma'
let code_add1 = FU.va_code_Fast_add1 ()
let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with
| 5 -> Some 0 // rdi
| 4 -> Some 1 // rsi
| 3 -> Some 2 // rdx
| _ -> None
let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with
| 0 -> MS.rRdi
| 1 -> MS.rRsi
| 2 -> MS.rRdx
let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg
(* Here's the type expected for the add1 wrapper *)
[@__reduce__]
let lowstar_add1_t =
assert_norm (List.length dom + List.length ([]<:list arg) <= 3);
IX64.as_lowstar_sig_t_weak
3
arg_reg
add1_regs_modified
add1_xmms_modified
code_add1
dom
[]
_
_
// The boolean here doesn't matter
(W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win))
(* And here's the add1 wrapper itself *)
let lowstar_add1 : lowstar_add1_t =
assert_norm (List.length dom + List.length ([]<:list arg) <= 3);
IX64.wrap_weak
3
arg_reg
add1_regs_modified
add1_xmms_modified
code_add1
dom
(W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win))
let lowstar_add1_normal_t : normal lowstar_add1_t
= as_normal_t #lowstar_add1_t lowstar_add1
open Vale.AsLowStar.MemoryHelpers
let add_scalar out f1 f2
= DV.length_eq (get_downview out);
DV.length_eq (get_downview f1);
let (x, _) = lowstar_add1_normal_t out f1 f2 () in
x
let add1_comments : list string =
["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"]
let add1_names (n:nat) =
match n with
| 0 -> "out"
| 1 -> "f1"
| 2 -> "f2"
| _ -> ""
let add1_code_inline () : FStar.All.ML int =
PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments
[@__reduce__]
let fadd_dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; t64_no_mod] in
assert_norm (List.length y = 3);
y
(* Need to rearrange the order of arguments *)
[@__reduce__]
let fadd_pre : VSig.vale_pre fadd_dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:b64)
(va_s0:V.va_state) ->
FH.va_req_Fadd c va_s0
(as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2)
[@__reduce__]
let fadd_post : VSig.vale_post fadd_dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FH.va_ens_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f
#set-options "--z3rlimit 50"
let fadd_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) ->
let open MS in
if r = rRax || r = rRcx || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true
else false
let fadd_xmms_modified = fun _ -> false
[@__reduce__]
let fadd_lemma'
(code:V.va_code)
(_win:bool)
(out:b64)
(f1:b64)
(f2:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fadd_pre code out f1 f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions va_s0 va_s1 fadd_regs_modified fadd_xmms_modified /\
fadd_post code out f1 f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FH.va_lemma_Fadd code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2;
(va_s1, f)
(* Prove that add1_lemma' has the required type *)
let fadd_lemma = as_t #(VSig.vale_sig fadd_regs_modified fadd_xmms_modified fadd_pre fadd_post) fadd_lemma'
let code_Fadd = FH.va_code_Fadd ()
(* Here's the type expected for the fadd wrapper *)
[@__reduce__]
let lowstar_fadd_t =
assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3);
IX64.as_lowstar_sig_t_weak
3
arg_reg
fadd_regs_modified
fadd_xmms_modified
code_Fadd
fadd_dom
[]
_
_
// The boolean here doesn't matter
(W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win))
(* And here's the fadd wrapper itself *)
let lowstar_fadd : lowstar_fadd_t =
assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3);
IX64.wrap_weak
3
arg_reg
fadd_regs_modified
fadd_xmms_modified
code_Fadd
fadd_dom
(W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win))
let lowstar_fadd_normal_t : normal lowstar_fadd_t
= as_normal_t #lowstar_fadd_t lowstar_fadd | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_Inline_s.fst.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Curve25519.X64.FastWide.fsti.checked",
"Vale.Curve25519.X64.FastUtil.fsti.checked",
"Vale.Curve25519.X64.FastHybrid.fsti.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Inline.X64.Fadd_inline.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AsLowStar.MemoryHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastWide",
"short_module": "FW"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastHybrid",
"short_module": "FH"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"abbrev": true,
"full_module": "Vale.X64.Print_Inline_s",
"short_module": "PR"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519.Fast_defs",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
out: Vale.Inline.X64.Fadd_inline.u256 ->
f1: Vale.Inline.X64.Fadd_inline.u256 ->
f2: Vale.Inline.X64.Fadd_inline.u256
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Vale.Inline.X64.Fadd_inline.u256",
"FStar.UInt64.t",
"FStar.Ghost.erased",
"Vale.Interop.X64.as_lowstar_sig_ret",
"Prims.unit",
"Vale.Interop.X64.als_ret",
"Vale.Inline.X64.Fadd_inline.lowstar_fadd_normal_t",
"LowStar.BufferView.Down.length_eq",
"FStar.UInt8.t",
"Vale.Interop.Types.get_downview",
"Vale.Arch.HeapTypes_s.TUInt64",
"LowStar.Buffer.trivial_preorder"
] | [] | false | true | false | false | false | let fadd out f1 f2 =
| DV.length_eq (get_downview out);
DV.length_eq (get_downview f1);
DV.length_eq (get_downview f2);
let x, _ = lowstar_fadd_normal_t out f1 f2 () in
() | false |
Vale.AES.X64.GCMdecryptOpt.fst | Vale.AES.X64.GCMdecryptOpt.va_wp_Gcm_blocks_wrapped | val va_wp_Gcm_blocks_wrapped
(alg: algorithm)
(offset: int)
(auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b: buffer128)
(iv: supported_iv_LE)
(scratch_b: buffer128)
(key: (seq nat32))
(round_keys: (seq quad32))
(keys_b hkeys_b: buffer128)
(expected_tag: (seq nat8))
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | val va_wp_Gcm_blocks_wrapped
(alg: algorithm)
(offset: int)
(auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b: buffer128)
(iv: supported_iv_LE)
(scratch_b: buffer128)
(key: (seq nat32))
(round_keys: (seq quad32))
(keys_b hkeys_b: buffer128)
(expected_tag: (seq nat8))
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | let va_wp_Gcm_blocks_wrapped (alg:algorithm) (offset:int) (auth_b:buffer128) (abytes_b:buffer128)
(in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128) (out128_b:buffer128)
(inout_b:buffer128) (iv_b:buffer128) (iv:supported_iv_LE) (scratch_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (expected_tag:(seq nat8))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
sse_enabled /\ movbe_enabled /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 +
offset + 0) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 32) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 48) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 64) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) auth_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0) (va_get_reg64 rR8 va_s0) iv_b 1
(va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6
va_s0) in128x6_ptr in128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6 va_s0) out128x6_ptr out128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1
va_s0) in128_ptr in128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) out128_ptr out128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5
va_s0) inout_ptr inout_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128
(va_get_mem_heaplet 3 va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0)
hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\ (let iv_BE =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let h_LE =
Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
in iv_BE == Vale.AES.GCM_s.compute_iv_BE h_LE iv)) /\ (forall (va_x_mem:vale_heap)
(va_x_rax:nat64) (va_x_rbx:nat64) (va_x_rcx:nat64) (va_x_rdx:nat64) (va_x_rdi:nat64)
(va_x_rsi:nat64) (va_x_rbp:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64)
(va_x_r11:nat64) (va_x_r12:nat64) (va_x_r13:nat64) (va_x_r14:nat64) (va_x_r15:nat64)
(va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32)
(va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm9:quad32)
(va_x_xmm10:quad32) (va_x_xmm11:quad32) (va_x_xmm12:quad32) (va_x_xmm13:quad32)
(va_x_xmm14:quad32) (va_x_xmm15:quad32) (va_x_heap1:vale_heap) (va_x_heap2:vale_heap)
(va_x_heap3:vale_heap) (va_x_heap5:vale_heap) (va_x_heap6:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 6
va_x_heap6 (va_upd_mem_heaplet 5 va_x_heap5 (va_upd_mem_heaplet 3 va_x_heap3
(va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 15 va_x_xmm15
(va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12 (va_upd_xmm 11
va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (va_upd_xmm 8 va_x_xmm8
(va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4
(va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0
(va_upd_reg64 rR15 va_x_r15 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13
(va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10
(va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRbp va_x_rbp (va_upd_reg64
rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRcx
va_x_rcx (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem
va_s0))))))))))))))))))))))))))))))))))))) in va_get_ok va_sM /\ (let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in Vale.X64.Decls.modifies_buffer128 out128_b
(va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128
iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\
Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM) /\ Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0)
(va_get_mem_heaplet 5 va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b
(va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\
va_get_reg64 rRsi va_s0 < pow2_32 /\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0
(va_get_mem_heaplet 2 va_s0) in let auth_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_s0) abytes_b) in let auth_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
auth_raw_quads) 0 (va_get_reg64 rRsi va_s0) in let plain_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0)
in128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) in let plain_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
plain_raw_quads) 0 plain_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) in let cipher_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
cipher_raw_quads) 0 plain_num_bytes in l_and (l_and (l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.nat8 auth_bytes < pow2_32) (FStar.Seq.Base.length #Vale.Def.Types_s.nat8
plain_bytes < pow2_32)) (cipher_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq
Vale.Def.Types_s.nat8) #bool (Vale.AES.GCM_s.gcm_decrypt_LE alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes expected_tag)))
(Vale.Def.Types_s.le_quad32_to_bytes (va_get_xmm 8 va_sM) == Vale.AES.GCM.gcm_decrypt_LE_tag
alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) ==> va_k
va_sM (()))) | {
"file_name": "obj/Vale.AES.X64.GCMdecryptOpt.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 1839,
"start_col": 0,
"start_line": 1694
} | module Vale.AES.X64.GCMdecryptOpt
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open FStar.Seq
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_s
open Vale.AES.GCTR_s
open Vale.AES.GCTR
open Vale.AES.GCM
open Vale.AES.GHash_s
open Vale.AES.GHash
open Vale.AES.GCM_s
open Vale.AES.X64.AES
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.Poly1305.Math
open Vale.AES.GCM_helpers
open Vale.AES.X64.GHash
open Vale.AES.X64.GCTR
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.X64.Stack_i
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.InsBasic
open Vale.X64.InsMem
open Vale.X64.InsVector
open Vale.X64.InsStack
open Vale.X64.InsAes
open Vale.X64.QuickCode
open Vale.X64.QuickCodes
open Vale.AES.X64.GF128_Mul
open Vale.X64.Stack
open Vale.X64.CPU_Features_s
open Vale.Math.Poly2.Bits_s
open Vale.AES.X64.AESopt
open Vale.AES.X64.AESGCM
open Vale.AES.X64.AESopt2
open Vale.Lib.Meta
open Vale.AES.X64.GCMencryptOpt
open Vale.AES.OptPublic
open Vale.Lib.Basic
#reset-options "--z3rlimit 20 --max_ifuel 0"
//-- Gcm_extra_bytes
val va_code_Gcm_extra_bytes : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_extra_bytes alg =
(va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0)
(va_op_reg_opr64_reg64 rRax) 0 Secret) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 10)
(va_op_xmm_xmm 0)) (va_CCons (va_code_Ghash_extra_bytes ()) (va_CCons (va_code_Mov128
(va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_CCons (va_code_Pshufb (va_op_xmm_xmm 0)
(va_op_xmm_xmm 9)) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons (va_code_Pxor
(va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_CCons (va_code_Store128_buffer
(va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret)
(va_CNil ()))))))))))
val va_codegen_success_Gcm_extra_bytes : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_extra_bytes alg =
(va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0)
(va_op_reg_opr64_reg64 rRax) 0 Secret) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm
10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Ghash_extra_bytes ()) (va_pbool_and
(va_codegen_success_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_pbool_and
(va_codegen_success_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and
(va_codegen_success_AESEncryptBlock alg) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm
10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Store128_buffer
(va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret)
(va_ttrue ())))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_extra_bytes (va_mods:va_mods_t) (alg:algorithm) (inout_b:buffer128) (key:(seq
nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat)
(old_hash:quad32) (completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit
(va_code_Gcm_extra_bytes alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (len:(va_int_range
1 1)) = 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 188 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRax) 0 Secret inout_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 189 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (fun (va_s:va_state) _ -> let
(hash_input:quad32) = va_get_xmm 0 va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 193 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_extra_bytes hkeys_b total_bytes old_hash h_LE completed_quads) (fun
(va_s:va_state) _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 194 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.equal #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s)
inout_b) (FStar.Seq.Base.create #quad32 1 hash_input)) (let (snap:(FStar.Seq.Base.seq
Vale.X64.Decls.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 198 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 199 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 200 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AESEncryptBlock alg (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 11 va_s)) key
round_keys keys_b) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 201 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.AES_s.aes_encrypt_LE_reveal ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 204 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 205 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax)
(va_op_xmm_xmm 10) 0 Secret inout_b 0) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 207 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.gctr_partial_reveal ()) (va_QEmpty (()))))))))))))))
val va_lemma_Gcm_extra_bytes : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
inout_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> total_bytes:nat -> old_hash:quad32 -> completed_quads:(seq quad32) ->
h_LE:quad32
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_extra_bytes alg) va_s0 /\ va_get_ok va_s0 /\ (let
(len:(va_int_range 1 1)) = 1 in sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b
inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b inout_b /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax va_s0) inout_b
len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys
keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0
va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32
(Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length
#quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply`
FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes
`op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16
`op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
(Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads =
FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0)
inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes =
Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) /\ va_state_eq va_sM
(va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM (va_update_ok va_sM
(va_update_mem va_sM va_s0))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_extra_bytes va_b0 va_s0 alg inout_b key round_keys keys_b hkeys_b total_bytes
old_hash completed_quads h_LE =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_extra_bytes va_mods alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_extra_bytes alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 121 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (len:(va_int_range 1 1)) = 1 in label va_range1
"***** POSTCONDITION NOT MET AT line 174 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 177 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg len (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0)) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 180 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let raw_quads = FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 181 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 182 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 183 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let input_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 186 column 59 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(l_and (FStar.Seq.Base.length #Vale.Def.Types_s.quad32 input_quads > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE old_hash input_quads)))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm
7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32)
(completed_quads:(seq quad32)) (h_LE:quad32) (va_s0:va_state) (va_k:(va_state -> unit -> Type0))
: Type0 =
(va_get_ok va_s0 /\ (let (len:(va_int_range 1 1)) = 1 in sse_enabled /\
Vale.X64.Decls.buffers_disjoint128 keys_b inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b
inout_b /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax
va_s0) inout_b len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys
keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0
va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32
(Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length
#quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply`
FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes
`op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16
`op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
(Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes) /\ (forall
(va_x_mem:vale_heap) (va_x_rcx:nat64) (va_x_r11:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32)
(va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32)
(va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm10:quad32) (va_x_heap5:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 5
va_x_heap5 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7
(va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3
(va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR11
va_x_r11 (va_upd_reg64 rRcx va_x_rcx (va_upd_mem va_x_mem va_s0)))))))))))))) in va_get_ok
va_sM /\ (let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads =
FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0)
inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes =
Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) ==> va_k va_sM (())))
val va_wpProof_Gcm_extra_bytes : alg:algorithm -> inout_b:buffer128 -> key:(seq nat32) ->
round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> total_bytes:nat ->
old_hash:quad32 -> completed_quads:(seq quad32) -> h_LE: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_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_extra_bytes alg) ([va_Mod_flags;
va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5;
va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11;
va_Mod_reg64 rRcx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash
completed_quads h_LE va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_extra_bytes (va_code_Gcm_extra_bytes alg) va_s0 alg inout_b key
round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10
va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm
7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32)
(completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit (va_code_Gcm_extra_bytes alg)) =
(va_QProc (va_code_Gcm_extra_bytes alg) ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10;
va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm
2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem])
(va_wp_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash
completed_quads h_LE) (va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE))
//--
//-- Gcm_blocks128
val va_code_Gcm_blocks128 : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks128 alg =
(va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi))
(va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_CCons
(va_code_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_CCons
(va_code_Ghash_buffer ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdi)
(va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx)
(va_op_opr64_reg64 rR12)) (va_CCons (va_code_Gctr_blocks128 alg) (va_CNil ())))))))))
val va_codegen_success_Gcm_blocks128 : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks128 alg =
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi))
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx))
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax))
(va_pbool_and (va_codegen_success_Ghash_buffer ()) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_pbool_and
(va_codegen_success_Gctr_blocks128 alg) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks128 (va_mods:va_mods_t) (alg:algorithm) (in_b:buffer128) (out_b:buffer128)
(key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32)
: (va_quickCode unit (va_code_Gcm_blocks128 alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 274 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 275 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 276 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 277 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_buffer hkeys_b in_b h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_old_s))) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 278 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 279 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 280 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gctr_blocks128 alg in_b out_b key round_keys keys_b) (va_QEmpty (()))))))))))
val va_lemma_Gcm_blocks128 : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> in_b:buffer128 ->
out_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> h_LE:quad32
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks128 alg) va_s0 /\ va_get_ok va_s0 /\
(sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b out_b /\
Vale.X64.Decls.buffers_disjoint128 hkeys_b out_b /\ (Vale.X64.Decls.buffers_disjoint128 in_b
out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16
`op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply`
va_get_reg64 rRdx va_s0 < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b)
(Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx
va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\
va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8
va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0)
(va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM ==
va_get_xmm 8 va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b ==
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ (va_get_reg64 rRdx va_s0 > 0 ==>
l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==> FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b)))) /\ va_state_eq va_sM (va_update_flags va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 10 va_sM (va_update_xmm 11 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rR10 va_sM
(va_update_reg64 rR11 va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRbx va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_blocks128 va_b0 va_s0 alg in_b out_b key round_keys keys_b hkeys_b h_LE =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11;
va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm
2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks128 va_mods alg in_b out_b key round_keys keys_b hkeys_b h_LE in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks128 alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 210 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 255 column 53 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 261 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 262 column 45 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0) (va_get_reg64 rRdx
va_s0)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 265 column 93 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM == va_get_xmm 8 va_s0)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b == Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) out_b)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 267 column 131 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRdx va_s0 > 0 ==> l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==>
FStar.Seq.Base.length #Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm
8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2;
va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_blocks128 (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32) (va_s0:va_state)
(va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b out_b /\
Vale.X64.Decls.buffers_disjoint128 hkeys_b out_b /\ (Vale.X64.Decls.buffers_disjoint128 in_b
out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16
`op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply`
va_get_reg64 rRdx va_s0 < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b)
(Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx
va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\
va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8
va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret) /\ (forall (va_x_mem:vale_heap) (va_x_rbx:nat64) (va_x_rdi:nat64) (va_x_r11:nat64)
(va_x_r10:nat64) (va_x_rdx:nat64) (va_x_r12:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32)
(va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32)
(va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm11:quad32) (va_x_xmm10:quad32)
(va_x_heap1:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 11 va_x_xmm11
(va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5
(va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1
(va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64
rR10 va_x_r10 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRbx
va_x_rbx (va_upd_mem va_x_mem va_s0))))))))))))))))))) in va_get_ok va_sM /\
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0)
(va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM ==
va_get_xmm 8 va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b ==
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ (va_get_reg64 rRdx va_s0 > 0 ==>
l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==> FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b)))) ==> va_k va_sM (())))
val va_wpProof_Gcm_blocks128 : alg:algorithm -> in_b:buffer128 -> out_b:buffer128 -> key:(seq
nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> h_LE: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_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b
h_LE va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks128 alg) ([va_Mod_flags;
va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6;
va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0;
va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10; va_Mod_reg64 rR11; va_Mod_reg64 rRdi;
va_Mod_reg64 rRbx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_blocks128 (va_code_Gcm_blocks128 alg) va_s0 alg in_b out_b key
round_keys keys_b hkeys_b h_LE in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 1 va_sM (va_update_xmm 10
va_sM (va_update_xmm 11 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6
va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2
va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR12 va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rRdi va_sM (va_update_reg64 rRbx va_sM (va_update_ok va_sM (va_update_mem
va_sM va_s0))))))))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm
8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2;
va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_blocks128 (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32) : (va_quickCode
unit (va_code_Gcm_blocks128 alg)) =
(va_QProc (va_code_Gcm_blocks128 alg) ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10;
va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm
3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64
rR10; va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_mem])
(va_wp_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE)
(va_wpProof_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE))
//--
//-- Gcm_blocks
#push-options "--z3rlimit 1000"
val va_code_Gcm_blocks : alg:algorithm -> offset:int -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks alg offset =
(va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx))
(va_CCons (va_code_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9) (va_const_opr64
32)) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRsp)
(offset + 0)) (va_CCons (va_code_Gcm_blocks_auth ()) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8)) (va_CCons
(va_code_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp) (offset + 16))
(va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp)
(offset + 24)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13))
(va_CCons (va_code_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64
rR8) 0 Public) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_reg_opr64_reg64 rRbp) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_Load_one_lsb
(va_op_xmm_xmm 10)) (va_CCons (va_code_VPaddd (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)
(va_op_xmm_xmm 10)) (va_CCons (va_code_AES_GCM_decrypt_6mult alg) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11) (va_op_reg_opr64_reg64
rRbp) 32 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx))
(va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp)
(offset + 32)) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRdi)
(va_op_reg_opr64_reg64 rRsp) (offset + 40)) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 48)) (va_CCons
(va_code_Mov64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRdx)) (va_CCons
(va_code_InitPshufbMask (va_op_xmm_xmm 9) (va_op_reg_opr64_reg64 rR12)) (va_CCons
(va_code_Pshufb (va_op_xmm_xmm 11) (va_op_xmm_xmm 9)) (va_CCons (va_code_Gcm_blocks128 alg)
(va_CCons (va_code_Stack_lemma ()) (va_CCons (va_code_Add64 (va_op_dst_opr64_reg64 rR14)
(va_opr_code_Stack (va_op_reg64_reg64 rRsp) (offset + 24) Public)) (va_CCons (va_code_IMul64
(va_op_dst_opr64_reg64 rR14) (va_const_opr64 16)) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rR13) (va_op_reg_opr64_reg64 rRsp) (offset + 64)) (va_CCons (va_IfElse
(va_cmp_gt (va_op_cmp_reg64 rR13) (va_op_cmp_reg64 rR14)) (va_Block (va_CCons
(va_code_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 56))
(va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR13)) (va_CCons
(va_code_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 15)) (va_CCons
(va_code_Gcm_extra_bytes alg) (va_CCons (va_Block (va_CNil ())) (va_CNil ()))))))) (va_Block
(va_CNil ()))) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15))
(va_CCons (va_code_Gcm_make_length_quad ()) (va_CCons (va_code_Ghash_register ()) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRbp) 0 Secret) (va_CCons (va_code_Gctr_register alg) (va_CCons (va_Block (va_CNil ()))
(va_CNil ()))))))))))))))))))))))))))))))))))))
val va_codegen_success_Gcm_blocks : alg:algorithm -> offset:int -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks alg offset =
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx))
(va_pbool_and (va_codegen_success_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9)
(va_const_opr64 32)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64
rRbx) (va_op_reg_opr64_reg64 rRsp) (offset + 0)) (va_pbool_and
(va_codegen_success_Gcm_blocks_auth ()) (va_pbool_and (va_codegen_success_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8)) (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp)
(offset + 16)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRdx)
(va_op_reg_opr64_reg64 rRsp) (offset + 24)) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13)) (va_pbool_and (va_codegen_success_Mov128
(va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_Load128_buffer
(va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rR8) 0 Public)
(va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_reg_opr64_reg64 rRbp) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and
(va_codegen_success_Load_one_lsb (va_op_xmm_xmm 10)) (va_pbool_and (va_codegen_success_VPaddd
(va_op_xmm_xmm 1) (va_op_xmm_xmm 1) (va_op_xmm_xmm 10)) (va_pbool_and
(va_codegen_success_AES_GCM_decrypt_6mult alg) (va_pbool_and (va_codegen_success_Load128_buffer
(va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11) (va_op_reg_opr64_reg64 rRbp) 32 Secret)
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx))
(va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRax)
(va_op_reg_opr64_reg64 rRsp) (offset + 32)) (va_pbool_and (va_codegen_success_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 40)) (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp)
(offset + 48)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR14)
(va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_InitPshufbMask (va_op_xmm_xmm 9)
(va_op_reg_opr64_reg64 rR12)) (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 11)
(va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_Gcm_blocks128 alg) (va_pbool_and
(va_codegen_success_Stack_lemma ()) (va_pbool_and (va_codegen_success_Add64
(va_op_dst_opr64_reg64 rR14) (va_opr_code_Stack (va_op_reg64_reg64 rRsp) (offset + 24) Public))
(va_pbool_and (va_codegen_success_IMul64 (va_op_dst_opr64_reg64 rR14) (va_const_opr64 16))
(va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rR13)
(va_op_reg_opr64_reg64 rRsp) (offset + 64)) (va_pbool_and (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp)
(offset + 56)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR10)
(va_op_opr64_reg64 rR13)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rR10)
(va_const_opr64 15)) (va_codegen_success_Gcm_extra_bytes alg)))) (va_pbool_and
(va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15)) (va_pbool_and
(va_codegen_success_Gcm_make_length_quad ()) (va_pbool_and (va_codegen_success_Ghash_register
()) (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRbp) 0 Secret) (va_pbool_and
(va_codegen_success_Gctr_register alg) (va_ttrue ()))))))))))))))))))))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks (va_mods:va_mods_t) (alg:algorithm) (offset:int) (auth_b:buffer128)
(abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128)
(out128_b:buffer128) (inout_b:buffer128) (iv_b:buffer128) (scratch_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit
(va_code_Gcm_blocks alg offset)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 0) (va_get_stack va_s) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 8) (va_get_stack va_s) in let
(out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 16) (va_get_stack va_s) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 24) (va_get_stack va_s) in let
(in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 32) (va_get_stack va_s) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 40) (va_get_stack va_s) in let
(len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset
+ 48) (va_get_stack va_s) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 56) (va_get_stack va_s) in let
(plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s
+ offset + 64) (va_get_stack va_s) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_old_s)) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 463 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 464 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9) (va_const_opr64 32))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 465 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRsp) (offset + 0))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 466 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks_auth auth_b abytes_b hkeys_b h_LE) (fun (va_s:va_state)
(auth_quad_seq:(seq quad32)) -> let (y_0:quad32) = Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 0 0 0 0 in let (y_auth_bytes:quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 473 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 474 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp) (offset + 16))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 475 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 24))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 476 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 477 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (fun (va_s:va_state) _ -> let
(iv_BE:Vale.X64.Decls.quad32) = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2
va_old_s) in let (ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32
iv_BE 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 483 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64
rR8) 0 Public iv_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 485 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_reg_opr64_reg64 rRbp)
(va_op_xmm_xmm 1) 0 Secret scratch_b 0) (fun (va_s:va_state) _ -> let (j0:quad32) = va_get_xmm
1 va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 487 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load_one_lsb (va_op_xmm_xmm 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 489 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_VPaddd (va_op_xmm_xmm 1) (va_op_xmm_xmm 1) (va_op_xmm_xmm 10)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 491 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AES_GCM_decrypt_6mult alg h_LE iv_b in128x6_b out128x6_b scratch_b key round_keys
keys_b hkeys_b) (fun (va_s:va_state) _ -> let (y_cipher128x6:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in let (auth_in:(seq quad32)) =
auth_quad_seq in let (va_arg138:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) =
Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b in let
(va_arg137:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg136:Vale.Def.Types_s.quad32) = y_auth_bytes in let (va_arg135:Vale.Def.Types_s.quad32) =
y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 494 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_ghash_incremental0_append h_LE va_arg135 va_arg136
y_cipher128x6 va_arg137 va_arg138) (let auth_in = FStar.Seq.Base.append #quad32 auth_in
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 498 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11)
(va_op_reg_opr64_reg64 rRbp) 32 Secret scratch_b 2) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 499 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 500 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 32))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 501 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 40))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 502 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 48))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 503 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 504 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_InitPshufbMask (va_op_xmm_xmm 9) (va_op_reg_opr64_reg64 rR12)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 505 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pshufb (va_op_xmm_xmm 11) (va_op_xmm_xmm 9)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 506 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks128 alg in128_b out128_b key round_keys keys_b hkeys_b h_LE) (fun
(va_s:va_state) _ -> let (y_cipher128:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in let (va_arg134:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b in let
(va_arg133:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg132:Vale.Def.Types_s.quad32) = y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 508 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_ghash_incremental0_append h_LE va_arg132 y_cipher128x6
y_cipher128 va_arg133 va_arg134) (let auth_in = FStar.Seq.Base.append #quad32 auth_in
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 512 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Stack_lemma (va_op_reg64_reg64 rRsp) (offset + 24) Public) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 512 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Add64 (va_op_dst_opr64_reg64 rR14) (va_opr_code_Stack (va_op_reg64_reg64 rRsp)
(offset + 24) Public)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 513 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_IMul64 (va_op_dst_opr64_reg64 rR14) (va_const_opr64 16)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 514 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rR13) (va_op_reg_opr64_reg64 rRsp) (offset + 64))
(fun (va_s:va_state) _ -> let (y_inout:Vale.Def.Types_s.quad32) = y_cipher128 in let
(plain_byte_seq:(seq quad32)) = empty_seq_quad32 in let (cipher_byte_seq:(seq quad32)) =
empty_seq_quad32 in let (va_arg131:Vale.Def.Types_s.quad32) = va_get_xmm 11 va_s in let
(va_arg130:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in let
(va_arg129:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = cipher_byte_seq in let
(va_arg128:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = plain_byte_seq in let
(va_arg127:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 519 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.gctr_partial_opaque_init va_arg127 va_arg128 va_arg129 va_arg130
va_arg131) (let (total_bytes:(va_int_at_least 0)) = FStar.Seq.Base.length #quad32 auth_quad_seq
`op_Multiply` 16 + plain_num_bytes in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 523 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_qIf va_mods (Cmp_gt (va_op_cmp_reg64 rR13) (va_op_cmp_reg64 rR14)) (qblock va_mods (fun
(va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 525 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 56))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 526 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR13)) (fun (va_s:va_state) _
-> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 527 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.Poly1305.Math.lemma_poly_bits64 ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 528 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 15)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 532 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes y_0 auth_in
h_LE) (fun (va_s:va_state) _ -> let y_inout = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm
8 va_s) in let (raw_auth_quads:(FStar.Seq.Base.seq quad32)) = FStar.Seq.Base.append #quad32
auth_in (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b) in va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 536 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun a_1906 (s_1907:(FStar.Seq.Base.seq a_1906)) (i_1908:Prims.nat) (j_1909:Prims.nat) -> let
(j_1869:Prims.nat) = j_1909 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1908
j_1869) (Prims.op_LessThanOrEqual j_1869 (FStar.Seq.Base.length #a_1906 s_1907))))
Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 total_bytes)
(fun _ -> let (auth_input_bytes:(FStar.Seq.Base.seq Vale.Def.Types_s.nat8)) =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
raw_auth_quads) 0 total_bytes in let (padded_auth_bytes:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in let auth_in =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes in let plain_byte_seq =
Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b in let cipher_byte_seq =
Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b in va_QEmpty ((auth_in,
cipher_byte_seq, plain_byte_seq, y_inout)))))))))) (qblock va_mods (fun (va_s:va_state) ->
va_QEmpty ((auth_in, cipher_byte_seq, plain_byte_seq, y_inout))))) (fun (va_s:va_state) va_g ->
let ((auth_in:(seq quad32)), (cipher_byte_seq:(seq quad32)), (plain_byte_seq:(seq quad32)),
(y_inout:Vale.Def.Types_s.quad32)) = va_g in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 547 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 548 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_make_length_quad ()) (fun (va_s:va_state) _ -> let
(length_quad32:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 0
va_s) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 551 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_register hkeys_b h_LE y_inout) (fun (va_s:va_state) _ -> let
(y_final:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s)
in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 554 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRbp) 0 Secret scratch_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 557 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gctr_register alg key round_keys keys_b) (fun (va_s:va_state) _ -> let
(va_arg126:Vale.Def.Types_s.quad32) = va_get_xmm 8 va_s in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 560 column 40 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.Arch.Types.le_seq_quad32_to_bytes_of_singleton va_arg126)
(va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 561 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun (icb_BE_677:Vale.Def.Types_s.quad32) (plain_LE_678:Vale.Def.Types_s.quad32)
(alg_679:Vale.AES.AES_common_s.algorithm) (key_680:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32))
(i_681:Prims.int) -> Vale.AES.AES_s.is_aes_key_LE alg_679 key_680) j0 y_final alg key 0) (fun _
-> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 561 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 8 va_s == Vale.AES.GCTR_s.gctr_encrypt_block j0 y_final alg key 0) (let
(plain128:(FStar.Seq.Base.seq Vale.X64.Decls.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in let
(cipher128:(FStar.Seq.Base.seq Vale.X64.Decls.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) in128_b) in va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 566 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.length #quad32 plain_byte_seq == 0 ==> FStar.Seq.Base.equal
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 plain128 plain_byte_seq)
plain128) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 567 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.length #quad32 cipher_byte_seq == 0 ==> FStar.Seq.Base.equal
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 cipher128 cipher_byte_seq)
cipher128) (let (va_arg125:Vale.Def.Types_s.quad32) = Vale.AES.GCTR.inc32lite ctr_BE_2 len128x6
in let (va_arg124:Vale.Def.Types_s.quad32) = ctr_BE_2 in let (va_arg123:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) = key in let (va_arg122:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32))
= Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b in let
(va_arg121:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) in128_b in let (va_arg120:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) out128x6_b in let
(va_arg119:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_old_s) in128x6_b in let (va_arg118:Prims.nat) = len128 in let
(va_arg117:Prims.nat) = len128x6 in let (va_arg116:Vale.AES.AES_common_s.algorithm) = alg in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 569 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.lemma_gctr_partial_append va_arg116 va_arg117 va_arg118
va_arg119 va_arg120 va_arg121 va_arg122 va_arg123 va_arg124 va_arg125) (let
(va_arg115:Vale.Def.Types_s.quad32) = Vale.AES.GCTR.inc32lite (Vale.AES.GCTR.inc32lite ctr_BE_2
len128x6) len128 in let (va_arg114:Vale.Def.Types_s.quad32) = ctr_BE_2 in let
(va_arg113:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in let
(va_arg112:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = cipher_byte_seq in let
(va_arg111:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = plain_byte_seq in let
(va_arg110:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b) in let
(va_arg109:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in let (va_arg108:Prims.nat) =
FStar.Seq.Base.length #quad32 plain_byte_seq in let (va_arg107:Prims.nat) = len128x6 + len128
in let (va_arg106:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 575 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.lemma_gctr_partial_append va_arg106 va_arg107 va_arg108
va_arg109 va_arg110 va_arg111 va_arg112 va_arg113 va_arg114 va_arg115) (let
(va_arg105:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg104:Vale.Def.Types_s.quad32) = y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 583 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_hash_append2 h_LE va_arg104 y_inout y_final va_arg105
length_quad32) (let auth_in = FStar.Seq.Base.append #quad32 auth_in (FStar.Seq.Base.create
#Vale.Def.Types_s.quad32 1 length_quad32) in let (va_arg103:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = auth_in in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 585 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.ghash_incremental_to_ghash h_LE va_arg103) (va_QEmpty
(()))))))))))))))))))))))))))))))))))))))))))))))))
val va_lemma_Gcm_blocks : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> offset:int ->
auth_b:buffer128 -> abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 ->
in128_b:buffer128 -> out128_b:buffer128 -> inout_b:buffer128 -> iv_b:buffer128 ->
scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks alg offset) va_s0 /\ va_get_ok va_s0 /\
(let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in sse_enabled /\ movbe_enabled /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp
va_s0 + offset + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet
1 va_s0) (va_get_reg64 rRdi va_s0) auth_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2
va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6
va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) in128_ptr in128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1
va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) inout_ptr inout_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0) hkeys_b 8
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet
1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b
(va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer128
scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) /\
Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32
/\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let
(ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in let
(plain_in:(seq quad32)) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) then FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) else FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in let (cipher_out:(seq quad32)) = (if (plain_num_bytes
> (len128x6 + len128) `op_Multiply` 128 `op_Division` 8) then FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) else
FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM)
out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b)) in let
(cipher_bound:nat) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128 `op_Division`
8) then (len128x6 + len128 + 1) else (len128x6 + len128)) in Vale.AES.GCTR.gctr_partial alg
cipher_bound plain_in cipher_out key ctr_BE_2 /\ (let (length_quad:quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) (8
`op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply` plain_num_bytes) 0) in let
(raw_auth_quads:(seq quad32)) = (if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) then FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b) else Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0)
auth_b) in let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64 rRsi va_s0) in let
(padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in let
(auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes in let
(raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 (FStar.Seq.Base.append #quad32
auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in let (total_bytes:nat) =
FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 + plain_num_bytes in let
(raw_quad_seq:(seq quad32)) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) then (let (ab:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32 raw_quad_seq
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let (pb:(seq
nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32 pb) else
raw_quad_seq) in let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 raw_quad_seq
(FStar.Seq.Base.create #quad32 1 length_quad) in va_get_xmm 8 va_sM ==
Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE h_LE auth_quad_seq) alg
key 0))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM
(va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm
13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm
9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM
(va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM
(va_update_reg64 rRbp va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0)))))))))))))))))))))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_blocks va_b0 va_s0 alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5;
va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14;
va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12;
va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp;
va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx;
va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks va_mods alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks alg offset) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 283 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
let (h_LE:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.X64.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 0 va_s0)) in label va_range1
"***** POSTCONDITION NOT MET AT line 396 column 56 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 397 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 398 column 57 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 399 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 400 column 58 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet
6 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 403 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(plain_num_bytes < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 404 column 38 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRsi va_s0 < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 406 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 408 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (ctr_BE_1:quad32) = iv_BE in label va_range1
"***** POSTCONDITION NOT MET AT line 409 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in label va_range1
"***** POSTCONDITION NOT MET AT line 412 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (plain_in:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in label va_range1
"***** POSTCONDITION NOT MET AT line 421 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (cipher_out:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_sM) out128_b)) in label va_range1
"***** POSTCONDITION NOT MET AT line 430 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (cipher_bound:nat) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> len128x6 + len128 + 1) (fun _ -> len128x6 + len128) in label
va_range1
"***** POSTCONDITION NOT MET AT line 434 column 77 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg cipher_bound plain_in cipher_out key ctr_BE_2) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 438 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (length_quad:quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 0 0 0 0) (8 `op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply`
plain_num_bytes) 0) in label va_range1
"***** POSTCONDITION NOT MET AT line 440 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_auth_quads:(seq quad32)) = va_if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b)) (fun _ -> Vale.X64.Decls.s128 (va_get_mem_heaplet 1
va_s0) auth_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 444 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64 rRsi va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 445 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in label
va_range1
"***** POSTCONDITION NOT MET AT line 446 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes
in label va_range1
"***** POSTCONDITION NOT MET AT line 448 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 (FStar.Seq.Base.append #quad32
auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 452 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (total_bytes:nat) = FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 +
plain_num_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 453 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_quad_seq:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply`
128 `op_Division` 8) (fun _ -> let (ab:(seq nat8)) = FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32
raw_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let
(pb:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32
pb) (fun _ -> raw_quad_seq) in label va_range1
"***** POSTCONDITION NOT MET AT line 460 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 raw_quad_seq
(FStar.Seq.Base.create #quad32 1 length_quad) in label va_range1
"***** POSTCONDITION NOT MET AT line 461 column 106 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 8 va_sM == Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE
h_LE auth_quad_seq) alg key 0)))))))))))))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_blocks (alg:algorithm) (offset:int) (auth_b:buffer128) (abytes_b:buffer128)
(in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128) (out128_b:buffer128)
(inout_b:buffer128) (iv_b:buffer128) (scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
let (h_LE:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.X64.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 0 va_s0)) in sse_enabled /\
movbe_enabled /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0)
(va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet
1 va_s0) (va_get_reg64 rRdi va_s0) auth_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2
va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6
va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) in128_ptr in128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1
va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) inout_ptr inout_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0) hkeys_b 8
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)))) /\ (forall (va_x_mem:vale_heap)
(va_x_rax:nat64) (va_x_rbx:nat64) (va_x_rcx:nat64) (va_x_rdx:nat64) (va_x_rdi:nat64)
(va_x_rsi:nat64) (va_x_rbp:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64)
(va_x_r11:nat64) (va_x_r12:nat64) (va_x_r13:nat64) (va_x_r14:nat64) (va_x_r15:nat64)
(va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32)
(va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm9:quad32)
(va_x_xmm10:quad32) (va_x_xmm11:quad32) (va_x_xmm12:quad32) (va_x_xmm13:quad32)
(va_x_xmm14:quad32) (va_x_xmm15:quad32) (va_x_heap1:vale_heap) (va_x_heap2:vale_heap)
(va_x_heap3:vale_heap) (va_x_heap5:vale_heap) (va_x_heap6:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 6
va_x_heap6 (va_upd_mem_heaplet 5 va_x_heap5 (va_upd_mem_heaplet 3 va_x_heap3
(va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 15 va_x_xmm15
(va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12 (va_upd_xmm 11
va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (va_upd_xmm 8 va_x_xmm8
(va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4
(va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0
(va_upd_reg64 rR15 va_x_r15 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13
(va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10
(va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRbp va_x_rbp (va_upd_reg64
rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRcx
va_x_rcx (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem
va_s0))))))))))))))))))))))))))))))))))))) in va_get_ok va_sM /\ (let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet
1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b
(va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer128
scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) /\
Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32
/\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let
(ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in let
(plain_in:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in let (cipher_out:(seq quad32)) = va_if
(plain_num_bytes > (len128x6 + len128) `op_Multiply` 128 `op_Division` 8) (fun _ ->
FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_sM) out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM)
inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) in let (cipher_bound:nat) = va_if (plain_num_bytes > (len128x6 + len128)
`op_Multiply` 128 `op_Division` 8) (fun _ -> len128x6 + len128 + 1) (fun _ -> len128x6 +
len128) in Vale.AES.GCTR.gctr_partial alg cipher_bound plain_in cipher_out key ctr_BE_2 /\ (let
(length_quad:quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) (8
`op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply` plain_num_bytes) 0) in let
(raw_auth_quads:(seq quad32)) = va_if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b)) (fun _ -> Vale.X64.Decls.s128 (va_get_mem_heaplet 1
va_s0) auth_b) in let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64
rRsi va_s0) in let (padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits
auth_input_bytes in let (auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32
padded_auth_bytes in let (raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32
(FStar.Seq.Base.append #quad32 auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0)
in128x6_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in let (total_bytes:nat)
= FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 + plain_num_bytes in let
(raw_quad_seq:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> let (ab:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32 raw_quad_seq
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let (pb:(seq
nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32 pb) (fun
_ -> raw_quad_seq) in let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32
raw_quad_seq (FStar.Seq.Base.create #quad32 1 length_quad) in va_get_xmm 8 va_sM ==
Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE h_LE auth_quad_seq) alg
key 0))) ==> va_k va_sM (())))
val va_wpProof_Gcm_blocks : alg:algorithm -> offset:int -> auth_b:buffer128 -> abytes_b:buffer128
-> in128x6_b:buffer128 -> out128x6_b:buffer128 -> in128_b:buffer128 -> out128_b:buffer128 ->
inout_b:buffer128 -> iv_b:buffer128 -> scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq
quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit ->
Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b
in128_b out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks alg offset) ([va_Mod_flags;
va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2;
va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm
11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5;
va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15;
va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10;
va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi;
va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) va_s0
va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b
iv_b scratch_b key round_keys keys_b hkeys_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_blocks (va_code_Gcm_blocks alg offset) va_s0 alg offset auth_b
abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b scratch_b key round_keys keys_b
hkeys_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM
(va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm
13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm
9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM
(va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM
(va_update_reg64 rRbp va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))))))))))))))))))))))))))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_blocks (alg:algorithm) (offset:int) (auth_b:buffer128) (abytes_b:buffer128)
(in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128) (out128_b:buffer128)
(inout_b:buffer128) (iv_b:buffer128) (scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit (va_code_Gcm_blocks alg
offset)) =
(va_QProc (va_code_Gcm_blocks alg offset) ([va_Mod_flags; va_Mod_mem_heaplet 6;
va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1;
va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10;
va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm
3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64
rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64
rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64
rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_Gcm_blocks alg offset auth_b
abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b scratch_b key round_keys keys_b
hkeys_b) (va_wpProof_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b))
#pop-options
//--
//-- Gcm_blocks_wrapped
#push-options "--z3rlimit 60"
val va_code_Gcm_blocks_wrapped : alg:algorithm -> offset:int -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks_wrapped alg offset =
(va_Block (va_CCons (va_code_Gcm_blocks alg offset) (va_CCons (va_Block (va_CNil ())) (va_CCons
(va_Block (va_CNil ())) (va_CNil ())))))
val va_codegen_success_Gcm_blocks_wrapped : alg:algorithm -> offset:int -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks_wrapped alg offset =
(va_pbool_and (va_codegen_success_Gcm_blocks alg offset) (va_ttrue ()))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks_wrapped (va_mods:va_mods_t) (alg:algorithm) (offset:int) (auth_b:buffer128)
(abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128)
(out128_b:buffer128) (inout_b:buffer128) (iv_b:buffer128) (iv:supported_iv_LE)
(scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128)
(hkeys_b:buffer128) (expected_tag:(seq nat8)) : (va_quickCode unit (va_code_Gcm_blocks_wrapped
alg offset)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 0) (va_get_stack va_s) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 8) (va_get_stack va_s) in let
(out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 16) (va_get_stack va_s) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 24) (va_get_stack va_s) in let
(in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 32) (va_get_stack va_s) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 40) (va_get_stack va_s) in let
(len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset
+ 48) (va_get_stack va_s) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 56) (va_get_stack va_s) in let
(plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s
+ offset + 64) (va_get_stack va_s) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 739 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b
iv_b scratch_b key round_keys keys_b hkeys_b) (fun (va_s:va_state) _ -> va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 741 column 37 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(8 `op_Multiply` va_get_reg64 rRsi va_old_s >= 0 /\ 8 `op_Multiply` va_get_reg64 rRsi va_old_s
<= 18446744073709551615 /\ 8 `op_Multiply` plain_num_bytes >= 0 /\ 8 `op_Multiply`
plain_num_bytes <= 18446744073709551615) (fun _ -> let (va_arg55:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) (8
`op_Multiply` va_get_reg64 rRsi va_old_s) 1) (8 `op_Multiply` plain_num_bytes) 0) in let
(va_arg54:Vale.Def.Types_s.quad32) = va_get_xmm 8 va_s in let
(va_arg53:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.X64.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 0 va_s)) in let
(va_arg52:Vale.Def.Types_s.quad32) = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2
va_old_s) in let (va_arg51:Vale.AES.GCM_s.supported_iv_LE) = iv in let (va_arg50:Prims.nat) =
va_get_reg64 rRsi va_old_s in let (va_arg49:Prims.nat) = plain_num_bytes in let
(va_arg48:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s) inout_b in let (va_arg47:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b in let
(va_arg46:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s) out128x6_b in let (va_arg45:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b in let
(va_arg44:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) in128_b in let (va_arg43:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b in
let (va_arg42:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_old_s) abytes_b in let (va_arg41:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) auth_b in let
(va_arg40:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = key in let
(va_arg39:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 741 column 37 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCM.gcm_blocks_dec_helper_simplified va_arg39 va_arg40 va_arg41
va_arg42 va_arg43 va_arg44 va_arg45 va_arg46 va_arg47 va_arg48 va_arg49 va_arg50 va_arg51
va_arg52 va_arg53 va_arg54 va_arg55) (let (auth_raw_quads:(FStar.Seq.Base.seq
Vale.X64.Decls.quad32)) = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) auth_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_old_s)
abytes_b) in va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 751 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun a_1906 (s_1907:(FStar.Seq.Base.seq a_1906)) (i_1908:Prims.nat) (j_1909:Prims.nat) -> let
(j_1869:Prims.nat) = j_1909 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1908
j_1869) (Prims.op_LessThanOrEqual j_1869 (FStar.Seq.Base.length #a_1906 s_1907))))
Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0 (va_get_reg64
rRsi va_old_s)) (fun _ -> let (auth_bytes:(FStar.Seq.Base.seq Vale.Def.Types_s.nat8)) =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
auth_raw_quads) 0 (va_get_reg64 rRsi va_old_s) in let (va_arg38:Vale.Def.Types_s.quad32) =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_old_s) in let
(va_arg37:Vale.AES.GCM_s.supported_iv_LE) = iv in let (va_arg36:Prims.nat) = plain_num_bytes in
let (va_arg35:(FStar.Seq.Base.seq Vale.Def.Words_s.nat8)) = expected_tag in let
(va_arg34:(FStar.Seq.Base.seq Vale.Def.Words_s.nat8)) = auth_bytes in let
(va_arg33:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s) inout_b in let (va_arg32:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b in let
(va_arg31:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s) out128x6_b in let (va_arg30:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b in let
(va_arg29:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) in128_b in let (va_arg28:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b in
let (va_arg27:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = key in let
(va_arg26:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 752 column 37 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCM.gcm_blocks_helper_dec_simplified va_arg26 va_arg27 va_arg28
va_arg29 va_arg30 va_arg31 va_arg32 va_arg33 va_arg34 va_arg35 va_arg36 va_arg37 va_arg38)
(va_QEmpty (()))))))))
val va_lemma_Gcm_blocks_wrapped : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> offset:int ->
auth_b:buffer128 -> abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 ->
in128_b:buffer128 -> out128_b:buffer128 -> inout_b:buffer128 -> iv_b:buffer128 ->
iv:supported_iv_LE -> scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) ->
keys_b:buffer128 -> hkeys_b:buffer128 -> expected_tag:(seq nat8)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks_wrapped alg offset) va_s0 /\ va_get_ok
va_s0 /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in sse_enabled /\ movbe_enabled /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp
va_s0 + offset + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet
1 va_s0) (va_get_reg64 rRdi va_s0) auth_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2
va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6
va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) in128_ptr in128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1
va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) inout_ptr inout_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0) hkeys_b 8
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\ (let iv_BE =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let h_LE =
Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
in iv_BE == Vale.AES.GCM_s.compute_iv_BE h_LE iv))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in Vale.X64.Decls.modifies_buffer128 out128_b
(va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128
iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\
Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM) /\ Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0)
(va_get_mem_heaplet 5 va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b
(va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\
va_get_reg64 rRsi va_s0 < pow2_32 /\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0
(va_get_mem_heaplet 2 va_s0) in let auth_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_s0) abytes_b) in let auth_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
auth_raw_quads) 0 (va_get_reg64 rRsi va_s0) in let plain_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0)
in128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) in let plain_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
plain_raw_quads) 0 plain_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) in let cipher_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
cipher_raw_quads) 0 plain_num_bytes in l_and (l_and (l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.nat8 auth_bytes < pow2_32) (FStar.Seq.Base.length #Vale.Def.Types_s.nat8
plain_bytes < pow2_32)) (cipher_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq
Vale.Def.Types_s.nat8) #bool (Vale.AES.GCM_s.gcm_decrypt_LE alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes expected_tag)))
(Vale.Def.Types_s.le_quad32_to_bytes (va_get_xmm 8 va_sM) == Vale.AES.GCM.gcm_decrypt_LE_tag
alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM (va_update_mem_heaplet
5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 1
va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12
va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm 9 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM
(va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM
(va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRbp va_sM
(va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRdx va_sM
(va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_blocks_wrapped va_b0 va_s0 alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b expected_tag =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5;
va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14;
va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12;
va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp;
va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx;
va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks_wrapped va_mods alg offset auth_b abytes_b in128x6_b out128x6_b
in128_b out128_b inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b expected_tag in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks_wrapped alg offset) va_qc
va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 588 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 711 column 56 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 712 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 713 column 57 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 714 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 715 column 58 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet
6 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 718 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(plain_num_bytes < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 719 column 38 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRsi va_s0 < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 721 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 723 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let auth_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_s0)
abytes_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 724 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let auth_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0 (va_get_reg64 rRsi va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 725 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let plain_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 726 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let plain_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads) 0 plain_num_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 727 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let cipher_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 728 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let cipher_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads) 0 plain_num_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 737 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(l_and (l_and (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 auth_bytes < pow2_32)
(FStar.Seq.Base.length #Vale.Def.Types_s.nat8 plain_bytes < pow2_32)) (cipher_bytes ==
__proj__Mktuple2__item___1 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv
plain_bytes auth_bytes expected_tag))) (Vale.Def.Types_s.le_quad32_to_bytes (va_get_xmm 8
va_sM) == Vale.AES.GCM.gcm_decrypt_LE_tag alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE
key) iv plain_bytes auth_bytes))))))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Stack.fsti.checked",
"Vale.X64.QuickCodes.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.InsVector.fsti.checked",
"Vale.X64.InsStack.fsti.checked",
"Vale.X64.InsMem.fsti.checked",
"Vale.X64.InsBasic.fsti.checked",
"Vale.X64.InsAes.fsti.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Lib.Meta.fsti.checked",
"Vale.Lib.Basic.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_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",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.X64.GHash.fsti.checked",
"Vale.AES.X64.GF128_Mul.fsti.checked",
"Vale.AES.X64.GCTR.fsti.checked",
"Vale.AES.X64.GCMencryptOpt.fsti.checked",
"Vale.AES.X64.AESopt2.fsti.checked",
"Vale.AES.X64.AESopt.fsti.checked",
"Vale.AES.X64.AESGCM.fsti.checked",
"Vale.AES.X64.AES.fsti.checked",
"Vale.AES.OptPublic.fsti.checked",
"Vale.AES.GHash_s.fst.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_s.fst.checked",
"Vale.AES.GCTR.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"Vale.AES.GCM.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_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.X64.GCMdecryptOpt.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Lib.Basic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"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.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_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": "Vale.Def.Types_s",
"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": "FStar.Seq",
"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.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"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.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_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": "Vale.Def.Types_s",
"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": "FStar.Seq",
"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.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 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": 60,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
alg: Vale.AES.AES_common_s.algorithm ->
offset: Prims.int ->
auth_b: Vale.X64.Memory.buffer128 ->
abytes_b: Vale.X64.Memory.buffer128 ->
in128x6_b: Vale.X64.Memory.buffer128 ->
out128x6_b: Vale.X64.Memory.buffer128 ->
in128_b: Vale.X64.Memory.buffer128 ->
out128_b: Vale.X64.Memory.buffer128 ->
inout_b: Vale.X64.Memory.buffer128 ->
iv_b: Vale.X64.Memory.buffer128 ->
iv: Vale.AES.GCM_s.supported_iv_LE ->
scratch_b: Vale.X64.Memory.buffer128 ->
key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 ->
round_keys: FStar.Seq.Base.seq Vale.X64.Decls.quad32 ->
keys_b: Vale.X64.Memory.buffer128 ->
hkeys_b: Vale.X64.Memory.buffer128 ->
expected_tag: FStar.Seq.Base.seq Vale.X64.Memory.nat8 ->
va_s0: Vale.X64.Decls.va_state ->
va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.AES.AES_common_s.algorithm",
"Prims.int",
"Vale.X64.Memory.buffer128",
"Vale.AES.GCM_s.supported_iv_LE",
"FStar.Seq.Base.seq",
"Vale.X64.Memory.nat32",
"Vale.X64.Decls.quad32",
"Vale.X64.Memory.nat8",
"Vale.X64.Decls.va_state",
"Prims.unit",
"Prims.l_and",
"Prims.b2t",
"Vale.X64.Decls.va_get_ok",
"Vale.X64.CPU_Features_s.sse_enabled",
"Vale.X64.CPU_Features_s.movbe_enabled",
"Vale.X64.Stack_i.valid_stack_slot64",
"Prims.op_Addition",
"Vale.X64.Decls.va_get_reg64",
"Vale.X64.Machine_s.rRsp",
"Vale.X64.Decls.va_get_stack",
"Vale.Arch.HeapTypes_s.Public",
"Vale.X64.Decls.va_get_stackTaint",
"Vale.X64.Decls.validSrcAddrs128",
"Vale.X64.Decls.va_get_mem_heaplet",
"Vale.X64.Machine_s.rRdi",
"Vale.X64.Machine_s.rRdx",
"Vale.X64.Decls.va_get_mem_layout",
"Vale.Arch.HeapTypes_s.Secret",
"Vale.X64.Decls.validDstAddrs128",
"Vale.X64.Machine_s.rR8",
"Vale.X64.Machine_s.rRbp",
"Vale.X64.Machine_s.rR9",
"Vale.X64.Decls.buffer_disjoints128",
"Prims.Cons",
"Prims.Nil",
"Prims.l_or",
"Vale.X64.Decls.buffers_disjoint128",
"Prims.eq2",
"Prims.op_LessThan",
"Prims.op_Multiply",
"Vale.X64.Machine_s.pow2_64",
"Prims.nat",
"Vale.X64.Decls.buffer_length",
"Vale.X64.Memory.vuint128",
"Vale.X64.Machine_s.pow2_32",
"Vale.X64.Machine_s.rRsi",
"Vale.X64.Memory.buffer_addr",
"Prims.op_Modulus",
"Prims.l_imp",
"Prims.op_GreaterThan",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThanOrEqual",
"Vale.X64.Decls.va_mul_nat",
"Prims.op_Division",
"Vale.AES.X64.GCMencryptOpt.aes_reqs",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.CPU_Features_s.pclmulqdq_enabled",
"Vale.AES.GHash.hkeys_reqs_priv",
"Vale.X64.Decls.s128",
"Vale.Def.Types_s.reverse_bytes_quad32",
"Vale.AES.AES_s.aes_encrypt_LE",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Vale.Def.Types_s.quad32",
"Vale.AES.GCM_s.compute_iv_BE",
"Vale.X64.Decls.buffer128_read",
"Vale.Def.Words_s.nat64",
"Vale.X64.Stack_i.load_stack64",
"Prims.l_Forall",
"Vale.X64.InsBasic.vale_heap",
"Vale.X64.Memory.nat64",
"Vale.X64.Flags.t",
"Vale.X64.Decls.modifies_buffer128",
"FStar.Seq.Base.length",
"Vale.Def.Types_s.nat8",
"FStar.Pervasives.Native.__proj__Mktuple2__item___1",
"Prims.bool",
"Vale.AES.GCM_s.gcm_decrypt_LE",
"Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE",
"Vale.Def.Words_s.nat8",
"Vale.Def.Types_s.le_quad32_to_bytes",
"Vale.X64.Decls.va_get_xmm",
"Vale.AES.GCM.gcm_decrypt_LE_tag",
"FStar.Seq.Base.slice",
"Vale.Def.Types_s.le_seq_quad32_to_bytes",
"FStar.Seq.Base.append",
"Vale.X64.State.vale_state",
"Vale.X64.Decls.va_upd_flags",
"Vale.X64.Decls.va_upd_mem_heaplet",
"Vale.X64.Decls.va_upd_xmm",
"Vale.X64.Decls.va_upd_reg64",
"Vale.X64.Machine_s.rR15",
"Vale.X64.Machine_s.rR14",
"Vale.X64.Machine_s.rR13",
"Vale.X64.Machine_s.rR12",
"Vale.X64.Machine_s.rR11",
"Vale.X64.Machine_s.rR10",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.Machine_s.rRax",
"Vale.X64.Decls.va_upd_mem"
] | [] | false | false | false | true | true | let va_wp_Gcm_blocks_wrapped
(alg: algorithm)
(offset: int)
(auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b: buffer128)
(iv: supported_iv_LE)
(scratch_b: buffer128)
(key: (seq nat32))
(round_keys: (seq quad32))
(keys_b hkeys_b: buffer128)
(expected_tag: (seq nat8))
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 =
| (va_get_ok va_s0 /\
(let abytes_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0)
in
let in128x6_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0)
in
let out128x6_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0)
in
let len128x6:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0)
in
let in128_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0)
in
let out128_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0)
in
let len128:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0)
in
let inout_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0)
in
let plain_num_bytes:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0)
in
sse_enabled /\ movbe_enabled /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 8)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 24)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 40)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 56)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0) /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg64 rRdi va_s0)
auth_b
(va_get_reg64 rRdx va_s0)
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0)
abytes_ptr
abytes_b
1
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0)
(va_get_reg64 rR8 va_s0)
iv_b
1
(va_get_mem_layout va_s0)
Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0)
in128x6_ptr
in128x6_b
len128x6
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6 va_s0)
out128x6_ptr
out128x6_b
len128x6
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0)
in128_ptr
in128_b
len128
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0)
out128_ptr
out128_b
len128
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0)
inout_ptr
inout_b
1
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3 va_s0)
(va_get_reg64 rRbp va_s0)
scratch_b
9
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0)
(va_get_reg64 rR9 va_s0)
hkeys_b
8
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.buffer_disjoints128 iv_b
([keys_b; scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b
([keys_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; hkeys_b]) /\
Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b; hkeys_b; in128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b; out128x6_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b; out128x6_b; out128_b]) /\
(Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b == out128x6_b) /\
(Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b) /\
va_get_reg64 rRdi va_s0 + 16 `op_Multiply` (va_get_reg64 rRdx va_s0) < pow2_64 /\
in128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64 /\
inout_ptr + 16 < pow2_64 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b == va_get_reg64 rRdx va_s0 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b == len128x6 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == len128 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\ plain_num_bytes < pow2_32 /\
va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 < pow2_64 /\
Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0 va_s0) + 128 <
pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\
(va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) <=
plain_num_bytes /\
plain_num_bytes <
va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) +
128
`op_Division`
8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 <
va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128 `op_Division` 8) /\
aes_reqs alg
key
round_keys
keys_b
(va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0)
(va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg
key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\
(let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in
let h_LE =
Vale.AES.AES_s.aes_encrypt_LE alg
key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
in
iv_BE == Vale.AES.GCM_s.compute_iv_BE h_LE iv)) /\
(forall (va_x_mem: vale_heap) (va_x_rax: nat64) (va_x_rbx: nat64) (va_x_rcx: nat64)
(va_x_rdx: nat64) (va_x_rdi: nat64) (va_x_rsi: nat64) (va_x_rbp: nat64) (va_x_r8: nat64)
(va_x_r9: nat64) (va_x_r10: nat64) (va_x_r11: nat64) (va_x_r12: nat64) (va_x_r13: nat64)
(va_x_r14: nat64) (va_x_r15: nat64) (va_x_xmm0: quad32) (va_x_xmm1: quad32)
(va_x_xmm2: quad32) (va_x_xmm3: quad32) (va_x_xmm4: quad32) (va_x_xmm5: quad32)
(va_x_xmm6: quad32) (va_x_xmm7: quad32) (va_x_xmm8: quad32) (va_x_xmm9: quad32)
(va_x_xmm10: quad32) (va_x_xmm11: quad32) (va_x_xmm12: quad32) (va_x_xmm13: quad32)
(va_x_xmm14: quad32) (va_x_xmm15: quad32) (va_x_heap1: vale_heap) (va_x_heap2: vale_heap)
(va_x_heap3: vale_heap) (va_x_heap5: vale_heap) (va_x_heap6: vale_heap)
(va_x_efl: Vale.X64.Flags.t).
let va_sM =
va_upd_flags va_x_efl
(va_upd_mem_heaplet 6
va_x_heap6
(va_upd_mem_heaplet 5
va_x_heap5
(va_upd_mem_heaplet 3
va_x_heap3
(va_upd_mem_heaplet 2
va_x_heap2
(va_upd_mem_heaplet 1
va_x_heap1
(va_upd_xmm 15
va_x_xmm15
(va_upd_xmm 14
va_x_xmm14
(va_upd_xmm 13
va_x_xmm13
(va_upd_xmm 12
va_x_xmm12
(va_upd_xmm 11
va_x_xmm11
(va_upd_xmm 10
va_x_xmm10
(va_upd_xmm 9
va_x_xmm9
(va_upd_xmm 8
va_x_xmm8
(va_upd_xmm 7
va_x_xmm7
(va_upd_xmm 6
va_x_xmm6
(va_upd_xmm 5
va_x_xmm5
(va_upd_xmm 4
va_x_xmm4
(va_upd_xmm 3
va_x_xmm3
(va_upd_xmm 2
va_x_xmm2
(va_upd_xmm 1
va_x_xmm1
(va_upd_xmm
0
va_x_xmm0
(va_upd_reg64
rR15
va_x_r15
(va_upd_reg64
rR14
va_x_r14
(
va_upd_reg64
rR13
va_x_r13
(
va_upd_reg64
rR12
va_x_r12
(
va_upd_reg64
rR11
va_x_r11
(
va_upd_reg64
rR10
va_x_r10
(
va_upd_reg64
rR9
va_x_r9
(
va_upd_reg64
rR8
va_x_r8
(
va_upd_reg64
rRbp
va_x_rbp
(
va_upd_reg64
rRsi
va_x_rsi
(
va_upd_reg64
rRdi
va_x_rdi
(
va_upd_reg64
rRdx
va_x_rdx
(
va_upd_reg64
rRcx
va_x_rcx
(
va_upd_reg64
rRbx
va_x_rbx
(
va_upd_reg64
rRax
va_x_rax
(
va_upd_mem
va_x_mem
va_s0
)
)
)
)
)
)
)
)
)
)
)
)
)
)
))
))))))))))
)))))))))))
in
va_get_ok va_sM /\
(let abytes_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0)
in
let in128x6_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0)
in
let out128x6_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0)
in
let len128x6:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0)
in
let in128_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0)
in
let out128_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0)
in
let len128:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0)
in
let inout_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0)
in
let plain_num_bytes:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0)
in
Vale.X64.Decls.modifies_buffer128 out128_b
(va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM) /\
Vale.X64.Decls.modifies_buffer128 iv_b
(va_get_mem_heaplet 2 va_s0)
(va_get_mem_heaplet 2 va_sM) /\
Vale.X64.Decls.modifies_buffer128 scratch_b
(va_get_mem_heaplet 3 va_s0)
(va_get_mem_heaplet 3 va_sM) /\
Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0)
(va_get_mem_heaplet 5 va_sM) /\
Vale.X64.Decls.modifies_buffer128 out128x6_b
(va_get_mem_heaplet 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\
va_get_reg64 rRsi va_s0 < pow2_32 /\
(let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in
let auth_raw_quads =
FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_s0) abytes_b)
in
let auth_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads)
0
(va_get_reg64 rRsi va_s0)
in
let plain_raw_quads =
FStar.Seq.Base.append #Vale.X64.Decls.quad32
(FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b)
in
let plain_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads)
0
plain_num_bytes
in
let cipher_raw_quads =
FStar.Seq.Base.append #Vale.X64.Decls.quad32
(FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b)
in
let cipher_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads)
0
plain_num_bytes
in
l_and (l_and (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 auth_bytes < pow2_32)
(FStar.Seq.Base.length #Vale.Def.Types_s.nat8 plain_bytes < pow2_32))
(cipher_bytes ==
__proj__Mktuple2__item___1 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8)
#bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key)
iv
plain_bytes
auth_bytes
expected_tag)))
(Vale.Def.Types_s.le_quad32_to_bytes (va_get_xmm 8 va_sM) ==
Vale.AES.GCM.gcm_decrypt_LE_tag alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key)
iv
plain_bytes
auth_bytes))) ==>
va_k va_sM (()))) | false |
AlgHeap.fst | AlgHeap.sublist_at | val sublist_at (l1 l2: ops)
: Lemma (sublist l1 (l1 @ l2) /\ sublist l2 (l1 @ l2))
[SMTPatOr [[SMTPat (sublist l1 (l1 @ l2))]; [SMTPat (sublist l2 (l1 @ l2))]]] | val sublist_at (l1 l2: ops)
: Lemma (sublist l1 (l1 @ l2) /\ sublist l2 (l1 @ l2))
[SMTPatOr [[SMTPat (sublist l1 (l1 @ l2))]; [SMTPat (sublist l2 (l1 @ l2))]]] | let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2 | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 31,
"end_line": 76,
"start_col": 0,
"start_line": 69
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l1: AlgHeap.ops -> l2: AlgHeap.ops
-> FStar.Pervasives.Lemma (ensures AlgHeap.sublist l1 (l1 @ l2) /\ AlgHeap.sublist l2 (l1 @ l2))
[SMTPatOr [[SMTPat (AlgHeap.sublist l1 (l1 @ l2))]; [SMTPat (AlgHeap.sublist l2 (l1 @ l2))]]] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"AlgHeap.ops",
"AlgHeap.op",
"Prims.list",
"AlgHeap.sublist_at",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.l_and",
"AlgHeap.sublist",
"FStar.List.Tot.Base.op_At",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat_or",
"FStar.Pervasives.smt_pat",
"Prims.logical",
"Prims.Nil"
] | [
"recursion"
] | false | false | true | false | false | let rec sublist_at (l1 l2: ops)
: Lemma (sublist l1 (l1 @ l2) /\ sublist l2 (l1 @ l2))
[SMTPatOr [[SMTPat (sublist l1 (l1 @ l2))]; [SMTPat (sublist l2 (l1 @ l2))]]] =
| match l1 with
| [] -> ()
| _ :: l1 -> sublist_at l1 l2 | false |
AlgHeap.fst | AlgHeap.abides_app | val abides_app (#a: _) (l1 l2: ops) (c: tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1 @ l2) c))
[SMTPat (abides (l1 @ l2) c)] | val abides_app (#a: _) (l1 l2: ops) (c: tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1 @ l2) c))
[SMTPat (abides (l1 @ l2) c)] | let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2 | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 20,
"end_line": 114,
"start_col": 0,
"start_line": 110
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l1: AlgHeap.ops -> l2: AlgHeap.ops -> c: AlgHeap.tree0 a
-> FStar.Pervasives.Lemma (requires AlgHeap.abides l1 c \/ AlgHeap.abides l2 c)
(ensures AlgHeap.abides (l1 @ l2) c)
[SMTPat (AlgHeap.abides (l1 @ l2) c)] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"AlgHeap.ops",
"AlgHeap.tree0",
"AlgHeap.sublist_at",
"Prims.unit",
"Prims.l_or",
"AlgHeap.abides",
"Prims.squash",
"FStar.List.Tot.Base.op_At",
"AlgHeap.op",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.prop",
"Prims.Nil"
] | [] | true | false | true | false | false | let abides_app #a (l1: ops) (l2: ops) (c: tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1 @ l2) c))
[SMTPat (abides (l1 @ l2) c)] =
| sublist_at l1 l2 | false |
AlgHeap.fst | AlgHeap.interp_at | val interp_at (l1 l2: ops) (l: op)
: Lemma (mem l (l1 @ l2) == (mem l l1 || mem l l2)) [SMTPat (mem l (l1 @ l2))] | val interp_at (l1 l2: ops) (l: op)
: Lemma (mem l (l1 @ l2) == (mem l l1 || mem l l2)) [SMTPat (mem l (l1 @ l2))] | let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 32,
"end_line": 65,
"start_col": 0,
"start_line": 60
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l1: AlgHeap.ops -> l2: AlgHeap.ops -> l: AlgHeap.op
-> FStar.Pervasives.Lemma
(ensures
FStar.List.Tot.Base.mem l (l1 @ l2) ==
(FStar.List.Tot.Base.mem l l1 || FStar.List.Tot.Base.mem l l2))
[SMTPat (FStar.List.Tot.Base.mem l (l1 @ l2))] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"AlgHeap.ops",
"AlgHeap.op",
"Prims.list",
"AlgHeap.interp_at",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"Prims.bool",
"FStar.List.Tot.Base.mem",
"FStar.List.Tot.Base.op_At",
"Prims.op_BarBar",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil"
] | [
"recursion"
] | false | false | true | false | false | let rec interp_at (l1 l2: ops) (l: op)
: Lemma (mem l (l1 @ l2) == (mem l l1 || mem l l2)) [SMTPat (mem l (l1 @ l2))] =
| match l1 with
| [] -> ()
| _ :: l1 -> interp_at l1 l2 l | false |
Hacl.Bignum.ModInv.fst | Hacl.Bignum.ModInv.bn_mod_inv_prime_precomp_st | val bn_mod_inv_prime_precomp_st : t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0 | let bn_mod_inv_prime_precomp_st (t:limb_t) (len:BN.meta_len t) =
n:lbignum t len
-> mu:limb t
-> r2:lbignum t len
-> a:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h r2 /\ live h a /\ live h res /\
disjoint res n /\ disjoint res a /\ disjoint n a /\
disjoint res r2 /\ disjoint a r2 /\ disjoint n r2 /\
S.bn_mod_inv_prime_pre (as_seq h n) (as_seq h a) /\
bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n /\
(1 + bn_v h n * v mu) % pow2 (bits t) == 0)
(ensures fun h0 r h1 -> modifies (loc res) h0 h1 /\
bn_v h1 res * bn_v h0 a % bn_v h0 n = 1) | {
"file_name": "code/bignum/Hacl.Bignum.ModInv.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 44,
"end_line": 76,
"start_col": 0,
"start_line": 60
} | module Hacl.Bignum.ModInv
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
module ST = FStar.HyperStack.ST
module S = Hacl.Spec.Bignum.ModInv
module BN = Hacl.Bignum
module BE = Hacl.Bignum.Exponentiation
module BM = Hacl.Bignum.Montgomery
module SD = Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let bn_check_mod_inv_prime_st (t:limb_t) (len:BN.meta_len t) =
n:lbignum t len
-> a:lbignum t len ->
Stack (limb t)
(requires fun h -> live h n /\ live h a /\ disjoint n a)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.bn_check_mod_inv_prime (as_seq h0 n) (as_seq h0 a))
inline_for_extraction noextract
val bn_check_mod_inv_prime: #t:limb_t -> len:BN.meta_len t -> bn_check_mod_inv_prime_st t len
let bn_check_mod_inv_prime #t len n a =
let m0 = BM.bn_check_modulus n in
let m1 = BN.bn_is_zero_mask len a in
let m2 = BN.bn_lt_mask len a n in
m0 &. (lognot m1) &. m2
inline_for_extraction noextract
val bn_mod_inv_prime_n2:
#t:limb_t
-> len:BN.meta_len t
-> n:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h -> 1 < bn_v h n /\
live h n /\ live h res /\ disjoint res n)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mod_inv_prime_n2 (as_seq h0 n))
let bn_mod_inv_prime_n2 #t len n res =
let c = BN.bn_sub1 len n (uint #t #SEC 2) res in
LowStar.Ignore.ignore c;
() | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.ModInv.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.ModInv.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.ModInv",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.meta_len",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Bignum.Definitions.limb",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Lib.Buffer.disjoint",
"Hacl.Spec.Bignum.ModInv.bn_mod_inv_prime_pre",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.as_seq",
"Prims.eq2",
"Prims.int",
"Hacl.Bignum.Definitions.bn_v",
"Prims.op_Modulus",
"Prims.pow2",
"FStar.Mul.op_Star",
"Lib.IntTypes.bits",
"Prims.op_Addition",
"Lib.IntTypes.SEC",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.b2t",
"Prims.op_Equality"
] | [] | false | false | false | false | true | let bn_mod_inv_prime_precomp_st (t: limb_t) (len: BN.meta_len t) =
| n: lbignum t len -> mu: limb t -> r2: lbignum t len -> a: lbignum t len -> res: lbignum t len
-> Stack unit
(requires
fun h ->
live h n /\ live h r2 /\ live h a /\ live h res /\ disjoint res n /\ disjoint res a /\
disjoint n a /\ disjoint res r2 /\ disjoint a r2 /\ disjoint n r2 /\
S.bn_mod_inv_prime_pre (as_seq h n) (as_seq h a) /\
bn_v h r2 == pow2 ((2 * bits t) * v len) % bn_v h n /\
(1 + bn_v h n * v mu) % pow2 (bits t) == 0)
(ensures fun h0 r h1 -> modifies (loc res) h0 h1 /\ bn_v h1 res * bn_v h0 a % bn_v h0 n = 1) | false |
|
AlgHeap.fst | AlgHeap.abides_at_self | val abides_at_self (#a: _) (l: ops) (c: tree0 a)
: Lemma (abides (l @ l) c <==> abides l c) [SMTPat (abides (l @ l) c)] | val abides_at_self (#a: _) (l: ops) (c: tree0 a)
: Lemma (abides (l @ l) c <==> abides l c) [SMTPat (abides (l @ l) c)] | let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l) | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 28,
"end_line": 108,
"start_col": 0,
"start_line": 101
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l: AlgHeap.ops -> c: AlgHeap.tree0 a
-> FStar.Pervasives.Lemma (ensures AlgHeap.abides (l @ l) c <==> AlgHeap.abides l c)
[SMTPat (AlgHeap.abides (l @ l) c)] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"AlgHeap.ops",
"AlgHeap.tree0",
"Prims._assert",
"AlgHeap.sublist",
"FStar.List.Tot.Base.op_At",
"AlgHeap.op",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.l_iff",
"AlgHeap.abides",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.prop",
"Prims.Nil"
] | [] | true | false | true | false | false | let abides_at_self #a (l: ops) (c: tree0 a)
: Lemma (abides (l @ l) c <==> abides l c) [SMTPat (abides (l @ l) c)] =
| assert (sublist l (l @ l));
assert (sublist (l @ l) l) | false |
AlgHeap.fst | AlgHeap.return | val return (a: Type) (x: a) : tree a [] | val return (a: Type) (x: a) : tree a [] | let return (a:Type) (x:a)
: tree a []
= Return x | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 12,
"end_line": 148,
"start_col": 0,
"start_line": 146
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Type -> x: a -> AlgHeap.tree a [] | Prims.Tot | [
"total"
] | [] | [
"AlgHeap.Return",
"AlgHeap.tree",
"Prims.Nil",
"AlgHeap.op"
] | [] | false | false | false | true | false | let return (a: Type) (x: a) : tree a [] =
| Return x | false |
AlgHeap.fst | AlgHeap.abides_sublist_nopat | val abides_sublist_nopat (#a: _) (l1 l2: ops) (c: tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2) (ensures (abides l2) c) | val abides_sublist_nopat (#a: _) (l1 l2: ops) (c: tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2) (ensures (abides l2) c) | let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 32,
"end_line": 93,
"start_col": 0,
"start_line": 84
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l1: AlgHeap.ops -> l2: AlgHeap.ops -> c: AlgHeap.tree0 a
-> FStar.Pervasives.Lemma (requires AlgHeap.abides l1 c /\ AlgHeap.sublist l1 l2)
(ensures AlgHeap.abides l2 c) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"AlgHeap.ops",
"AlgHeap.tree0",
"AlgHeap.op",
"AlgHeap.op_inp",
"AlgHeap.op_out",
"FStar.Classical.forall_intro",
"AlgHeap.abides",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"AlgHeap.abides_sublist_nopat",
"Prims.l_and",
"AlgHeap.sublist"
] | [
"recursion"
] | false | false | true | false | false | let rec abides_sublist_nopat #a (l1: ops) (l2: ops) (c: tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2) (ensures (abides l2) c) =
| match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) = abides_sublist_nopat l1 l2 (k o) in
Classical.forall_intro sub | false |
Hacl.Bignum.ModInv.fst | Hacl.Bignum.ModInv.bn_mod_inv_prime_n2 | val bn_mod_inv_prime_n2:
#t:limb_t
-> len:BN.meta_len t
-> n:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h -> 1 < bn_v h n /\
live h n /\ live h res /\ disjoint res n)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mod_inv_prime_n2 (as_seq h0 n)) | val bn_mod_inv_prime_n2:
#t:limb_t
-> len:BN.meta_len t
-> n:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h -> 1 < bn_v h n /\
live h n /\ live h res /\ disjoint res n)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mod_inv_prime_n2 (as_seq h0 n)) | let bn_mod_inv_prime_n2 #t len n res =
let c = BN.bn_sub1 len n (uint #t #SEC 2) res in
LowStar.Ignore.ignore c;
() | {
"file_name": "code/bignum/Hacl.Bignum.ModInv.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 4,
"end_line": 56,
"start_col": 0,
"start_line": 53
} | module Hacl.Bignum.ModInv
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
module ST = FStar.HyperStack.ST
module S = Hacl.Spec.Bignum.ModInv
module BN = Hacl.Bignum
module BE = Hacl.Bignum.Exponentiation
module BM = Hacl.Bignum.Montgomery
module SD = Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let bn_check_mod_inv_prime_st (t:limb_t) (len:BN.meta_len t) =
n:lbignum t len
-> a:lbignum t len ->
Stack (limb t)
(requires fun h -> live h n /\ live h a /\ disjoint n a)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.bn_check_mod_inv_prime (as_seq h0 n) (as_seq h0 a))
inline_for_extraction noextract
val bn_check_mod_inv_prime: #t:limb_t -> len:BN.meta_len t -> bn_check_mod_inv_prime_st t len
let bn_check_mod_inv_prime #t len n a =
let m0 = BM.bn_check_modulus n in
let m1 = BN.bn_is_zero_mask len a in
let m2 = BN.bn_lt_mask len a n in
m0 &. (lognot m1) &. m2
inline_for_extraction noextract
val bn_mod_inv_prime_n2:
#t:limb_t
-> len:BN.meta_len t
-> n:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h -> 1 < bn_v h n /\
live h n /\ live h res /\ disjoint res n)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mod_inv_prime_n2 (as_seq h0 n)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.ModInv.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.ModInv.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.ModInv",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
len: Hacl.Bignum.meta_len t ->
n: Hacl.Bignum.Definitions.lbignum t len ->
res: Hacl.Bignum.Definitions.lbignum t len
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.meta_len",
"Hacl.Bignum.Definitions.lbignum",
"Prims.unit",
"LowStar.Ignore.ignore",
"Hacl.Spec.Bignum.Base.carry",
"Hacl.Bignum.bn_sub1",
"Lib.IntTypes.uint",
"Lib.IntTypes.SEC"
] | [] | false | true | false | false | false | let bn_mod_inv_prime_n2 #t len n res =
| let c = BN.bn_sub1 len n (uint #t #SEC 2) res in
LowStar.Ignore.ignore c;
() | false |
AlgHeap.fst | AlgHeap.wp_is_monotonic | val wp_is_monotonic (#a: _) (wp: st_wp a) : Type0 | val wp_is_monotonic (#a: _) (wp: st_wp a) : Type0 | let wp_is_monotonic #a (wp : st_wp a) : Type0 =
forall p1 p2 s0. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> wp s0 p1 ==> wp s0 p2 | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 85,
"end_line": 270,
"start_col": 0,
"start_line": 269
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0)
unfold
let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p)
unfold
let read_wp : st_wp state = fun s0 p -> p (s0, s0)
unfold
let write_wp : state -> st_wp unit = fun s _ p -> p ((), s)
(* Also doable with handlers *)
let rec interp_as_wp #a (t : rwtree a) : st_wp a =
match t with
| Return x -> return_wp x
| Op Read _ k ->
bind_wp read_wp (fun s -> interp_as_wp (k s))
| Op Write s k ->
bind_wp (write_wp s) (fun (o:unit) -> interp_as_wp (k o))
let rec interp_rdwr_tree #a (t : tree a [Read;Write]) (s:state) : Tot (a & state) =
match t with
| Return x -> (x, s)
| Op Read _ k ->
interp_rdwr_tree (k s) s
| Op Write s k ->
interp_rdwr_tree (k ()) s
let interp_as_fun #a (t : rwtree a) : (state -> a & state) =
interp_rdwr_tree t
(* Bug: defining this as a FStar.Preorder.preorder
causes stupid failures ahead *)
val stronger : (#a:Type) -> st_wp a -> st_wp a -> Type0
let stronger w1 w2 = forall p s. w1 p s ==> w2 p s
let equiv #a (w1 w2 : st_wp a) = w1 `stronger` w2 /\ w2 `stronger` w1
let (<<=) = stronger
val interp_ret (#a:Type) (x:a) : Lemma (return_wp x `stronger` interp_as_wp (Return x))
let interp_ret x = () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | wp: AlgHeap.st_wp a -> Type0 | Prims.Tot | [
"total"
] | [] | [
"AlgHeap.st_wp",
"Prims.l_Forall",
"FStar.Pervasives.Native.tuple2",
"AlgHeap.state",
"Prims.logical",
"Prims.l_imp",
"FStar.Pervasives.Native.Mktuple2"
] | [] | false | false | false | true | true | let wp_is_monotonic #a (wp: st_wp a) : Type0 =
| forall p1 p2 s0. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> wp s0 p1 ==> wp s0 p2 | false |
AlgHeap.fst | AlgHeap.bind | val bind (a b: Type) (#labs1 #labs2: ops) (c: tree a labs1) (f: (x: a -> tree b labs2))
: Tot (tree b (labs1 @ labs2)) | val bind (a b: Type) (#labs1 #labs2: ops) (c: tree a labs1) (f: (x: a -> tree b labs2))
: Tot (tree b (labs1 @ labs2)) | let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k) | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 75,
"end_line": 155,
"start_col": 0,
"start_line": 150
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Type -> b: Type -> c: AlgHeap.tree a labs1 -> f: (x: a -> AlgHeap.tree b labs2)
-> AlgHeap.tree b (labs1 @ labs2) | Prims.Tot | [
"total"
] | [] | [
"AlgHeap.ops",
"AlgHeap.tree",
"AlgHeap.handle_with",
"FStar.List.Tot.Base.op_At",
"AlgHeap.op",
"Prims.b2t",
"FStar.List.Tot.Base.mem",
"AlgHeap.op_inp",
"AlgHeap.op_out",
"AlgHeap.Op"
] | [] | false | false | false | false | false | let bind (a b: Type) (#labs1 #labs2: ops) (c: tree a labs1) (f: (x: a -> tree b labs2))
: Tot (tree b (labs1 @ labs2)) =
| handle_with #_ #_ #labs1 #(labs1 @ labs2) c f (fun act i k -> Op act i k) | false |