(*************************************************************
 *                                                           *
 *       Cryptographic protocol verifier                     *
 *                                                           *
 *       Bruno Blanchet and Xavier Allamigeon                *
 *                                                           *
 *       Copyright (C) INRIA, LIENS, MPII 2000-2012          *
 *                                                           *
 *************************************************************)

(*

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details (in file LICENSE).

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

*)
(* Otway Rees protocol.
   Corrected version by Paulson TR443 Inductive... *)

pred c/1 decompData, elimVar.

fun host/1.

fun encrypt/2.

query c:secretA[].
query c:secretB[].

reduc

(* attacker *)
c:encrypt(m,k) & c:k -> c:m;
c:x & c:y -> c:encrypt(x,y);
c:x -> c:host(x);


c:host(shrA[]);
c:host(shrB[]);

(* A *)

c:X -> c:(Na[X],host(shrA[]),X, encrypt((Na[X], host(shrA[]), X), shrA[]));

c:(Na[host(shrB[])], encrypt((Na[host(shrB[])],key), shrA[])) -> c:encrypt(secretA[], key);

(* B *)

c:(x,y,host(shrB[]),z) -> c:(x,y,host(shrB[]),z, encrypt((x,Nb[y],y,host(shrB[])), shrB[]));

c:(x,y,host(shrB[]),z) & c:(x,y2,encrypt((Nb[y], key), shrB[])) -> c:(x,y2);

c:(x,host(shrA[]),host(shrB[]),z) & c:(x,y2,encrypt((Nb[host(shrA[])],key), shrB[])) -> c:encrypt(secretB[], key);

(* Server *)

c:(na,host(shra), host(shrb), encrypt((na, host(shra), host(shrb)), shra),
   encrypt((na,nb,host(shra),host(shrb)), shrb)) ->
c:(na,encrypt((na, k[x,shra,shrb]), shra),encrypt((nb,k[x,shra,shrb]), shrb)).

