(* 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

*)

pred c/1 elimVar, decompData.

fun encrypt/2.
fun host/1.

not c:Kas[].
not c:Kbs[].
query c:secretA[].
query c:secretB[].

param maxDepth = 6.

reduc

(* attacker *)

c:k -> c:host(k);
c:k & c:m -> c:encrypt(m,k);
c:k & c:encrypt(m,k) -> c:m;

(* A *)

c:host(Kas[]);
c:Na[];
c:nb & c:encrypt((b, k, Na[]), Kas[]) -> c:encrypt(nb, k);
c:encrypt((host(Kbs[]), k, Na[]), Kas[]) -> c:encrypt(secretA[], k);

(* B *)

c:host(Kbs[]);
c:a & c:na -> c:Nb[a, na];
c:a & c:na -> c:encrypt((a, na), Kbs[]);
c:encrypt((host(Kas[]), k, Nb[host(Kas[]), na]), Kbs[]) & c:encrypt(Nb[host(Kas[]), na], k) -> c:encrypt(secretB[], k);

(* S *)

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

(* EXPECTPV
RESULT goal unreachable: c:secretB[]
RESULT goal unreachable: c:secretA[]
0.704s (user 0.700s + system 0.004s), max rss 9880K
END *)
