(*************************************************************
 *                                                           *
 *  Cryptographic protocol verifier                          *
 *                                                           *
 *  Bruno Blanchet, Vincent Cheval, and Marc Sylvestre       *
 *                                                           *
 *  Copyright (C) INRIA, CNRS 2000-2020                      *
 *                                                           *
 *************************************************************)

(*

    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.
   Correct version, from Millen, Ruess, 
   2000 IEEE Symposium on Security and Privacy *)

pred c/1 decompData, elimVar.

fun shr/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:A[];
c:B[];
c:C[];
c:shr(C[]);

(* A *)

c:X -> c:(N[X],A[],X, encrypt((Na[X], N[X], A[], X), shr(A[])));

c:(N[B[]], encrypt((Na[B[]],key), shr(A[]))) -> c:encrypt(secretA[], key);

(* B *)

c:(x,y,B[],z) -> c:(x,y,B[],z,encrypt((Nb[y],x,y,B[]), shr(B[])));

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

c:(x,A[],B[],z) & c:(x,y2,encrypt((Nb[A[]],key), shr(B[]))) -> 
c:encrypt(secretB[], key);

(* Server *)

c:(x,a,b, encrypt((na, x,a,b), shr(a)), encrypt((nb,x,a,b), shr(b))) ->
c:(x,encrypt((na, k[x,a,b]), shr(a)),
     encrypt((nb, k[x,a,b]), shr(b))).

