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_BE: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 Vale.PPC64LE.Decls.buffers_disjoint128 keys_b inout_b /\
    Vale.PPC64LE.Decls.buffers_disjoint128 hkeys_b inout_b /\ Vale.PPC64LE.Decls.validDstAddrs128
    (va_get_mem_heaplet 5 va_s0) (va_get_reg 3 va_s0) inout_b len (va_get_mem_layout va_s0) Secret
    /\ len == Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 inout_b /\ aes_reqs
    alg key round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout
    va_s0) /\ Vale.AES.GHash_BE.hkeys_reqs_priv (Vale.Arch.Types.reverse_bytes_quad32_seq
    (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)) h_BE /\
    Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg 5 va_s0) hkeys_b 3
    (va_get_mem_layout va_s0) Secret /\ va_get_vec 1 va_s0 == Vale.AES.GHash_BE.ghash_incremental0
    h_BE 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_reg 8 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_BE.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
    (Vale.AES.GCM_helpers_BE.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.PPC64LE.Decls.modifies_buffer128 inout_b
    (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR_BE.gctr_partial alg
    len (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 5
    va_s0) inout_b)) (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
    (va_get_mem_heaplet 5 va_sM) inout_b)) key (va_get_vec 7 va_s0) /\ (let raw_quads =
    FStar.Seq.Base.append #quad32 completed_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
    (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b)) in let input_bytes =
    FStar.Seq.Base.slice #Vale.Def.Words_s.nat8 (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE
    (Vale.Def.Words.Seq_s.seq_four_to_seq_BE #Vale.Def.Words_s.nat32 raw_quads)) 0 total_bytes in
    let padded_bytes = Vale.AES.GCTR_BE_s.pad_to_128_bits input_bytes in let input_quads =
    Vale.Def.Types_s.be_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
    #Vale.Def.Types_s.quad32 input_quads > 0) (va_get_vec 1 va_sM ==
    Vale.AES.GHash_BE.ghash_incremental h_BE old_hash input_quads))) /\ va_state_eq va_sM
    (va_update_mem_heaplet 5 va_sM (va_update_cr0 va_sM (va_update_vec 12 va_sM (va_update_vec 11
    va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM (va_update_vec 7
    va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3
    va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10
    va_sM (va_update_reg 7 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_BE =
  let (va_mods:va_mods_t) = [va_Mod_mem_heaplet 5; va_Mod_cr0; va_Mod_vec 12; va_Mod_vec 11;
    va_Mod_vec 10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 7; va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec
    4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 7;
    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_BE 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 106 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCMdecrypt.vaf *****"
    (va_get_ok va_sM) /\ (let (len:(va_int_range 1 1)) = 1 in label va_range1
    "***** POSTCONDITION NOT MET AT line 152 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCMdecrypt.vaf *****"
    (Vale.PPC64LE.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 155 column 147 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCMdecrypt.vaf *****"
    (Vale.AES.GCTR_BE.gctr_partial alg len (Vale.Arch.Types.reverse_bytes_quad32_seq
    (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))
    (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 5 va_sM)
    inout_b)) key (va_get_vec 7 va_s0)) /\ label va_range1
    "***** POSTCONDITION NOT MET AT line 158 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCMdecrypt.vaf *****"
    (let raw_quads = FStar.Seq.Base.append #quad32 completed_quads
    (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 5 va_s0)
    inout_b)) in label va_range1
    "***** POSTCONDITION NOT MET AT line 159 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCMdecrypt.vaf *****"
    (let input_bytes = FStar.Seq.Base.slice #Vale.Def.Words_s.nat8
    (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE
    #Vale.Def.Words_s.nat32 raw_quads)) 0 total_bytes in label va_range1
    "***** POSTCONDITION NOT MET AT line 160 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCMdecrypt.vaf *****"
    (let padded_bytes = Vale.AES.GCTR_BE_s.pad_to_128_bits input_bytes in label va_range1
    "***** POSTCONDITION NOT MET AT line 161 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCMdecrypt.vaf *****"
    (let input_quads = Vale.Def.Types_s.be_bytes_to_seq_quad32 padded_bytes in label va_range1
    "***** POSTCONDITION NOT MET AT line 162 column 91 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCMdecrypt.vaf *****"
    (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.quad32 input_quads > 0) (va_get_vec 1 va_sM ==
    Vale.AES.GHash_BE.ghash_incremental h_BE old_hash input_quads)))))))) in
  assert_norm (va_qc.mods == va_mods);
  va_lemma_norm_mods ([va_Mod_mem_heaplet 5; va_Mod_cr0; va_Mod_vec 12; va_Mod_vec 11; va_Mod_vec
    10; va_Mod_vec 9; va_Mod_vec 8; va_Mod_vec 7; va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4;
    va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 7; va_Mod_ok;
    va_Mod_mem]) va_sM va_s0;
  (va_sM, va_fM)
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_BE: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 Vale.PPC64LE.Decls.buffers_disjoint128 keys_b inout_b /\
    Vale.PPC64LE.Decls.buffers_disjoint128 hkeys_b inout_b /\ Vale.PPC64LE.Decls.validDstAddrs128
    (va_get_mem_heaplet 5 va_s0) (va_get_reg 3 va_s0) inout_b len (va_get_mem_layout va_s0) Secret
    /\ len == Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 inout_b /\ aes_reqs
    alg key round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout
    va_s0) /\ Vale.AES.GHash_BE.hkeys_reqs_priv (Vale.Arch.Types.reverse_bytes_quad32_seq
    (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)) h_BE /\
    Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg 5 va_s0) hkeys_b 3
    (va_get_mem_layout va_s0) Secret /\ va_get_vec 1 va_s0 == Vale.AES.GHash_BE.ghash_incremental0
    h_BE 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_reg 8 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_BE.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
    (Vale.AES.GCM_helpers_BE.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.PPC64LE.Decls.modifies_buffer128 inout_b
    (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR_BE.gctr_partial alg
    len (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 5
    va_s0) inout_b)) (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
    (va_get_mem_heaplet 5 va_sM) inout_b)) key (va_get_vec 7 va_s0) /\ (let raw_quads =
    FStar.Seq.Base.append #quad32 completed_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
    (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b)) in let input_bytes =
    FStar.Seq.Base.slice #Vale.Def.Words_s.nat8 (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE
    (Vale.Def.Words.Seq_s.seq_four_to_seq_BE #Vale.Def.Words_s.nat32 raw_quads)) 0 total_bytes in
    let padded_bytes = Vale.AES.GCTR_BE_s.pad_to_128_bits input_bytes in let input_quads =
    Vale.Def.Types_s.be_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
    #Vale.Def.Types_s.quad32 input_quads > 0) (va_get_vec 1 va_sM ==
    Vale.AES.GHash_BE.ghash_incremental h_BE old_hash input_quads))) /\ va_state_eq va_sM
    (va_update_mem_heaplet 5 va_sM (va_update_cr0 va_sM (va_update_vec 12 va_sM (va_update_vec 11
    va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM (va_update_vec 7
    va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3
    va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10
    va_sM (va_update_reg 7 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_BE
     =
let va_mods:va_mods_t =
  [
    va_Mod_mem_heaplet 5; va_Mod_cr0; va_Mod_vec 12; va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9;
    va_Mod_vec 8; va_Mod_vec 7; va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
    va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 7; 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_BE
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 106 column 1 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCMdecrypt.vaf *****"
          (va_get_ok va_sM) /\
        (let len:(va_int_range 1 1) = 1 in
          label va_range1
            "***** POSTCONDITION NOT MET AT line 152 column 55 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCMdecrypt.vaf *****"
            (Vale.PPC64LE.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 155 column 147 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCMdecrypt.vaf *****"
            (Vale.AES.GCTR_BE.gctr_partial alg
                len
                (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
                            5
                            va_s0)
                        inout_b))
                (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
                            5
                            va_sM)
                        inout_b))
                key
                (va_get_vec 7 va_s0)) /\
          label va_range1
            "***** POSTCONDITION NOT MET AT line 158 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCMdecrypt.vaf *****"
            (let raw_quads =
                FStar.Seq.Base.append #quad32
                  completed_quads
                  (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
                              5
                              va_s0)
                          inout_b))
              in
              label va_range1
                "***** POSTCONDITION NOT MET AT line 159 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCMdecrypt.vaf *****"
                (let input_bytes =
                    FStar.Seq.Base.slice #Vale.Def.Words_s.nat8
                      (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE
                              #Vale.Def.Words_s.nat32
                              raw_quads))
                      0
                      total_bytes
                  in
                  label va_range1
                    "***** POSTCONDITION NOT MET AT line 160 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCMdecrypt.vaf *****"
                    (let padded_bytes = Vale.AES.GCTR_BE_s.pad_to_128_bits input_bytes in
                      label va_range1
                        "***** POSTCONDITION NOT MET AT line 161 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCMdecrypt.vaf *****"
                        (let input_quads = Vale.Def.Types_s.be_bytes_to_seq_quad32 padded_bytes in
                          label va_range1
                            "***** POSTCONDITION NOT MET AT line 162 column 91 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCMdecrypt.vaf *****"
                            (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.quad32 input_quads > 0)
                                (va_get_vec 1 va_sM ==
                                  Vale.AES.GHash_BE.ghash_incremental h_BE old_hash input_quads)))))
            )))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([
      va_Mod_mem_heaplet 5; va_Mod_cr0; va_Mod_vec 12; va_Mod_vec 11; va_Mod_vec 10; va_Mod_vec 9;
      va_Mod_vec 8; va_Mod_vec 7; va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3;
      va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 7; va_Mod_ok; va_Mod_mem
    ])
  va_sM
  va_s0;
