src/HOL/Auth/OtwayRees.ML
author paulson
Mon Oct 28 15:59:39 1996 +0100 (1996-10-28)
changeset 2135 80477862ab33
parent 2134 04a71407089d
child 2160 ad4382e546fc
permissions -rw-r--r--
Minor corrections
paulson@1941
     1
(*  Title:      HOL/Auth/OtwayRees
paulson@1941
     2
    ID:         $Id$
paulson@1941
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@1941
     4
    Copyright   1996  University of Cambridge
paulson@1941
     5
paulson@1941
     6
Inductive relation "otway" for the Otway-Rees protocol.
paulson@1941
     7
paulson@2014
     8
Version that encrypts Nonce NB
paulson@2014
     9
paulson@1941
    10
From page 244 of
paulson@1941
    11
  Burrows, Abadi and Needham.  A Logic of Authentication.
paulson@1941
    12
  Proc. Royal Soc. 426 (1989)
paulson@1941
    13
*)
paulson@1941
    14
paulson@1941
    15
open OtwayRees;
paulson@1941
    16
paulson@1941
    17
proof_timing:=true;
paulson@1941
    18
HOL_quantifiers := false;
paulson@2135
    19
Pretty.setdepth 15;
paulson@1941
    20
paulson@1996
    21
paulson@2014
    22
(*Weak liveness: there are traces that reach the end*)
paulson@1996
    23
goal thy 
paulson@1996
    24
 "!!A B. [| A ~= B; A ~= Server; B ~= Server |]   \
paulson@2032
    25
\        ==> EX K. EX NA. EX evs: otway lost.          \
paulson@2014
    26
\               Says B A {|Nonce NA, Crypt {|Nonce NA, Key K|} (shrK A)|} \
paulson@2014
    27
\                 : set_of_list evs";
paulson@1996
    28
by (REPEAT (resolve_tac [exI,bexI] 1));
paulson@2032
    29
by (rtac (otway.Nil RS otway.OR1 RS otway.OR2 RS otway.OR3 RS otway.OR4) 2);
paulson@1996
    30
by (ALLGOALS (simp_tac (!simpset setsolver safe_solver)));
paulson@1996
    31
by (REPEAT_FIRST (resolve_tac [refl, conjI]));
paulson@2104
    32
by (REPEAT_FIRST (fast_tac (!claset addss (!simpset setsolver safe_solver))));
paulson@2014
    33
result();
paulson@1996
    34
paulson@1996
    35
paulson@1941
    36
(**** Inductive proofs about otway ****)
paulson@1941
    37
paulson@2104
    38
(*Monotonicity*)
paulson@2032
    39
goal thy "!!evs. lost' <= lost ==> otway lost' <= otway lost";
paulson@2032
    40
by (rtac subsetI 1);
paulson@2032
    41
by (etac otway.induct 1);
paulson@2032
    42
by (REPEAT_FIRST
paulson@2032
    43
    (best_tac (!claset addIs (impOfSubs (sees_mono RS analz_mono RS synth_mono)
paulson@2032
    44
                              :: otway.intrs))));
paulson@2032
    45
qed "otway_mono";
paulson@2032
    46
paulson@1941
    47
(*Nobody sends themselves messages*)
paulson@2032
    48
goal thy "!!evs. evs : otway lost ==> ALL A X. Says A A X ~: set_of_list evs";
paulson@2032
    49
by (etac otway.induct 1);
paulson@1941
    50
by (Auto_tac());
paulson@1941
    51
qed_spec_mp "not_Says_to_self";
paulson@1941
    52
Addsimps [not_Says_to_self];
paulson@1941
    53
AddSEs   [not_Says_to_self RSN (2, rev_notE)];
paulson@1941
    54
paulson@1941
    55
paulson@1941
    56
(** For reasoning about the encrypted portion of messages **)
paulson@1941
    57
paulson@2135
    58
goal thy "!!evs. Says A' B {|N, Agent A, Agent B, X|} : set_of_list evs \
paulson@2135
    59
\                ==> X : analz (sees lost Spy evs)";
paulson@2032
    60
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS analz.Inj]) 1);
paulson@2032
    61
qed "OR2_analz_sees_Spy";
paulson@1941
    62
paulson@2135
    63
goal thy "!!evs. Says S B {|N, X, X'|} : set_of_list evs \
paulson@2135
    64
\                ==> X : analz (sees lost Spy evs)";
paulson@2032
    65
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS analz.Inj]) 1);
paulson@2032
    66
qed "OR4_analz_sees_Spy";
paulson@1941
    67
paulson@2135
    68
goal thy "!!evs. Says Server B {|NA, X, Crypt {|NB,K|} K'|} : set_of_list evs \
paulson@2135
    69
\                 ==> K : parts (sees lost Spy evs)";
paulson@1941
    70
by (fast_tac (!claset addSEs partsEs
paulson@2032
    71
                      addSDs [Says_imp_sees_Spy RS parts.Inj]) 1);
paulson@2135
    72
qed "Oops_parts_sees_Spy";
paulson@1941
    73
paulson@1941
    74
(*OR2_analz... and OR4_analz... let us treat those cases using the same 
paulson@1964
    75
  argument as for the Fake case.  This is possible for most, but not all,
paulson@1964
    76
  proofs: Fake does not invent new nonces (as in OR2), and of course Fake
paulson@2032
    77
  messages originate from the Spy. *)
paulson@1964
    78
paulson@2032
    79
bind_thm ("OR2_parts_sees_Spy",
paulson@2032
    80
          OR2_analz_sees_Spy RS (impOfSubs analz_subset_parts));
paulson@2032
    81
bind_thm ("OR4_parts_sees_Spy",
paulson@2032
    82
          OR4_analz_sees_Spy RS (impOfSubs analz_subset_parts));
paulson@2032
    83
paulson@2032
    84
(*We instantiate the variable to "lost".  Leaving it as a Var makes proofs
paulson@2032
    85
  harder to complete, since simplification does less for us.*)
paulson@2014
    86
