(* Simpler Yahalom protocol
Version of Burrows, Abadi, Needham, SRC039

Message 1 A -> B: A; Na 
Message 2 B -> S: B; Nb; {A; Na}Kbs 
Message 3 S -> A: Nb; {B; Kab; Na}Kas ; {A; Kab; Nb}Kbs 
Message 4 A -> B: {A; Kab; Nb}Kbs ; {Nb}Kab

Attack of Syverson, A taxonomy of replay attacks

*)

pred c/1 elimVar, decompData.
nounif c:x.

fun encrypt/2.
fun host/1.
fun i0/0.

query A:x.

(* param maxDepth = 6. *)

not c:Kas[].
not c:Kbs[].

reduc

(* attacker *)

c:c[];
c:k -> c:host(k);
c:k & c:m -> c:encrypt(m,k);
c:k & c:encrypt(m,k) -> c:m;
c:host(Kas[]);
c:host(Kbs[]);

(* A *)

c:(host(Kas[]), Na[i]);
c:(nb, encrypt((b, k, Na[i]), Kas[]), mb) -> c:(mb, encrypt(nb, k));
c:(nb, encrypt((host(Kbs[]), k, Na[i]), Kas[]), mb) -> A:encrypt((host(Kbs[]), k, Na[i]), Kas[]);

(* B *)

c:(a, na) & (a,na) <> (host(Kas[]),Na[i0()]) -> c:(host(Kbs[]), Nb[a, na, j], encrypt((a, na), Kbs[]));

(* S *)

c:(host(kbs), nb, encrypt((host(kas), na), kbs)) -> c:(nb, encrypt((host(kbs), k[kas, kbs, na, nb], na), kas), encrypt((host(kas),  k[kas, kbs, na, nb], nb), kbs)).
