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

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

*)

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

fun encrypt/2.
fun host/1.


query A:x.

(* param maxDepth = 100. *)

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:(encrypt((b, k, Na[i], nb), Kas[]), mb) -> c:(mb, encrypt(nb, k));
c:(encrypt((host(Kbs[]), k, Na[i], nb), Kas[]), mb) -> A:encrypt((host(Kbs[]), k, Na[i], nb), Kas[]);

(* B *)

c:(a, na) -> c:(host(Kbs[]), encrypt((a, na, Nb[a,na,j]), Kbs[]));

(* S *)

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