val parts_Fake_tac = 
paulson@2032
    87
    let val tac = forw_inst_tac [("lost","lost")] 
paulson@2032
    88
    in  tac OR2_parts_sees_Spy 4 THEN 
paulson@2032
    89
        tac OR4_parts_sees_Spy 6 THEN
paulson@2135
    90
        tac Oops_parts_sees_Spy 7
paulson@2032
    91
    end;
paulson@1941
    92
paulson@2064
    93
(*For proving the easier theorems about X ~: parts (sees lost Spy evs) *)
paulson@2064
    94
fun parts_induct_tac i = SELECT_GOAL
paulson@2064
    95
    (DETERM (etac otway.induct 1 THEN parts_Fake_tac THEN
paulson@2064
    96
	     (*Fake message*)
paulson@2064
    97
	     TRY (best_tac (!claset addDs [impOfSubs analz_subset_parts,
paulson@2064
    98
					   impOfSubs Fake_parts_insert]
paulson@2064
    99
                                    addss (!simpset)) 2)) THEN
paulson@2064
   100
     (*Base case*)
paulson@2064
   101
     fast_tac (!claset addss (!simpset)) 1 THEN
paulson@2064
   102
     ALLGOALS Asm_simp_tac) i;
paulson@1941
   103
paulson@2032
   104
(** Theorems of the form X ~: parts (sees lost Spy evs) imply that NOBODY
paulson@2014
   105
    sends messages containing X! **)
paulson@1941
   106
paulson@2064
   107
(*Spy never sees another agent's shared key! (unless it's lost at start)*)
paulson@1941
   108
goal thy 
paulson@2135
   109
 "!!evs. evs : otway lost \
paulson@2135
   110
\        ==> (Key (shrK A) : parts (sees lost Spy evs)) = (A : lost)";
paulson@2064
   111
by (parts_induct_tac 1);
paulson@1941
   112
by (Auto_tac());
paulson@2135
   113
qed "Spy_see_shrK";
paulson@2135
   114
Addsimps [Spy_see_shrK];
paulson@1941
   115
paulson@2135
   116
goal thy 
paulson@2135
   117
 "!!evs. evs : otway lost \
paulson@2135
   118
\        ==> (Key (shrK A) : analz (sees lost Spy evs)) = (A : lost)";
paulson@2135
   119
by (auto_tac(!claset addDs [impOfSubs analz_subset_parts], !simpset));
paulson@2135
   120
qed "Spy_analz_shrK";
paulson@2135
   121
Addsimps [Spy_analz_shrK];
paulson@1941
   122
paulson@2135
   123
goal thy  "!!A. [| Key (shrK A) : parts (sees lost Spy evs);       \
paulson@2135
   124
\                  evs : otway lost |] ==> A:lost";
paulson@2135
   125
by (fast_tac (!claset addDs [Spy_see_shrK]) 1);
paulson@2135
   126
qed "Spy_see_shrK_D";
paulson@1941
   127
paulson@2135
   128
bind_thm ("Spy_analz_shrK_D", analz_subset_parts RS subsetD RS Spy_see_shrK_D);
paulson@2135
   129
AddSDs [Spy_see_shrK_D, Spy_analz_shrK_D];
paulson@1941
   130
paulson@1941
   131
paulson@1941
   132