(va_sM, va_fM)
Vale.AES.PPC64LE.GCMdecrypt.fst.checked
Vale.PPC64LE.State.fsti.checked Vale.PPC64LE.Stack_i.fsti.checked Vale.PPC64LE.QuickCodes.fsti.checked Vale.PPC64LE.QuickCode.fst.checked Vale.PPC64LE.Memory.fsti.checked Vale.PPC64LE.Machine_s.fst.checked Vale.PPC64LE.InsVector.fsti.checked Vale.PPC64LE.InsStack.fsti.checked Vale.PPC64LE.InsMem.fsti.checked Vale.PPC64LE.InsBasic.fsti.checked Vale.PPC64LE.Decls.fsti.checked Vale.Poly1305.Math.fsti.checked Vale.Math.Poly2.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.Words.Four_s.fsti.checked Vale.Def.Types_s.fst.checked Vale.Def.Prop_s.fst.checked Vale.Def.Opaque_s.fsti.checked Vale.Arch.Types.fsti.checked Vale.Arch.HeapImpl.fsti.checked Vale.AES.Types_helpers.fsti.checked Vale.AES.PPC64LE.GHash.fsti.checked Vale.AES.PPC64LE.GF128_Mul.fsti.checked Vale.AES.PPC64LE.GCTR.fsti.checked Vale.AES.PPC64LE.GCMencrypt.fsti.checked Vale.AES.PPC64LE.AES.fsti.checked Vale.AES.GHash_BE_s.fst.checked Vale.AES.GHash_BE.fsti.checked Vale.AES.GF128_s.fsti.checked Vale.AES.GF128.fsti.checked Vale.AES.GCTR_BE_s.fst.checked Vale.AES.GCTR_BE.fsti.checked Vale.AES.GCM_helpers_BE.fsti.checked Vale.AES.GCM_BE_s.fst.checked Vale.AES.GCM_BE.fsti.checked Vale.AES.AES_common_s.fst.checked Vale.AES.AES_BE_s.fst.checked prims.fst.checked FStar.Seq.Base.fsti.checked FStar.Seq.fst.checked FStar.Pervasives.Native.fst.checked FStar.Pervasives.fsti.checked
Vale.AES.PPC64LE.GCMdecrypt.fst
Vale.PPC64LE.Decls.va_code Vale.PPC64LE.Decls.va_state Vale.AES.AES_common_s.algorithm Vale.PPC64LE.Memory.buffer128 FStar.Seq.Base.seq Vale.PPC64LE.Memory.nat32 Vale.PPC64LE.Memory.quad32 Prims.nat Vale.PPC64LE.QuickCodes.fuel Prims.unit FStar.Pervasives.Native.Mktuple2 Vale.PPC64LE.Decls.va_fuel Vale.PPC64LE.QuickCode.va_lemma_norm_mods Prims.Cons Vale.PPC64LE.QuickCode.mod_t Vale.PPC64LE.QuickCode.va_Mod_mem_heaplet Vale.PPC64LE.QuickCode.va_Mod_cr0 Vale.PPC64LE.QuickCode.va_Mod_vec Vale.PPC64LE.QuickCode.va_Mod_reg Vale.PPC64LE.QuickCode.va_Mod_ok Vale.PPC64LE.QuickCode.va_Mod_mem Prims.Nil FStar.Pervasives.assert_norm Prims.eq2 Prims.list Vale.PPC64LE.QuickCode.__proj__QProc__item__mods Vale.AES.PPC64LE.GCMdecrypt.va_code_Gcm_extra_bytes FStar.Pervasives.Native.tuple2 FStar.Pervasives.Native.tuple3 Vale.PPC64LE.Machine_s.state Vale.PPC64LE.QuickCodes.va_wp_sound_code_norm Prims.l_and Vale.PPC64LE.QuickCodes.label Vale.PPC64LE.QuickCodes.va_range1 Prims.b2t Vale.PPC64LE.Decls.va_get_ok Vale.PPC64LE.Decls.modifies_buffer128 Vale.PPC64LE.Decls.va_get_mem_heaplet Vale.AES.GCTR_BE.gctr_partial Vale.Arch.Types.reverse_bytes_quad32_seq Vale.PPC64LE.Decls.s128 Vale.PPC64LE.Decls.va_get_vec Prims.op_GreaterThan FStar.Seq.Base.length Vale.Def.Types_s.quad32 Vale.AES.GHash_BE.ghash_incremental Vale.Def.Types_s.be_bytes_to_seq_quad32 Vale.Def.Words_s.nat8 Vale.AES.GCTR_BE_s.pad_to_128_bits FStar.Seq.Base.slice Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE Vale.Def.Words.Seq_s.seq_four_to_seq_BE Vale.Def.Words_s.nat32 FStar.Seq.Base.append Vale.PPC64LE.Decls.va_int_range Vale.PPC64LE.QuickCode.quickCode Vale.AES.PPC64LE.GCMdecrypt.va_qcode_Gcm_extra_bytes
module Vale.AES.PPC64LE.GCMdecrypt
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_BE_s
open Vale.AES.GCTR_BE_s
open Vale.AES.GCTR_BE
open Vale.AES.GCM_BE
open Vale.AES.GHash_BE_s
open Vale.AES.GHash_BE
open Vale.AES.GCM_BE_s
open Vale.AES.PPC64LE.AES
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.Poly1305.Math
open Vale.AES.GCM_helpers_BE
open Vale.AES.PPC64LE.GHash
open Vale.AES.PPC64LE.GCTR
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.Stack_i
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.InsStack
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.PPC64LE.GF128_Mul
open Vale.Math.Poly2.Bits_s
open Vale.Lib.Meta
open Vale.AES.PPC64LE.GCMencrypt
open Vale.Lib.Basic
#reset-options "--z3rlimit 20"
//-- 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_Vmr (va_op_vec_opr_vec 11) (va_op_vec_opr_vec 7)) (va_CCons
    (va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 5) (va_op_vec_opr_vec 9)
    (va_op_reg_opr_reg 3) Secret) (va_CCons (va_code_Vmr (va_op_vec_opr_vec 12) (va_op_vec_opr_vec
    9)) (va_CCons (va_code_Ghash_extra_bytes ()) (va_CCons (va_code_Vmr (va_op_vec_opr_vec 0)
    (va_op_vec_opr_vec 11)) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons (va_code_Vxor
    (va_op_vec_opr_vec 12) (va_op_vec_opr_vec 12) (va_op_vec_opr_vec 0)) (va_CCons
    (va_code_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 5) (va_op_vec_opr_vec 12)
    (va_op_reg_opr_reg 3) 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_Vmr (va_op_vec_opr_vec 11) (va_op_vec_opr_vec 7)) (va_pbool_and
    (va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 5) (va_op_vec_opr_vec 9)
    (va_op_reg_opr_reg 3) Secret) (va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 12)
    (va_op_vec_opr_vec 9)) (va_pbool_and (va_codegen_success_Ghash_extra_bytes ()) (va_pbool_and
    (va_codegen_success_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 11)) (va_pbool_and
    (va_codegen_success_AESEncryptBlock alg) (va_pbool_and (va_codegen_success_Vxor
    (va_op_vec_opr_vec 12) (va_op_vec_opr_vec 12) (va_op_vec_opr_vec 0)) (va_pbool_and
    (va_codegen_success_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 5) (va_op_vec_opr_vec 12)
    (va_op_reg_opr_reg 3) 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_BE: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 164 column 8 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCMdecrypt.vaf *****"
    (va_quick_Vmr (va_op_vec_opr_vec 11) (va_op_vec_opr_vec 7)) (va_QSeq va_range1
    "***** PRECONDITION NOT MET AT line 165 column 26 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCMdecrypt.vaf *****"
    (va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 5) (va_op_vec_opr_vec 9)
    (va_op_reg_opr_reg 3) Secret inout_b 0) (va_QBind va_range1
    "***** PRECONDITION NOT MET AT line 166 column 8 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCMdecrypt.vaf *****"
    (va_quick_Vmr (va_op_vec_opr_vec 12) (va_op_vec_opr_vec 9)) (fun (va_s:va_state) _ -> let
    (hash_input:quad32) = va_get_vec 9 va_s in va_QBind va_range1
    "***** PRECONDITION NOT MET AT line 170 column 22 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCMdecrypt.vaf *****"
    (va_quick_Ghash_extra_bytes hkeys_b total_bytes old_hash h_BE completed_quads) (fun
    (va_s:va_state) _ -> va_qAssert va_range1
    "***** PRECONDITION NOT MET AT line 171 column 5 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCMdecrypt.vaf *****"
    (FStar.Seq.Base.equal #Vale.Def.Types_s.quad32 (Vale.Arch.Types.reverse_bytes_quad32_seq
    (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b)) (FStar.Seq.Base.create #quad32 1
    hash_input)) (va_QSeq va_range1
    "***** PRECONDITION NOT MET AT line 173 column 8 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCMdecrypt.vaf *****"
    (va_quick_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 11)) (va_QSeq va_range1
    "***** PRECONDITION NOT MET AT line 174 column 20 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCMdecrypt.vaf *****"
    (va_quick_AESEncryptBlock alg (va_get_vec 7 va_old_s) key round_keys keys_b) (va_QSeq va_range1
    "***** PRECONDITION NOT MET AT line 176 column 9 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCMdecrypt.vaf *****"
    (va_quick_Vxor (va_op_vec_opr_vec 12) (va_op_vec_opr_vec 12) (va_op_vec_opr_vec 0)) (va_QBind
    va_range1
    "***** PRECONDITION NOT MET AT line 177 column 27 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCMdecrypt.vaf *****"
    (va_quick_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 5) (va_op_vec_opr_vec 12)
    (va_op_reg_opr_reg 3) Secret inout_b 0) (fun (va_s:va_state) _ -> va_qPURE va_range1
    "***** PRECONDITION NOT MET AT line 179 column 24 of file /home/gebner/everest/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCMdecrypt.vaf *****"
    (fun (_:unit) -> Vale.AES.GCTR_BE.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_BE: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 Vale.PPC64LE.Decls.buffers_disjoint128 keys_b inout_b /\
    Vale.PPC64LE.Decls.buffers_disjoint128 hkeys_b inout_b /\ Vale.PPC64LE.Decls.validDstAddrs128
    (va_get_mem_heaplet 5 va_s0) (va_get_reg 3 va_s0) inout_b len (va_get_mem_layout va_s0) Secret
    /\ len == Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 inout_b /\ aes_reqs
    alg key round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout
    va_s0) /\ Vale.AES.GHash_BE.hkeys_reqs_priv (Vale.Arch.Types.reverse_bytes_quad32_seq
    (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)) h_BE /\
    Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg 5 va_s0) hkeys_b 3
    (va_get_mem_layout va_s0) Secret /\ va_get_vec 1 va_s0 == Vale.AES.GHash_BE.ghash_incremental0
    h_BE 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_reg 8 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_BE.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
    (Vale.AES.GCM_helpers_BE.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.PPC64LE.Decls.modifies_buffer128 inout_b
    (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR_BE.gctr_partial alg
    len (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 5
    va_s0) inout_b)) (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
    (va_get_mem_heaplet 5 va_sM) inout_b)) key (va_get_vec 7 va_s0) /\ (let raw_quads =
    FStar.Seq.Base.append #quad32 completed_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
    (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b)) in let input_bytes =
    FStar.Seq.Base.slice #Vale.Def.Words_s.nat8 (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE
    (Vale.Def.Words.Seq_s.seq_four_to_seq_BE #Vale.Def.Words_s.nat32 raw_quads)) 0 total_bytes in
    let padded_bytes = Vale.AES.GCTR_BE_s.pad_to_128_bits input_bytes in let input_quads =
    Vale.Def.Types_s.be_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
    #Vale.Def.Types_s.quad32 input_quads > 0) (va_get_vec 1 va_sM ==
    Vale.AES.GHash_BE.ghash_incremental h_BE old_hash input_quads))) /\ va_state_eq va_sM
    (va_update_mem_heaplet 5 va_sM (va_update_cr0 va_sM (va_update_vec 12 va_sM (va_update_vec 11
    va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM (va_update_vec 7
    va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3
    va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10
    va_sM (va_update_reg 7 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))
[@"opaque_to_smt"]
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_BE: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 Vale.PPC64LE.Decls.buffers_disjoint128 keys_b inout_b /\
    Vale.PPC64LE.Decls.buffers_disjoint128 hkeys_b inout_b /\ Vale.PPC64LE.Decls.validDstAddrs128
    (va_get_mem_heaplet 5 va_s0) (va_get_reg 3 va_s0) inout_b len (va_get_mem_layout va_s0) Secret
    /\ len == Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 inout_b /\ aes_reqs
    alg key round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout
    va_s0) /\ Vale.AES.GHash_BE.hkeys_reqs_priv (Vale.Arch.Types.reverse_bytes_quad32_seq
    (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)) h_BE /\
    Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg 5 va_s0) hkeys_b 3
    (va_get_mem_layout va_s0) Secret /\ va_get_vec 1 va_s0 == Vale.AES.GHash_BE.ghash_incremental0
    h_BE 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_reg 8 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_BE.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
    (Vale.AES.GCM_helpers_BE.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.PPC64LE.Decls.modifies_buffer128 inout_b
    (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR_BE.gctr_partial alg
    len (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 5
    va_s0) inout_b)) (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
    (va_get_mem_heaplet 5 va_sM) inout_b)) key (va_get_vec 7 va_s0) /\ (let raw_quads =
    FStar.Seq.Base.append #quad32 completed_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
    (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b)) in let input_bytes =
    FStar.Seq.Base.slice #Vale.Def.Words_s.nat8 (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE
    (Vale.Def.Words.Seq_s.seq_four_to_seq_BE #Vale.Def.Words_s.nat32 raw_quads)) 0 total_bytes in
    let padded_bytes = Vale.AES.GCTR_BE_s.pad_to_128_bits input_bytes in let input_quads =
    Vale.Def.Types_s.be_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
    #Vale.Def.Types_s.quad32 input_quads > 0) (va_get_vec 1 va_sM ==
    Vale.AES.GHash_BE.ghash_incremental h_BE old_hash input_quads))) /\ va_state_eq va_sM
    (va_update_mem_heaplet 5 va_sM (va_update_cr0 va_sM (va_update_vec 12 va_sM (va_update_vec 11
    va_sM (va_update_vec 10 va_sM (va_update_vec 9 va_sM (va_update_vec 8 va_sM (va_update_vec 7
    va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3
    va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10
    va_sM (va_update_reg 7 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))

    va_b0: Vale.PPC64LE.Decls.va_code ->
    va_s0: Vale.PPC64LE.Decls.va_state ->
    alg: Vale.AES.AES_common_s.algorithm ->
    inout_b: Vale.PPC64LE.Memory.buffer128 ->
    key: FStar.Seq.Base.seq Vale.PPC64LE.Memory.nat32 ->
    round_keys: FStar.Seq.Base.seq Vale.PPC64LE.Memory.quad32 ->
    keys_b: Vale.PPC64LE.Memory.buffer128 ->
    hkeys_b: Vale.PPC64LE.Memory.buffer128 ->
    total_bytes: Prims.nat ->
    old_hash: Vale.PPC64LE.Memory.quad32 ->
    completed_quads: FStar.Seq.Base.seq Vale.PPC64LE.Memory.quad32 ->
    h_BE: Vale.PPC64LE.Memory.quad32
  -> Prims.Ghost (Vale.PPC64LE.Decls.va_state * Vale.PPC64LE.Decls.va_fuel)