Require Recdef.
Require Coq.Strings.String.
Require Coq.Strings.Ascii.
(* LINEAR-TIME FUNCTIONAL VERSION OF SHA256 *)
Function zeros (n : Z) {measure Z.to_nat n} : list Int.int :=
if Z.gtb n 0 then Int.zero :: zeros (n-1) else nil.

(* Specifications: *)
Lemma length_rnd_64_inv:
forall r k w, length (rnd_64 r k w) = 8 -> length r = 8.
Lemma length_process_block:
forall r b, length r = 8 -> length (process_block r b) = 8.
Lemma length_map2_add_rnd_64:
forall regs w,
length regs = 8 ->
length (map2 Int.add regs (rnd_64 regs K256 w)) = 8.
Lemma grab_and_process_block_length:
forall n r firstr msg r' m',
length r = 8 ->
length msg >= n ->
grab_and_process_block n r firstr msg  = (r',m') ->
length r' = 8.
Lemma length_process_msg:
forall b, length (process_msg init_registers b) = 8.
Lemma process_msg_eq2:
forall regs hashed b,
length b = 16 ->
process_msg regs (b++hashed) =
process_msg (process_block regs (rev b)) hashed.
Lemma rnd_64_S:
forall regs i b k w,
nth_error K256 i = Some k ->
nth_error b i = Some w ->
rnd_64 regs K256 (firstn (S i) b) =
rnd_function (rnd_64 regs K256 (firstn i b)) k w.
Lemma Zlength_zeros:
forall n, (n>=0)%Z -> Zlength (zeros n) = n.
Lemma length_zeros: forall n:Z, length (zeros n) = Z.to_nat n.
Hint Rewrite length_zeros : norm.