(*** Future keys can't be seen or used! ***)
paulson@1941
   133
paulson@1941
   134
(*Nobody can have SEEN keys that will be generated in the future.
paulson@1941
   135
  This has to be proved anew for each protocol description,
paulson@1941
   136
  but should go by similar reasoning every time.  Hardest case is the
paulson@1941
   137
  standard Fake rule.  
paulson@2014
   138
      The Union over C is essential for the induction! *)
paulson@2032
   139
goal thy "!!evs. evs : otway lost ==> \
paulson@1941
   140
\                length evs <= length evs' --> \
paulson@2032
   141
\                          Key (newK evs') ~: (UN C. parts (sees lost C evs))";
paulson@2064
   142
by (parts_induct_tac 1);
paulson@1941
   143
by (REPEAT_FIRST (best_tac (!claset addDs [impOfSubs analz_subset_parts,
paulson@2032
   144
                                           impOfSubs parts_insert_subset_Un,
paulson@2032
   145
                                           Suc_leD]
paulson@2032
   146
                                    addss (!simpset))));
paulson@1941
   147
val lemma = result();
paulson@1941
   148
paulson@1941
   149
(*Variant needed for the main theorem below*)
paulson@1941
   150
goal thy 
paulson@2032
   151
 "!!evs. [| evs : otway lost;  length evs <= length evs' |]    \
paulson@2032
   152
\        ==> Key (newK evs') ~: parts (sees lost C evs)";
paulson@1941
   153
by (fast_tac (!claset addDs [lemma]) 1);
paulson@1941
   154
qed "new_keys_not_seen";
paulson@1941
   155
Addsimps [new_keys_not_seen];
paulson@1941
   156
paulson@1941
   157
(*Another variant: old messages must contain old keys!*)
paulson@1941
   158
goal thy 
paulson@1941
   159
 "!!evs. [| Says A B X : set_of_list evs;  \
paulson@1941
   160
\           Key (newK evt) : parts {X};    \
paulson@2032
   161
\           evs : otway lost                 \
paulson@1941
   162
\        |] ==> length evt < length evs";
paulson@2032
   163
by (rtac ccontr 1);
paulson@2032
   164
by (dtac leI 1);
paulson@2032
   165
by (fast_tac (!claset addSDs [new_keys_not_seen, Says_imp_sees_Spy]
paulson@2014
   166
                      addIs  [impOfSubs parts_mono]) 1);
paulson@1941
   167
qed "Says_imp_old_keys";
paulson@1941
   168
paulson@1941
   169
paulson@2014
   170
(*** Future nonces can't be seen or used! [proofs resemble those above] ***)
paulson@2014
   171
paulson@2032
   172
goal thy "!!evs. evs : otway lost ==> \
paulson@2014
   173
\                length evs <= length evt --> \
paulson@2032
   174
\                Nonce (newN evt) ~: (UN C. parts (sees lost C evs))";
paulson@2032
   175
by (etac otway.induct 1);
paulson@2014
   176
(*auto_tac does not work here, as it performs safe_tac first*)
paulson@2032
   177
by (ALLGOALS (asm_simp_tac (!simpset addsimps [parts_insert2]
paulson@2014
   178
                                     addcongs [disj_cong])));
paulson@2014
   179
by (REPEAT_FIRST (fast_tac (!claset 
paulson@2032
   180
                              addSEs partsEs
paulson@2032
   181
                              addSDs  [Says_imp_sees_Spy RS parts.Inj]
paulson@2032
   182
                              addDs  [impOfSubs analz_subset_parts,
paulson@2032
   183
                                      impOfSubs parts_insert_subset_Un,
paulson@2032
   184
                                      Suc_leD]
paulson@2032
   185
                              addss (!simpset))));
paulson@2014
   186
val lemma = result();
paulson@2014
   187
paulson@2014
   188
(*Variant needed for the main theorem below*)
paulson@2014
   189
goal thy 
paulson@2032
   190
 "!!evs. [| evs : otway lost;  length evs <= length evs' |]    \
paulson@2032
   191
\        ==> Nonce (newN evs') ~: parts (sees lost C evs)";
paulson@2014
   192
by (fast_tac (!claset addDs [lemma]) 1);
paulson@2014
   193
qed "new_nonces_not_seen";
paulson@2014
   194
Addsimps [new_nonces_not_seen];
paulson@2014
   195
paulson@2014
   196
(*Another variant: old messages must contain old nonces!*)
paulson@2014
   197
goal thy 
paulson@2014
   198
 "!!evs. [| Says A B X : set_of_list evs;  \
paulson@2014
   199
\           Nonce (newN evt) : parts {X};    \
paulson@2032
   200
\           evs : otway lost                 \
paulson@2014
   201
\        |] ==> length evt < length evs";
paulson@2032
   202
by (rtac ccontr 1);
paulson@2032
   203
by (dtac leI 1);
paulson@2032
   204
by (fast_tac (!claset addSDs [new_nonces_not_seen, Says_imp_sees_Spy]
paulson@2032
   205
                      addIs  [impOfSubs parts_mono]) 1);
paulson@2014
   206
qed "Says_imp_old_nonces";
paulson@2014
   207
paulson@2014
   208
paulson@1941
   209
(*Nobody can have USED keys that will be generated in the future.
paulson@1941
   210
  ...very like new_keys_not_seen*)
paulson@2032
   211
goal thy "!!evs. evs : otway lost ==> \
paulson@1941
   212
\                length evs <= length evs' --> \
paulson@2032
   213
\                newK evs' ~: keysFor (UN C. parts (sees lost C evs))";
paulson@2064
   214
by (parts_induct_tac 1);
paulson@1941
   215
(*OR1 and OR3*)
paulson@1941
   216
by (EVERY (map (fast_tac (!claset addDs [Suc_leD] addss (!simpset))) [4,2]));
paulson@1941
   217
(*Fake, OR2, OR4: these messages send unknown (X) components*)
paulson@2104
   218
by (REPEAT
paulson@2104
   219
    (best_tac
paulson@1996
   220
      (!claset addDs [impOfSubs (analz_subset_parts RS keysFor_mono),
paulson@2032
   221
                      impOfSubs (parts_insert_subset_Un RS keysFor_mono),
paulson@2032
   222
                      Suc_leD]
paulson@2032
   223
               addEs [new_keys_not_seen RS not_parts_not_analz RSN(2,rev_notE)]
paulson@2104
   224
               addss (!simpset)) 1));
paulson@1941
   225
val lemma = result();
paulson@1941
   226
paulson@1941
   227
goal thy 
paulson@2032
   228
 "!!evs. [| evs : otway lost;  length evs <= length evs' |]    \
paulson@2032
   229
\        ==> newK evs' ~: keysFor (parts (sees lost C evs))";
paulson@1941
   230
by (fast_tac (!claset addSDs [lemma] addss (!simpset)) 1);
paulson@1941
   231
qed "new_keys_not_used";
paulson@1941
   232
paulson@1941
   233
bind_thm ("new_keys_not_analzd",
paulson@2032
   234
          [analz_subset_parts RS keysFor_mono,
paulson@2032
   235
           new_keys_not_used] MRS contra_subsetD);
paulson@1941
   236
paulson@1941
   237
Addsimps [new_keys_not_used, new_keys_not_analzd];
paulson@1941
   238
paulson@1941
   239
paulson@2064
   240
paulson@2064
   241
(*** Proofs involving analz ***)
paulson@2064
   242
paulson@2135
   243
(*Describes the form of K and NA when the Server sends this message.  Also
paulson@2135
   244
  for Oops case.*)
paulson@2064
   245
goal thy 
paulson@2135
   246
 "!!evs. [| Says Server B \
paulson@2135
   247
\            {|NA, X, Crypt {|NB, K|} (shrK B)|} : set_of_list evs;  \
paulson@2135
   248
\           evs : otway lost |]                                   \
paulson@2135
   249
\        ==> (EX evt: otway lost. K = Key(newK evt)) &            \
paulson@2135
   250
\            (EX i. NA = Nonce i) & (EX j. NB = Nonce j)";
paulson@2135
   251
by (etac rev_mp 1);
paulson@2135
   252
by (etac otway.induct 1);
paulson@2135
   253
by (ALLGOALS (fast_tac (!claset addss (!simpset))));
paulson@2135
   254
qed "Says_Server_message_form";
paulson@2064
   255
paulson@2064
   256
paulson@2064
   257
(*For proofs involving analz.  We again instantiate the variable to "lost".*)
paulson@2064
   258
val analz_Fake_tac = 
paulson@2064
   259
    dres_inst_tac [("lost","lost")] OR2_analz_sees_Spy 4 THEN 
paulson@2064
   260
    dres_inst_tac [("lost","lost")] OR4_analz_sees_Spy 6 THEN
paulson@2135
   261
    forw_inst_tac [("lost","lost")] Says_Server_message_form 7 THEN
paulson@2135
   262
    assume_tac 7 THEN Full_simp_tac 7 THEN
paulson@2135
   263
    REPEAT ((eresolve_tac [bexE, exE, conjE] ORELSE' hyp_subst_tac) 7);
paulson@1941
   264
paulson@1941
   265
paulson@1941
   266
(****
paulson@1941
   267
 The following is to prove theorems of the form
paulson@1941
   268
paulson@2032
   269
          Key K : analz (insert (Key (newK evt)) (sees lost Spy evs)) ==>
paulson@2032
   270
          Key K : analz (sees lost Spy evs)
paulson@1941
   271
paulson@1941
   272
 A more general formula must be proved inductively.
paulson@1941
   273
****)
paulson@1941
   274
paulson@1941
   275
paulson@1941
   276
(** Session keys are not used to encrypt other session keys **)
paulson@1941
   277
paulson@2014
   278
(*The equality makes the induction hypothesis easier to apply*)
paulson@1941
   279
goal thy  
paulson@2032
   280
 "!!evs. evs : otway lost ==> \
paulson@2032
   281
\  ALL K E. (Key K : analz (Key``(newK``E) Un (sees lost Spy evs))) = \
paulson@2032
   282
\           (K : newK``E | Key K : analz (sees lost Spy evs))";
paulson@2032
   283
by (etac otway.induct 1);
paulson@2064
   284
by analz_Fake_tac;
paulson@2045
   285
by (REPEAT_FIRST (ares_tac [allI, analz_image_newK_lemma]));
paulson@2135
   286
by (ALLGOALS (*Takes 22 secs*)
paulson@1941
   287
    (asm_simp_tac 
paulson@1941
   288
     (!simpset addsimps ([insert_Key_singleton, insert_Key_image, pushKey_newK]
paulson@2032
   289
                         @ pushes)
paulson@1941
   290
               setloop split_tac [expand_if])));
paulson@2104
   291
(** LEVEL 5 **)
paulson@2135
   292
(*OR4, OR2, Fake*) 
paulson@2135
   293
by (EVERY (map spy_analz_tac [5,3,2]));
paulson@2135
   294
(*Oops, OR3, Base*)
paulson@2064
   295
by (REPEAT (fast_tac (!claset addIs [image_eqI] addss (!simpset)) 1));
paulson@1941
   296
qed_spec_mp "analz_image_newK";
paulson@1941
   297
paulson@1941
   298
paulson@1941
   299
goal thy
paulson@2032
   300
 "!!evs. evs : otway lost ==>                               \
paulson@2032
   301
\        Key K : analz (insert (Key (newK evt)) (sees lost Spy evs)) = \
paulson@2032
   302
\        (K = newK evt | Key K : analz (sees lost Spy evs))";
paulson@1941
   303
by (asm_simp_tac (HOL_ss addsimps [pushKey_newK, analz_image_newK, 
paulson@2032
   304
                                   insert_Key_singleton]) 1);
paulson@1941
   305
by (Fast_tac 1);
paulson@1941
   306
qed "analz_insert_Key_newK";
paulson@1941
   307
paulson@1941
   308
paulson@2026
   309
(*** The Key K uniquely identifies the Server's  message. **)
paulson@2014
   310
paulson@2014
   311
goal thy 
paulson@2135
   312
 "!!evs. evs : otway lost ==>                                                 \
paulson@2135
   313
\   EX B' NA' NB' X'. ALL B NA NB X.                                          \
paulson@2135
   314
\     Says Server B {|NA, X, Crypt {|NB, K|} (shrK B)|} : set_of_list evs --> \
paulson@2135
   315
\     B=B' & NA=NA' & NB=NB' & X=X'";
paulson@2032
   316
by (etac otway.induct 1);
paulson@2014
   317
by (ALLGOALS (asm_simp_tac (!simpset addsimps [all_conj_distrib])));
paulson@2014
   318
by (Step_tac 1);
paulson@2014
   319
(*Remaining cases: OR3 and OR4*)
paulson@2014
   320
by (ex_strip_tac 2);
paulson@2014
   321
by (Fast_tac 2);
paulson@2064
   322
by (expand_case_tac "K = ?y" 1);
paulson@2064
   323
by (REPEAT (ares_tac [refl,exI,impI,conjI] 2));
paulson@2014
   324
(*...we assume X is a very new message, and handle this case by contradiction*)
paulson@2014
   325
by (fast_tac (!claset addEs [Says_imp_old_keys RS less_irrefl]
paulson@2032
   326
                      delrules [conjI]    (*prevent split-up into 4 subgoals*)
paulson@2032
   327
                      addss (!simpset addsimps [parts_insertI])) 1);
paulson@2014
   328
val lemma = result();
paulson@2014
   329
paulson@2014
   330
goal thy 
paulson@2135
   331
 "!!evs. [| Says Server B {|NA, X, Crypt {|NB, K|} (shrK B)|}      \
paulson@2014
   332
\            : set_of_list evs;                                    \ 
paulson@2135
   333
\           Says Server B' {|NA',X',Crypt {|NB',K|} (shrK B')|}    \
paulson@2014
   334
\            : set_of_list evs;                                    \
paulson@2135
   335
\           evs : otway lost |] ==> X=X' & B=B' & NA=NA' & NB=NB'";
paulson@2032
   336
by (dtac lemma 1);
paulson@2014
   337
by (REPEAT (etac exE 1));
paulson@2014
   338
(*Duplicate the assumption*)
paulson@2014
   339
by (forw_inst_tac [("psi", "ALL C.?P(C)")] asm_rl 1);
paulson@2014
   340
by (fast_tac (!claset addSDs [spec]) 1);
paulson@2014
   341
qed "unique_session_keys";
paulson@2014
   342
paulson@2014
   343
paulson@2014
   344
paulson@2048
   345
(**** Authenticity properties relating to NA ****)
paulson@2014
   346
paulson@2014
   347
(*Only OR1 can have caused such a part of a message to appear.*)
paulson@2014
   348
goal thy 
paulson@2064
   349
 "!!evs. [| A ~: lost;  evs : otway lost |]                        \
paulson@2064
   350
\        ==> Crypt {|NA, Agent A, Agent B|} (shrK A)               \
paulson@2064
   351
\             : parts (sees lost Spy evs) -->                      \
paulson@2064
   352
\            Says A B {|NA, Agent A, Agent B,                      \
paulson@2014
   353
\                       Crypt {|NA, Agent A, Agent B|} (shrK A)|}  \
paulson@2014
   354
\             : set_of_list evs";
paulson@2064
   355
by (parts_induct_tac 1);
paulson@2014
   356
qed_spec_mp "Crypt_imp_OR1";
paulson@2014
   357
paulson@2014
   358
paulson@2064
   359
(** The Nonce NA uniquely identifies A's message. **)
paulson@2014
   360
paulson@2014
   361
goal thy 
paulson@2032
   362
 "!!evs. [| evs : otway lost; A ~: lost |]               \
paulson@2014
   363
\ ==> EX B'. ALL B.    \
paulson@2048
   364
\        Crypt {|NA, Agent A, Agent B|} (shrK A) : parts (sees lost Spy evs) \
paulson@2048
   365
\        --> B = B'";
paulson@2064
   366
by (parts_induct_tac 1);
paulson@2064
   367
by (simp_tac (!simpset addsimps [all_conj_distrib]) 1); 
paulson@2026
   368
(*OR1: creation of new Nonce.  Move assertion into global context*)
paulson@2064
   369
by (expand_case_tac "NA = ?y" 1);
paulson@2014
   370
by (best_tac (!claset addSEs partsEs
paulson@2032
   371
                      addEs  [new_nonces_not_seen RSN(2,rev_notE)]) 1);
paulson@2014
   372
val lemma = result();
paulson@2014
   373
paulson@2014
   374
goal thy 
paulson@2048
   375
 "!!evs.[| Crypt {|NA, Agent A, Agent B|} (shrK A): parts(sees lost Spy evs); \
paulson@2048
   376
\          Crypt {|NA, Agent A, Agent C|} (shrK A): parts(sees lost Spy evs); \
paulson@2048
   377
\          evs : otway lost;  A ~: lost |]                                    \
paulson@2014
   378
\        ==> B = C";
paulson@2032
   379
by (dtac lemma 1);
paulson@2032
   380
by (assume_tac 1);
paulson@2014
   381
by (etac exE 1);
paulson@2014
   382
(*Duplicate the assumption*)
paulson@2014
   383
by (forw_inst_tac [("psi", "ALL C.?P(C)")] asm_rl 1);
paulson@2014
   384
by (fast_tac (!claset addSDs [spec]) 1);
paulson@2048
   385
qed "unique_NA";
paulson@2014
   386
paulson@2014
   387
paulson@2014
   388
val nonce_not_seen_now = le_refl RSN (2, new_nonces_not_seen) RSN (2,rev_notE);
paulson@2014
   389
paulson@2014
   390
(*It is impossible to re-use a nonce in both OR1 and OR2.  This holds because
paulson@2014
   391
  OR2 encrypts Nonce NB.  It prevents the attack that can occur in the
paulson@2014
   392
  over-simplified version of this protocol: see OtwayRees_Bad.*)
paulson@2014
   393
goal thy 
paulson@2032
   394
 "!!evs. [| A ~: lost;  evs : otway lost |]                            \
paulson@2014
   395
\        ==> Crypt {|NA, Agent A, Agent B|} (shrK A)             \
paulson@2032
   396
\             : parts (sees lost Spy evs) -->                       \
paulson@2014
   397
\            Crypt {|NA', NA, Agent A', Agent A|} (shrK A)       \
paulson@2032
   398
\             ~: parts (sees lost Spy evs)";
paulson@2071
   399
by (parts_induct_tac 1);
paulson@2071
   400
by (REPEAT (fast_tac (!claset addSEs (partsEs@[nonce_not_seen_now])
paulson@2026
   401
                              addSDs  [impOfSubs parts_insert_subset_Un]
paulson@2071
   402
                              addss (!simpset)) 1));
paulson@2014
   403
qed_spec_mp"no_nonce_OR1_OR2";
paulson@2014
   404
paulson@2014
   405
paulson@2053
   406
(*Crucial property: If the encrypted message appears, and A has used NA
paulson@2053
   407
  to start a run, then it originated with the Server!*)
paulson@2014
   408
goal thy 
paulson@2048
   409
 "!!evs. [| A ~: lost;  A ~= Spy;  evs : otway lost |]                 \
paulson@2048
   410
\    ==> Crypt {|NA, Key K|} (shrK A) : parts (sees lost Spy evs)      \
paulson@2048
   411
\        --> Says A B {|NA, Agent A, Agent B,                          \
paulson@2048
   412
\                       Crypt {|NA, Agent A, Agent B|} (shrK A)|}      \
paulson@2048
   413
\             : set_of_list evs -->                                    \
paulson@2048
   414
\            (EX NB. Says Server B                                     \
paulson@2048
   415
\                 {|NA,                                                \
paulson@2048
   416
\                   Crypt {|NA, Key K|} (shrK A),                      \
paulson@2048
   417
\                   Crypt {|NB, Key K|} (shrK B)|}                     \
paulson@2014
   418
\                   : set_of_list evs)";
paulson@2064
   419
by (parts_induct_tac 1);
paulson@2014
   420
(*OR1: it cannot be a new Nonce, contradiction.*)
paulson@2014
   421
by (fast_tac (!claset addSIs [parts_insertI]
paulson@2032
   422
                      addSEs partsEs
paulson@2032
   423
                      addEs [Says_imp_old_nonces RS less_irrefl]
paulson@2032
   424
                      addss (!simpset)) 1);
paulson@2064
   425
(*OR3 and OR4*) 
paulson@2014
   426
(*OR4*)
paulson@2014
   427
by (REPEAT (Safe_step_tac 2));
paulson@2014
   428
by (REPEAT (best_tac (!claset addSDs [parts_cut]) 3));
paulson@2014
   429
by (fast_tac (!claset addSIs [Crypt_imp_OR1]
paulson@2032
   430
                      addEs  partsEs
paulson@2032
   431
                      addDs [Says_imp_sees_Spy RS parts.Inj]) 2);
paulson@2064
   432
(*OR3*)  (** LEVEL 5 **)
paulson@2064
   433
by (asm_simp_tac (!simpset addsimps [ex_disj_distrib]) 1);
paulson@2014
   434
by (step_tac (!claset delrules [disjCI, impCE]) 1);
paulson@2014
   435
by (fast_tac (!claset addSEs [MPair_parts]
paulson@2032
   436
                      addSDs [Says_imp_sees_Spy RS parts.Inj]
paulson@2014
   437
                      addEs  [no_nonce_OR1_OR2 RSN (2, rev_notE)]
paulson@2048
   438
                      delrules [conjI] (*stop split-up into 4 subgoals*)) 2);
paulson@2048
   439
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS parts.Inj]
paulson@2048
   440
                      addSEs [MPair_parts]
paulson@2048
   441
                      addEs  [unique_NA]) 1);
paulson@2048
   442
qed_spec_mp "NA_Crypt_imp_Server_msg";
paulson@2014
   443
paulson@2014
   444
paulson@2053
   445
(*Corollary: if A receives B's OR4 message and the nonce NA agrees
paulson@2014
   446
  then the key really did come from the Server!  CANNOT prove this of the
paulson@2048
   447
  bad form of this protocol, even though we can prove
paulson@2032
   448
  Spy_not_see_encrypted_key*)
paulson@2014
   449
goal thy 
paulson@2053
   450
 "!!evs. [| Says B' A {|NA, Crypt {|NA, Key K|} (shrK A)|}         \
paulson@2053
   451
\            : set_of_list evs;                                    \
paulson@2053
   452
\           Says A B {|NA, Agent A, Agent B,                       \
paulson@2053
   453
\                      Crypt {|NA, Agent A, Agent B|} (shrK A)|}   \
paulson@2053
   454
\            : set_of_list evs;                                    \
paulson@2053
   455
\           A ~: lost;  A ~= Spy;  evs : otway lost |]             \
paulson@2053
   456
