Local Open Scope logic.
(*TODO: eliminate*)
Ltac canon_load_result ::= idtac.
Opaque littleendian.
Opaque littleendian_invert. Opaque Snuffle20. Opaque prepare_data.
Opaque QuadByte2ValList. Opaque fcore_result.
Definition wlistJ' (wlist:list val) (j: Z) (t0 t1 t2 t3:int) (l: list val): Prop :=
Zlength l = 16 /\
l = upd_Znth (4 * j + (j + 3) mod 4)
(upd_Znth (4 * j + (j + 2) mod 4)
(upd_Znth (4 * j + (j + 1) mod 4)
(upd_Znth (4 * j + (j + 0) mod 4) wlist (Vint t0))
(Vint t1)) (Vint t2)) (Vint t3).
Fixpoint WLIST' (wlist : list val) (tlist: list int) (j:Z) m l :=
match m with
O => l=wlist
| S m' => exists l' tm,
Zlength l = Zlength wlist /\
WLIST' wlist tlist j m' l' /\
Znth (Z.of_nat m') (map Vint tlist) = Vint tm /\
l = upd_Znth (4*j+ ((j+Z.of_nat m') mod 4)) l' (Vint tm)
end.
Definition Wcopyspec (t0 t1 t2 t3: int):=
(Int.xor t0
(Int.rol
(Int.add
(Int.xor t3
(Int.rol
(Int.add
(Int.xor t2
(Int.rol
(Int.add
(Int.xor t1
(Int.rol (Int.add t0 t3) (Int.repr 7))) t0)
(Int.repr 9)))
(Int.xor t1 (Int.rol (Int.add t0 t3) (Int.repr 7))))
(Int.repr 13)))
(Int.xor t2
(Int.rol
(Int.add
(Int.xor t1 (Int.rol (Int.add t0 t3) (Int.repr 7))) t0)
(Int.repr 9)))) (Int.repr 18)),
Int.xor t1 (Int.rol (Int.add t0 t3) (Int.repr 7)),
Int.xor t2
(Int.rol
(Int.add (Int.xor t1 (Int.rol (Int.add t0 t3) (Int.repr 7))) t0)
(Int.repr 9)),
Int.xor t3
(Int.rol
(Int.add
(Int.xor t2
(Int.rol
(Int.add
(Int.xor t1 (Int.rol (Int.add t0 t3) (Int.repr 7))) t0)
(Int.repr 9)))
(Int.xor t1 (Int.rol (Int.add t0 t3) (Int.repr 7))))
(Int.repr 13))).
Definition Jbody_statement :=
(Ssequence
(Sfor (Sset _m (Econst_int (Int.repr 0) tint))
(Ebinop Olt (Etempvar _m tint) (Econst_int (Int.repr 4) tint) tint)
(Ssequence
(Sset _t'33
(Ederef
(Ebinop Oadd (Evar _x (tarray tuint 16))
(Ebinop Omod
(Ebinop Oadd
(Ebinop Omul (Econst_int (Int.repr 5) tint)
(Etempvar _j tint) tint)
(Ebinop Omul (Econst_int (Int.repr 4) tint)
(Etempvar _m tint) tint) tint)
(Econst_int (Int.repr 16) tint) tint) (tptr tuint))
tuint))
(Sassign
(Ederef
(Ebinop Oadd (Evar _t (tarray tuint 4)) (Etempvar _m tint)
(tptr tuint)) tuint) (Etempvar _t'33 tuint)))
(Sset _m
(Ebinop Oadd (Etempvar _m tint) (Econst_int (Int.repr 1) tint)
tint)))
(Ssequence
(Ssequence
(Ssequence
(Sset _t'31
(Ederef
(Ebinop Oadd (Evar _t (tarray tuint 4))
(Econst_int (Int.repr 0) tint) (tptr tuint)) tuint))
(Ssequence
(Sset _t'32
(Ederef
(Ebinop Oadd (Evar _t (tarray tuint 4))
(Econst_int (Int.repr 3) tint) (tptr tuint)) tuint))
(Scall (Some _t'5)
(Evar _L32
(Tfunction (Tcons tuint (Tcons tint Tnil)) tuint
cc_default))
[Ebinop Oadd (Etempvar _t'31 tuint)
(Etempvar _t'32 tuint) tuint;
Econst_int (Int.repr 7) tint])))
(Ssequence
(Sset _t'30
(Ederef
(Ebinop Oadd (Evar _t (tarray tuint 4))
(Econst_int (Int.repr 1) tint) (tptr tuint)) tuint))
(Sassign
(Ederef
(Ebinop Oadd (Evar _t (tarray tuint 4))
(Econst_int (Int.repr 1) tint) (tptr tuint)) tuint)
(Ebinop Oxor (Etempvar _t'30 tuint) (Etempvar _t'5 tuint)
tuint))))
(Ssequence
(Ssequence
(Ssequence
(Sset _t'28
(Ederef
(Ebinop Oadd (Evar _t (tarray tuint 4))
(Econst_int (Int.repr 1) tint) (tptr tuint)) tuint))
(Ssequence
(Sset _t'29
(Ederef
(Ebinop Oadd (Evar _t (tarray tuint 4))
(Econst_int (Int.repr 0) tint) (tptr tuint))
tuint))
(Scall (Some _t'6)
(Evar _L32
(Tfunction (Tcons tuint (Tcons tint Tnil)) tuint
cc_default))
[Ebinop Oadd (Etempvar _t'28 tuint)
(Etempvar _t'29 tuint) tuint;
Econst_int (Int.repr 9) tint])))
(Ssequence
(Sset _t'27
(Ederef
(Ebinop Oadd (Evar _t (tarray tuint 4))
(Econst_int (Int.repr 2) tint) (tptr tuint)) tuint))
(Sassign
(Ederef
(Ebinop Oadd (Evar _t (tarray tuint 4))
(Econst_int (Int.repr 2) tint) (tptr tuint)) tuint)
(Ebinop Oxor (Etempvar _t'27 tuint) (Etempvar _t'6 tuint)
tuint))))
(Ssequence
(Ssequence
(Ssequence
(Sset _t'25
(Ederef
(Ebinop Oadd (Evar _t (tarray tuint 4))
(Econst_int (Int.repr 2) tint) (tptr tuint))
tuint))
(Ssequence
(Sset _t'26
(Ederef
(Ebinop Oadd (Evar _t (tarray tuint 4))
(Econst_int (Int.repr 1) tint) (tptr tuint))
tuint))
(Scall (Some _t'7)
(Evar _L32
(Tfunction (Tcons tuint (Tcons tint Tnil)) tuint
cc_default))
[Ebinop Oadd (Etempvar _t'25 tuint)
(Etempvar _t'26 tuint) tuint;
Econst_int (Int.repr 13) tint])))
(Ssequence
(Sset _t'24
(Ederef
(Ebinop Oadd (Evar _t (tarray tuint 4))
(Econst_int (Int.repr 3) tint) (tptr tuint))
tuint))
(Sassign
(Ederef
(Ebinop Oadd (Evar _t (tarray tuint 4))
(Econst_int (Int.repr 3) tint) (tptr tuint))
tuint)
(Ebinop Oxor (Etempvar _t'24 tuint)
(Etempvar _t'7 tuint) tuint))))
(Ssequence
(Ssequence
(Ssequence
(Sset _t'22
(Ederef
(Ebinop Oadd (Evar _t (tarray tuint 4))
(Econst_int (Int.repr 3) tint) (tptr tuint))
tuint))
(Ssequence
(Sset _t'23
(Ederef
(Ebinop Oadd (Evar _t (tarray tuint 4))
(Econst_int (Int.repr 2) tint)
(tptr tuint)) tuint))
(Scall (Some _t'8)
(Evar _L32
(Tfunction (Tcons tuint (Tcons tint Tnil))
tuint cc_default))
[Ebinop Oadd (Etempvar _t'22 tuint)
(Etempvar _t'23 tuint) tuint;
Econst_int (Int.repr 18) tint])))
(Ssequence
(Sset _t'21
(Ederef
(Ebinop Oadd (Evar _t (tarray tuint 4))
(Econst_int (Int.repr 0) tint) (tptr tuint))
tuint))
(Sassign
(Ederef
(Ebinop Oadd (Evar _t (tarray tuint 4))
(Econst_int (Int.repr 0) tint) (tptr tuint))
tuint)
(Ebinop Oxor (Etempvar _t'21 tuint)
(Etempvar _t'8 tuint) tuint))))
(Sfor (Sset _m (Econst_int (Int.repr 0) tint))
(Ebinop Olt (Etempvar _m tint)
(Econst_int (Int.repr 4) tint) tint)
(Ssequence
(Sset _t'20
(Ederef
(Ebinop Oadd (Evar _t (tarray tuint 4))
(Etempvar _m tint) (tptr tuint)) tuint))
(Sassign
(Ederef
(Ebinop Oadd (Evar _w (tarray tuint 16))
(Ebinop Oadd
(Ebinop Omul
(Econst_int (Int.repr 4) tint)
(Etempvar _j tint) tint)
(Ebinop Omod
(Ebinop Oadd (Etempvar _j tint)
(Etempvar _m tint) tint)
(Econst_int (Int.repr 4) tint) tint)
tint) (tptr tuint)) tuint)
(Etempvar _t'20 tuint)))
(Sset _m
(Ebinop Oadd (Etempvar _m tint)
(Econst_int (Int.repr 1) tint) tint)))))))).

Lemma Jbody (Espec : OracleKind) FR c k h nonce out w x y t i j xs
(I : 0 <= i < 20)
(J : 0 <= j < 4)
wlist
t0 t1 t2 t3
(T0: Znth ((5*j+4*0) mod 16) (map Vint xs) = Vint t0)
(T1: Znth ((5*j+4*1) mod 16) (map Vint  xs) = Vint t1)
(T2: Znth ((5*j+4*2) mod 16) (map Vint xs) = Vint t2)
(T3: Znth ((5*j+4*3) mod 16) (map Vint xs) = Vint t3):
@semax CompSpecs Espec
(func_tycontext f_core SalsaVarSpecs SalsaFunSpecs nil)
(PROP  ()
LOCAL  (temp _j (Vint (Int.repr j)); temp _i (Vint (Int.repr i));
lvar _t (tarray tuint 4) t; lvar _y (tarray tuint 16) y;
lvar _x (tarray tuint 16) x; lvar _w (tarray tuint 16) w; temp _in nonce;
temp _out out; temp _c c; temp _k k; temp _h (Vint (Int.repr h)))
SEP  (FR; data_at_ Tsh (tarray tuint 4) t;
data_at Tsh (tarray tuint 16) (*(map Vint wlist)*) wlist w;
data_at Tsh (tarray tuint 16) (map Vint xs) x))
Jbody_statement
(normal_ret_assert
(PROP  (0 <= j + 1 <= 4)
LOCAL  (temp _j (Vint (Int.repr j)); temp _i (Vint (Int.repr i));
lvar _t (tarray tuint 4) t; lvar _y (tarray tuint 16) y;
lvar _x (tarray tuint 16) x; lvar _w (tarray tuint 16) w;
temp _in nonce; temp _out out; temp _c c; temp _k k;
temp _h (Vint (Int.repr h)))
SEP  (FR; data_at Tsh (tarray tuint 16) (map Vint xs) x;
data_at_ Tsh (tarray tuint 4) t;
EX W:_,
!!(match Wcopyspec t0 t1 t2 t3 with
(s0,s1,s2,s3) => wlistJ' wlist j s0 s1 s2 s3 W
end)
&& data_at Tsh (tarray tuint 16) (*(map Vint W)*)W w))).