(* Needham Shroeder public key protocol.
   Original version, with a flaw discovered by Lowe *)

pred c/1 decompData, elimVar.

fun host/1.
fun sign/2.
fun pk/1.
fun encrypt/2.

query c:secret[].

not c:sS[].
not c:sA[].

reduc

(* The attacker *)

c:x & c:y -> c:sign(x,y);
c:sign(x,y) -> c:x;
c:x & c:encrypt(m,pk(x)) -> c:m;
c:x -> c:pk(x);
c:x & c:y -> c:encrypt(x,y);
c:host(x);

(* The protocol *)
(* Initialisation *)

c:pk(sA[]);
c:pk(sS[]);

(* A *)

c:sign((pkx, x), sS[]) -> c:encrypt((Na[pkx], host(sA[])), pkx);
c:sign((pkx, x), sS[]) & c:encrypt((Na[pkx], y), pk(sA[]))
   -> c:encrypt((y,k[x]), pkx);

(* B *)

c:encrypt((x,host(a)), pk(sA[])) & c:sign((pka, host(a)), sS[]) -> c:encrypt((x, Nb[x,host(a)]), pka);
c:encrypt((x,host(sA[])), pk(sA[])) & c:sign((pka, host(sA[])), sS[]) & c:encrypt((Nb[x, host(sA[])], z), pk(sA[]))
   -> c:encrypt(secret[], pk(z));

(* server *)

c:(host(s1),host(s2)) -> c:sign((pk(s2), host(s2)), sS[]).

(* EXPECTPV
RESULT goal reachable: c:secret[]
0.012s (user 0.004s + system 0.008s), max rss 8576K
END *)