\        ==> EX NB. Says Server B                                  \
paulson@2048
   457
\                     {|NA,                                        \
paulson@2048
   458
\                       Crypt {|NA, Key K|} (shrK A),              \
paulson@2048
   459
\                       Crypt {|NB, Key K|} (shrK B)|}             \
paulson@2053
   460
\                       : set_of_list evs";
paulson@2048
   461
by (fast_tac (!claset addSIs [NA_Crypt_imp_Server_msg]
paulson@2032
   462
                      addEs  partsEs
paulson@2032
   463
                      addDs  [Says_imp_sees_Spy RS parts.Inj]) 1);
paulson@2064
   464
qed "A_trust_OR4";
paulson@2014
   465
paulson@2014
   466
paulson@2048
   467
(** Crucial secrecy property: Spy does not see the keys sent in msg OR3
paulson@2048
   468
    Does not in itself guarantee security: an attack could violate 
paulson@2048
   469
    the premises, e.g. by having A=Spy **)
paulson@2014
   470
paulson@1941
   471
goal thy 
paulson@2032
   472
 "!!evs. [| A ~: lost;  B ~: lost;  evs : otway lost;  evt : otway lost |] \
paulson@2048
   473
\        ==> Says Server B                                                 \
paulson@2048
   474
\              {|NA, Crypt {|NA, Key K|} (shrK A),                         \
paulson@2048
   475
\                Crypt {|NB, Key K|} (shrK B)|} : set_of_list evs -->      \
paulson@2135
   476
