(* modified version of sha_padding_lemmas.pad *)
Definition pad_inc (msg : list byte) : list byte :=
  let n := BlockSize + Zlength msg in
  msg ++ [Byte.repr 128%Z]
      ++ list_repeat (Z.to_nat (-(n + 9) mod 64)) Byte.zero
      ++ intlist_to_bytelist ([Int.repr (n * 8 / Int.modulus); Int.repr (n * 8)]).Definition sha_splitandpad_inc (msg : Blist) : Blist :=
  bytesToBits (pad_inc (bitsToBytes msg)).

(* Specifications: *)
Lemma sha_splitandpad_inc_nil: length (sha_splitandpad_inc nil) = 512%nat.
Lemma pad_inc_length: forall l, exists k, (0 < k /\ length (pad_inc l) = k*64)%nat.
Lemma sha_splitandpad_inc_length: forall m, exists k, (0<k /\ length (sha_splitandpad_inc m) = k * 512)%nat.
Lemma sha_splitandpad_inc_InBlocks m : InBlocks 512 (sha_splitandpad_inc m).
Lemma sha_iv_length: length sha_iv = 256%nat.
Lemma B: (0<b)%nat.
Lemma hash_blocks_bits_len': forall r l, length r = 256%nat -> InBlocks 512 l -> length (hash_blocks_bits _ B sha_h r l) = 256%nat.
Lemma sha_h_length iv blk: length iv = c -> length blk = b -> length (sha_h iv blk) = c.
Lemma pad_injective_aux (l1 l2: list byte) k (K : k * Int.modulus + (BlockSize + Zlength l1) * 8 = (BlockSize + Zlength l2) * 8) (N : k <> 0): - (BlockSize + Zlength l2 + 9) mod 64 = - (BlockSize + Zlength l1 + 9) mod 64.
Lemma pad_injective_Case5 l1 l2 (H0 : (l1 ++ Byte.repr 128 :: nil) ++ list_repeat (Z.to_nat (- (BlockSize + Zlength l1 + 9) mod 64)) Byte.zero = (l2 ++ Byte.repr 128 :: nil) ++ list_repeat (Z.to_nat (- (BlockSize + Zlength l2 + 9) mod 64)) Byte.zero) (H : (BlockSize + Zlength l1) * 8 = ((BlockSize + Zlength l2) * 8) mod Int.modulus) (Nonneg1 : 0 <= (BlockSize + Zlength l1) * 8) (l : (BlockSize + Zlength l1) * 8 < Int.modulus): length l1 = length l2.
Lemma pad_inc_injective: forall l1 l2, pad_inc l1 = pad_inc l2 -> l1=l2.
Lemma block_8 A (l:list A): length l = b -> InBlocks 8 l.
Lemma sha_splitandpad_app : forall (l m : Blist), length l = b -> sha_splitandpad (l ++ m) = l ++ sha_splitandpad_inc m.