\            Says B Spy {|NA, NB, Key K|} ~: set_of_list evs -->           \
paulson@2048
   477
\            Key K ~: analz (sees lost Spy evs)";
paulson@2032
   478
by (etac otway.induct 1);
paulson@2064
   479
by analz_Fake_tac;
paulson@1964
   480
by (ALLGOALS
paulson@1941
   481
    (asm_full_simp_tac 
paulson@1941
   482
     (!simpset addsimps ([analz_subset_parts RS contra_subsetD,
paulson@2032
   483
                          analz_insert_Key_newK] @ pushes)
paulson@1941
   484
               setloop split_tac [expand_if])));
paulson@1941
   485
(*OR3*)
paulson@2014
   486
by (fast_tac (!claset addSIs [parts_insertI]
paulson@2032
   487
                      addEs [Says_imp_old_keys RS less_irrefl]
paulson@2048
   488
                      addss (!simpset addsimps [parts_insert2])) 3);
paulson@2135
   489
(*OR4, OR2, Fake*) 
paulson@2032
   490
by (REPEAT_FIRST (resolve_tac [conjI, impI] ORELSE' spy_analz_tac));
paulson@2135
   491
(*Oops*) (** LEVEL 5 **)
paulson@2135
   492
by (fast_tac (!claset delrules [disjE]
paulson@2135
   493
		      addDs [unique_session_keys] addss (!simpset)) 1);
paulson@2014
   494
val lemma = result() RS mp RS mp RSN(2,rev_notE);
paulson@2014
   495
paulson@2014
   496
goal thy 
paulson@2014
   497
 "!!evs. [| Says Server B \
paulson@2048
   498
\            {|NA, Crypt {|NA, K|} (shrK A),                             \
paulson@2048
   499
\                  Crypt {|NB, K|} (shrK B)|} : set_of_list evs;         \
paulson@2135
   500
\           Says B Spy {|NA, NB, K|} ~: set_of_list evs;                 \
paulson@2032
   501
\           A ~: lost;  B ~: lost;  evs : otway lost |]                  \
paulson@2032
   502
\        ==> K ~: analz (sees lost Spy evs)";
paulson@2014
   503
by (forward_tac [Says_Server_message_form] 1 THEN assume_tac 1);
paulson@2014
   504
by (fast_tac (!claset addSEs [lemma]) 1);
paulson@2032
   505
qed "Spy_not_see_encrypted_key";
paulson@2032
   506
paulson@1945
   507
paulson@2032
   508
goal thy 
paulson@2048
   509
 "!!evs. [| C ~: {A,B,Server};                                           \
paulson@2048
   510
\           Says Server B                                                \
paulson@2048
   511
\            {|NA, Crypt {|NA, K|} (shrK A),                             \
paulson@2048
   512
\                  Crypt {|NB, K|} (shrK B)|} : set_of_list evs;         \
paulson@2135
   513
\           Says B Spy {|NA, NB, K|} ~: set_of_list evs;                 \
paulson@2032
   514
\           A ~: lost;  B ~: lost;  evs : otway lost |]                  \
paulson@2032
   515
\        ==> K ~: analz (sees lost C evs)";
paulson@2032
   516
by (rtac (subset_insertI RS sees_mono RS analz_mono RS contra_subsetD) 1);
paulson@2032
   517
by (rtac (sees_lost_agent_subset_sees_Spy RS analz_mono RS contra_subsetD) 1);
paulson@2032
   518
by (FIRSTGOAL (rtac Spy_not_see_encrypted_key));
paulson@2032
   519
by (REPEAT_FIRST (fast_tac (!claset addIs [otway_mono RS subsetD])));
paulson@2032
   520
qed "Agent_not_see_encrypted_key";
paulson@1945
   521
paulson@1945
   522
paulson@2048
   523
(**** Authenticity properties relating to NB ****)
paulson@2048
   524
paulson@2048
   525
(*Only OR2 can have caused such a part of a message to appear.  We do not
paulson@2048
   526
  know anything about X'.*)
paulson@2048
   527
goal thy 
paulson@2048
   528
 "!!evs. [| B ~: lost;  evs : otway lost |]                    \
paulson@2048
   529
\        ==> Crypt {|NA, NB, Agent A, Agent B|} (shrK B)       \
paulson@2048
   530
\             : parts (sees lost Spy evs) -->                  \
paulson@2048
   531
\            (EX X'. Says B Server                             \
paulson@2048
   532
\             {|NA, Agent A, Agent B, X',                      \
paulson@2048
   533
\               Crypt {|NA, NB, Agent A, Agent B|} (shrK B)|}  \
paulson@2048
   534
\             : set_of_list evs)";
paulson@2064
   535
by (parts_induct_tac 1);
paulson@2064
   536
by (auto_tac (!claset, !simpset addcongs [conj_cong]));
paulson@2048
   537
qed_spec_mp "Crypt_imp_OR2";
paulson@2048
   538
paulson@2048
   539
paulson@2048
   540
(** The Nonce NB uniquely identifies B's  message. **)
paulson@2048
   541
paulson@2048
   542
goal thy 
paulson@2048
   543
 "!!evs. [| evs : otway lost; B ~: lost |]               \
paulson@2064
   544
\ ==> EX NA' A'. ALL NA A.                               \
paulson@2048
   545
\      Crypt {|NA, NB, Agent A, Agent B|} (shrK B) : parts(sees lost Spy evs) \
paulson@2048
   546
\      --> NA = NA' & A = A'";
paulson@2064
   547
by (parts_induct_tac 1);
paulson@2064
   548
by (simp_tac (!simpset addsimps [all_conj_distrib]) 1); 
paulson@2048
   549
(*OR2: creation of new Nonce.  Move assertion into global context*)
paulson@2064
   550
by (expand_case_tac "NB = ?y" 1);
paulson@2048
   551
by (fast_tac (!claset addSEs (nonce_not_seen_now::partsEs)) 1);
paulson@2048
   552
val lemma = result();
paulson@2048
   553
paulson@2048
   554
goal thy 
paulson@2048
   555
 "!!evs.[| Crypt {|NA, NB, Agent A, Agent B|} (shrK B) \
paulson@2048
   556
\                  : parts(sees lost Spy evs);         \
paulson@2048
   557
\          Crypt {|NC, NB, Agent C, Agent B|} (shrK B) \
paulson@2048
   558
\                  : parts(sees lost Spy evs);         \
paulson@2048
   559
\          evs : otway lost;  B ~: lost |]             \
paulson@2048
   560
\        ==> NC = NA & C = A";
paulson@2048
   561
by (dtac lemma 1);
paulson@2048
   562
by (assume_tac 1);
paulson@2048
   563
by (REPEAT (etac exE 1));
paulson@2048
   564
(*Duplicate the assumption*)
paulson@2048
   565
by (forw_inst_tac [("psi", "ALL C.?P(C)")] asm_rl 1);
paulson@2048
   566
by (fast_tac (!claset addSDs [spec]) 1);
paulson@2048
   567
qed "unique_NB";
paulson@2048
   568
paulson@2048
   569
paulson@2048
   570
(*If the encrypted message appears, and B has used Nonce NB,
paulson@2048
   571
  then it originated with the Server!*)
paulson@2048
   572
goal thy 
paulson@2048
   573
 "!!evs. [| B ~: lost;  B ~= Spy;  evs : otway lost |]                   \
paulson@2048
   574
\    ==> Crypt {|NB, Key K|} (shrK B) : parts (sees lost Spy evs)        \
paulson@2048
   575
\        --> (ALL X'. Says B Server                                      \
paulson@2048
   576
\                       {|NA, Agent A, Agent B, X',                      \
paulson@2048
   577
\                         Crypt {|NA, NB, Agent A, Agent B|} (shrK B)|}  \
paulson@2048
   578
\             : set_of_list evs                                          \
paulson@2048
   579
\             --> Says Server B                                          \
paulson@2048
   580
\                  {|NA, Crypt {|NA, Key K|} (shrK A),                   \
paulson@2048
   581
\                        Crypt {|NB, Key K|} (shrK B)|}                  \
paulson@2048
   582
\                   : set_of_list evs)";
paulson@2064
   583
by (parts_induct_tac 1);
paulson@2048
   584
(*OR1: it cannot be a new Nonce, contradiction.*)
paulson@2048
   585
by (fast_tac (!claset addSIs [parts_insertI]
paulson@2048
   586
                      addSEs partsEs
paulson@2048
   587
                      addEs [Says_imp_old_nonces RS less_irrefl]
paulson@2048
   588
                      addss (!simpset)) 1);
paulson@2048
   589
(*OR3 and OR4*)  (** LEVEL 5 **)
paulson@2048
   590
(*OR4*)
paulson@2048
   591
by (REPEAT (Safe_step_tac 2));
paulson@2048
   592
br (Crypt_imp_OR2 RS exE) 2;
paulson@2048
   593
by (REPEAT (fast_tac (!claset addEs partsEs) 2));
paulson@2048
   594
(*OR3*)  (** LEVEL 8 **)
paulson@2048
   595
by (step_tac (!claset delrules [disjCI, impCE]) 1);
paulson@2048
   596
by (fast_tac (!claset delrules [conjI] (*stop split-up*)) 3); 
paulson@2048
   597
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS parts.Inj]
paulson@2048
   598
                      addSEs [MPair_parts]
paulson@2048
   599
                      addDs  [unique_NB]) 2);
paulson@2048
   600
by (fast_tac (!claset addSEs [MPair_parts]
paulson@2048
   601
                      addSDs [Says_imp_sees_Spy RS parts.Inj]
paulson@2048
   602
                      addSEs  [no_nonce_OR1_OR2 RSN (2, rev_notE)]
paulson@2048
   603
                      delrules [conjI, impCE] (*stop split-up*)) 1);
paulson@2048
   604
qed_spec_mp "NB_Crypt_imp_Server_msg";
paulson@2048
   605
paulson@2048
   606
paulson@2048
   607
(*Guarantee for B: if it gets a message with matching NB then the Server
paulson@2048
   608
  has sent the correct message.*)
paulson@2048
   609
goal thy 
paulson@2048
   610
 "!!evs. [| B ~: lost;  B ~= Spy;  evs : otway lost;               \
paulson@2048
   611
\           Says S B {|NA, X, Crypt {|NB, Key K|} (shrK B)|}       \
paulson@2048
   612
\            : set_of_list evs;                                    \
paulson@2048
   613
\           Says B Server {|NA, Agent A, Agent B, X',              \
paulson@2048
   614
\                           Crypt {|NA, NB, Agent A, Agent B|}     \
paulson@2048
   615
\                                 (shrK B)|}                       \
paulson@2048
   616
\            : set_of_list evs |]                                  \
paulson@2048
   617
\        ==> Says Server B                                         \
paulson@2048
   618
\                 {|NA,                                            \
paulson@2048
   619
\                   Crypt {|NA, Key K|} (shrK A),                  \
paulson@2048
   620
\                   Crypt {|NB, Key K|} (shrK B)|}                 \
paulson@2048
   621
\                   : set_of_list evs";
paulson@2048
   622
by (fast_tac (!claset addSIs [NB_Crypt_imp_Server_msg]
paulson@2048
   623
                      addEs  partsEs
paulson@2048
   624
                      addDs  [Says_imp_sees_Spy RS parts.Inj]) 1);
paulson@2064
   625
qed "B_trust_OR3";
paulson@2048
   626
paulson@2048
   627
paulson@2064
   628
B_trust_OR3 RS Spy_not_see_encrypted_key;
paulson@2048
   629
paulson@2048
   630
paulson@2026
   631
(** A session key uniquely identifies a pair of senders in the message
paulson@2048
   632
    encrypted by a good agent C.  NEEDED?  INTERESTING?**)
paulson@1945
   633
goal thy 
paulson@2032
   634
 "!!evs. evs : otway lost ==>                                           \
paulson@2135
   635
\      EX A B. ALL C N.                                                 \
paulson@2135
   636
\         C ~: lost -->                                                 \
paulson@2135
   637
\         Crypt {|N, Key K|} (shrK C) : parts (sees lost Spy evs) -->   \
paulson@2026
   638
\         C=A | C=B";
paulson@2032
   639
by (Simp_tac 1);        (*Miniscoping*)
paulson@2032
   640
by (etac otway.induct 1);
paulson@2064
   641
by analz_Fake_tac;
paulson@2032
   642
(*spy_analz_tac just does not work here: it is an entirely different proof!*)
paulson@1945
   643
by (ALLGOALS 
paulson@2026
   644
    (asm_simp_tac (!simpset addsimps [all_conj_distrib, ex_disj_distrib,
nipkow@2134
   645
                                      imp_conjR, parts_insert_sees,
paulson@2032
   646
                                      parts_insert2])));
paulson@1945
   647
by (REPEAT_FIRST (etac exE));
paulson@2026
   648
(*OR3: extraction of K = newK evsa to global context...*) (** LEVEL 6 **)
paulson@2064
   649
by (expand_case_tac "K = ?y" 4);
paulson@2064
   650
by (REPEAT (ares_tac [exI] 5));
paulson@1945
   651
(*...we prove this case by contradiction: the key is too new!*)
paulson@2026
   652
by (fast_tac (!claset addSEs partsEs
paulson@2032
   653
                      addEs [Says_imp_old_keys RS less_irrefl]
paulson@2032
   654
                      addss (!simpset)) 4);
paulson@2026
   655
(*Base, Fake, OR2, OR4*)
paulson@2026
   656
by (REPEAT_FIRST ex_strip_tac);
paulson@2032
   657
by (dtac synth.Inj 4);
paulson@2032
   658
by (dtac synth.Inj 3);
paulson@2026
   659
(*Now in effect there are three Fake cases*)
paulson@2026
   660
by (REPEAT_FIRST (best_tac (!claset addDs [impOfSubs Fake_parts_insert]
paulson@2032
   661
                                    delrules [disjCI, disjE]
paulson@2032
   662
                                    addss (!simpset))));
paulson@2014
   663
qed "key_identifies_senders";