src/HOL/Auth/OtwayRees_Bad.ML
author paulson
Mon Sep 23 17:41:57 1996 +0200 (1996-09-23)
changeset 2002 ed423882c6a9
child 2032 1bbf1bdcaf56
permissions -rw-r--r--
Bad version of Otway-Rees and the new attack on it
paulson@2002
     1
(*  Title:      HOL/Auth/OtwayRees_Bad
paulson@2002
     2
    ID:         $Id$
paulson@2002
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@2002
     4
    Copyright   1996  University of Cambridge
paulson@2002
     5
paulson@2002
     6
Inductive relation "otway" for the Otway-Rees protocol.
paulson@2002
     7
paulson@2002
     8
The FAULTY version omitting encryption of Nonce NB, as suggested on page 247 of
paulson@2002
     9
  Burrows, Abadi and Needham.  A Logic of Authentication.
paulson@2002
    10
  Proc. Royal Soc. 426 (1989)
paulson@2002
    11
paulson@2002
    12
This file illustrates the consequences of such errors.  We can still prove
paulson@2002
    13
impressive-looking properties such as Enemy_not_see_encrypted_key, yet the
paulson@2002
    14
protocol is open to a middleperson attack.  Attempting to prove some key lemmas
paulson@2002
    15
indicates the possibility of this attack.
paulson@2002
    16
*)
paulson@2002
    17
paulson@2002
    18
open OtwayRees_Bad;
paulson@2002
    19
paulson@2002
    20
proof_timing:=true;
paulson@2002
    21
HOL_quantifiers := false;
paulson@2002
    22
paulson@2002
    23
paulson@2002
    24
(*Weak liveness: there are traces that reach the end*)
paulson@2002
    25
goal thy 
paulson@2002
    26
 "!!A B. [| A ~= B; A ~= Server; B ~= Server |]   \
paulson@2002
    27
\        ==> EX K. EX NA. EX evs: otway.          \
paulson@2002
    28
\               Says B A {|Nonce NA, Crypt {|Nonce NA, Key K|} (shrK A)|} \
paulson@2002
    29
\                 : set_of_list evs";
paulson@2002
    30
by (REPEAT (resolve_tac [exI,bexI] 1));
paulson@2002
    31
br (otway.Nil RS otway.OR1 RS otway.OR2 RS otway.OR3 RS otway.OR4) 2;
paulson@2002
    32
by (ALLGOALS (simp_tac (!simpset setsolver safe_solver)));
paulson@2002
    33
by (REPEAT_FIRST (resolve_tac [refl, conjI]));
paulson@2002
    34
by (ALLGOALS (fast_tac (!claset addss (!simpset setsolver safe_solver))));
paulson@2002
    35
result();
paulson@2002
    36
paulson@2002
    37
paulson@2002
    38
(**** Inductive proofs about otway ****)
paulson@2002
    39
paulson@2002
    40
(*The Enemy can see more than anybody else, except for their initial state*)
paulson@2002
    41
goal thy 
paulson@2002
    42
 "!!evs. evs : otway ==> \
paulson@2002
    43
\     sees A evs <= initState A Un sees Enemy evs";
paulson@2002
    44
be otway.induct 1;
paulson@2002
    45
by (ALLGOALS (fast_tac (!claset addDs [sees_Says_subset_insert RS subsetD] 
paulson@2002
    46
			        addss (!simpset))));
paulson@2002
    47
qed "sees_agent_subset_sees_Enemy";
paulson@2002
    48
paulson@2002
    49
paulson@2002
    50
(*Nobody sends themselves messages*)
paulson@2002
    51
goal thy "!!evs. evs : otway ==> ALL A X. Says A A X ~: set_of_list evs";
paulson@2002
    52
be otway.induct 1;
paulson@2002
    53
by (Auto_tac());
paulson@2002
    54
qed_spec_mp "not_Says_to_self";
paulson@2002
    55
Addsimps [not_Says_to_self];
paulson@2002
    56
AddSEs   [not_Says_to_self RSN (2, rev_notE)];
paulson@2002
    57
paulson@2002
    58
paulson@2002
    59
(** For reasoning about the encrypted portion of messages **)
paulson@2002
    60
paulson@2002
    61
goal thy "!!evs. Says A' B {|N, Agent A, Agent B, X|} : set_of_list evs ==> \
paulson@2002
    62
\                X : analz (sees Enemy evs)";
paulson@2002
    63
by (fast_tac (!claset addSDs [Says_imp_sees_Enemy RS analz.Inj]) 1);
paulson@2002
    64
qed "OR2_analz_sees_Enemy";
paulson@2002
    65
paulson@2002
    66
goal thy "!!evs. Says S B {|N, X, X'|} : set_of_list evs ==> \
paulson@2002
    67
\                X : analz (sees Enemy evs)";
paulson@2002
    68
by (fast_tac (!claset addSDs [Says_imp_sees_Enemy RS analz.Inj]) 1);
paulson@2002
    69
qed "OR4_analz_sees_Enemy";
paulson@2002
    70
paulson@2002
    71
goal thy "!!evs. Says B' A {|N, Crypt {|N,K|} K'|} : set_of_list evs ==> \
paulson@2002
    72
\                K : parts (sees Enemy evs)";
paulson@2002
    73
by (fast_tac (!claset addSEs partsEs
paulson@2002
    74
	              addSDs [Says_imp_sees_Enemy RS parts.Inj]) 1);
paulson@2002
    75
qed "Reveal_parts_sees_Enemy";
paulson@2002
    76
paulson@2002
    77
(*OR2_analz... and OR4_analz... let us treat those cases using the same 
paulson@2002
    78
  argument as for the Fake case.  This is possible for most, but not all,
paulson@2002
    79
  proofs: Fake does not invent new nonces (as in OR2), and of course Fake
paulson@2002
    80
  messages originate from the Enemy. *)
paulson@2002
    81
paulson@2002
    82
val parts_Fake_tac = 
paulson@2002
    83
    dtac (OR2_analz_sees_Enemy RS (impOfSubs analz_subset_parts)) 4 THEN
paulson@2002
    84
    dtac (OR4_analz_sees_Enemy RS (impOfSubs analz_subset_parts)) 6 THEN
paulson@2002
    85
    dtac Reveal_parts_sees_Enemy 7;
paulson@2002
    86
paulson@2002
    87
paulson@2002
    88
(** Theorems of the form X ~: parts (sees Enemy evs) imply that NOBODY
paulson@2002
    89
    sends messages containing X! **)
paulson@2002
    90
paulson@2002
    91
(*Enemy never sees another agent's shared key! (unless it is leaked at start)*)
paulson@2002
    92
goal thy 
paulson@2002
    93
 "!!evs. [| evs : otway;  A ~: bad |]    \
paulson@2002
    94
\        ==> Key (shrK A) ~: parts (sees Enemy evs)";
paulson@2002
    95
be otway.induct 1;
paulson@2002
    96
by parts_Fake_tac;
paulson@2002
    97
by (Auto_tac());
paulson@2002
    98
(*Deals with Fake message*)
paulson@2002
    99
by (best_tac (!claset addDs [impOfSubs analz_subset_parts,
paulson@2002
   100
			     impOfSubs Fake_parts_insert]) 1);
paulson@2002
   101
qed "Enemy_not_see_shrK";
paulson@2002
   102
paulson@2002
   103
bind_thm ("Enemy_not_analz_shrK",
paulson@2002
   104
	  [analz_subset_parts, Enemy_not_see_shrK] MRS contra_subsetD);
paulson@2002
   105
paulson@2002
   106
Addsimps [Enemy_not_see_shrK, Enemy_not_analz_shrK];
paulson@2002
   107
paulson@2002
   108
(*We go to some trouble to preserve R in the 3rd and 4th subgoals
paulson@2002
   109
  As usual fast_tac cannot be used because it uses the equalities too soon*)
paulson@2002
   110
val major::prems = 
paulson@2002
   111
goal thy  "[| Key (shrK A) : parts (sees Enemy evs);       \
paulson@2002
   112
\             evs : otway;                                 \
paulson@2002
   113
\             A:bad ==> R                                  \
paulson@2002
   114
\           |] ==> R";
paulson@2002
   115
br ccontr 1;
paulson@2002
   116
br ([major, Enemy_not_see_shrK] MRS rev_notE) 1;
paulson@2002
   117
by (swap_res_tac prems 2);
paulson@2002
   118
by (ALLGOALS (fast_tac (!claset addIs prems)));
paulson@2002
   119
qed "Enemy_see_shrK_E";
paulson@2002
   120
paulson@2002
   121
bind_thm ("Enemy_analz_shrK_E", 
paulson@2002
   122
	  analz_subset_parts RS subsetD RS Enemy_see_shrK_E);
paulson@2002
   123
paulson@2002
   124
AddSEs [Enemy_see_shrK_E, Enemy_analz_shrK_E];
paulson@2002
   125
paulson@2002
   126
paulson@2002
   127
(*** Future keys can't be seen or used! ***)
paulson@2002
   128
paulson@2002
   129
(*Nobody can have SEEN keys that will be generated in the future.
paulson@2002
   130
  This has to be proved anew for each protocol description,
paulson@2002
   131
  but should go by similar reasoning every time.  Hardest case is the
paulson@2002
   132
  standard Fake rule.  
paulson@2002
   133
      The Union over C is essential for the induction! *)
paulson@2002
   134
goal thy "!!evs. evs : otway ==> \
paulson@2002
   135
\                length evs <= length evs' --> \
paulson@2002
   136
\                          Key (newK evs') ~: (UN C. parts (sees C evs))";
paulson@2002
   137
be otway.induct 1;
paulson@2002
   138
by parts_Fake_tac;
paulson@2002
   139
(*auto_tac does not work here, as it performs safe_tac first*)
paulson@2002
   140
by (ALLGOALS Asm_simp_tac);
paulson@2002
   141
by (REPEAT_FIRST (best_tac (!claset addDs [impOfSubs analz_subset_parts,
paulson@2002
   142
				       impOfSubs parts_insert_subset_Un,
paulson@2002
   143
				       Suc_leD]
paulson@2002
   144
			        addss (!simpset))));
paulson@2002
   145
val lemma = result();
paulson@2002
   146
paulson@2002
   147
(*Variant needed for the main theorem below*)
paulson@2002
   148
goal thy 
paulson@2002
   149
 "!!evs. [| evs : otway;  length evs <= length evs' |]    \
paulson@2002
   150
\        ==> Key (newK evs') ~: parts (sees C evs)";
paulson@2002
   151
by (fast_tac (!claset addDs [lemma]) 1);
paulson@2002
   152
qed "new_keys_not_seen";
paulson@2002
   153
Addsimps [new_keys_not_seen];
paulson@2002
   154
paulson@2002
   155
(*Another variant: old messages must contain old keys!*)
paulson@2002
   156
goal thy 
paulson@2002
   157
 "!!evs. [| Says A B X : set_of_list evs;  \
paulson@2002
   158
\           Key (newK evt) : parts {X};    \
paulson@2002
   159
\           evs : otway                 \
paulson@2002
   160
\        |] ==> length evt < length evs";
paulson@2002
   161
br ccontr 1;
paulson@2002
   162
by (fast_tac (!claset addSDs [new_keys_not_seen, Says_imp_sees_Enemy]
paulson@2002
   163
	              addIs  [impOfSubs parts_mono, leI]) 1);
paulson@2002
   164
qed "Says_imp_old_keys";
paulson@2002
   165
paulson@2002
   166
paulson@2002
   167
(*** Future nonces can't be seen or used! [proofs resemble those above] ***)
paulson@2002
   168
paulson@2002
   169
goal thy "!!evs. evs : otway ==> \
paulson@2002
   170
\                length evs <= length evs' --> \
paulson@2002
   171
\                          Nonce (newN evs') ~: (UN C. parts (sees C evs))";
paulson@2002
   172
be otway.induct 1;
paulson@2002
   173
(*auto_tac does not work here, as it performs safe_tac first*)
paulson@2002
   174
by (ALLGOALS (asm_simp_tac (!simpset addsimps [de_Morgan_disj]
paulson@2002
   175
                                     addcongs [conj_cong])));
paulson@2002
   176
by (REPEAT_FIRST (fast_tac (!claset (*60 seconds???*)
paulson@2002
   177
			      addSEs [MPair_parts]
paulson@2002
   178
			      addDs  [Says_imp_sees_Enemy RS parts.Inj,
paulson@2002
   179
				      impOfSubs analz_subset_parts,
paulson@2002
   180
				      impOfSubs parts_insert_subset_Un,
paulson@2002
   181
				      Suc_leD]
paulson@2002
   182
			      addss (!simpset))));
paulson@2002
   183
val lemma = result();
paulson@2002
   184
paulson@2002
   185
(*Variant needed for the main theorem below*)
paulson@2002
   186
goal thy 
paulson@2002
   187
 "!!evs. [| evs : otway;  length evs <= length evs' |]    \
paulson@2002
   188
\        ==> Nonce (newN evs') ~: parts (sees C evs)";
paulson@2002
   189
by (fast_tac (!claset addDs [lemma]) 1);
paulson@2002
   190
qed "new_nonces_not_seen";
paulson@2002
   191
Addsimps [new_nonces_not_seen];
paulson@2002
   192
paulson@2002
   193
(*Another variant: old messages must contain old nonces!*)
paulson@2002
   194
goal thy 
paulson@2002
   195
 "!!evs. [| Says A B X : set_of_list evs;  \
paulson@2002
   196
\           Nonce (newN evt) : parts {X};    \
paulson@2002
   197
\           evs : otway                 \
paulson@2002
   198
\        |] ==> length evt < length evs";
paulson@2002
   199
br ccontr 1;
paulson@2002
   200
by (fast_tac (!claset addSDs [new_nonces_not_seen, Says_imp_sees_Enemy]
paulson@2002
   201
	              addIs  [impOfSubs parts_mono, leI]) 1);
paulson@2002
   202
qed "Says_imp_old_nonces";
paulson@2002
   203
paulson@2002
   204
paulson@2002
   205
(*Nobody can have USED keys that will be generated in the future.
paulson@2002
   206
  ...very like new_keys_not_seen*)
paulson@2002
   207
goal thy "!!evs. evs : otway ==> \
paulson@2002
   208
\                length evs <= length evs' --> \
paulson@2002
   209
\                newK evs' ~: keysFor (UN C. parts (sees C evs))";
paulson@2002
   210
be otway.induct 1;
paulson@2002
   211
by parts_Fake_tac;
paulson@2002
   212
by (ALLGOALS Asm_simp_tac);
paulson@2002
   213
(*OR1 and OR3*)
paulson@2002
   214
by (EVERY (map (fast_tac (!claset addDs [Suc_leD] addss (!simpset))) [4,2]));
paulson@2002
   215
(*Fake, OR2, OR4: these messages send unknown (X) components*)
paulson@2002
   216
by (EVERY 
paulson@2002
   217
    (map
paulson@2002
   218
     (best_tac
paulson@2002
   219
      (!claset addDs [impOfSubs (analz_subset_parts RS keysFor_mono),
paulson@2002
   220
		      impOfSubs (parts_insert_subset_Un RS keysFor_mono),
paulson@2002
   221
		      Suc_leD]
paulson@2002
   222
	       addEs [new_keys_not_seen RS not_parts_not_analz RSN(2,rev_notE)]
paulson@2002
   223
	       addss (!simpset)))
paulson@2002
   224
     [3,2,1]));
paulson@2002
   225
(*Reveal: dummy message*)
paulson@2002
   226
by (best_tac (!claset addEs  [new_keys_not_seen RSN(2,rev_notE)]
paulson@2002
   227
		      addIs  [less_SucI, impOfSubs keysFor_mono]
paulson@2002
   228
		      addss (!simpset addsimps [le_def])) 1);
paulson@2002
   229
val lemma = result();
paulson@2002
   230
paulson@2002
   231
goal thy 
paulson@2002
   232
 "!!evs. [| evs : otway;  length evs <= length evs' |]    \
paulson@2002
   233
\        ==> newK evs' ~: keysFor (parts (sees C evs))";
paulson@2002
   234
by (fast_tac (!claset addSDs [lemma] addss (!simpset)) 1);
paulson@2002
   235
qed "new_keys_not_used";
paulson@2002
   236
paulson@2002
   237
bind_thm ("new_keys_not_analzd",
paulson@2002
   238
	  [analz_subset_parts RS keysFor_mono,
paulson@2002
   239
	   new_keys_not_used] MRS contra_subsetD);
paulson@2002
   240
paulson@2002
   241
Addsimps [new_keys_not_used, new_keys_not_analzd];
paulson@2002
   242
paulson@2002
   243
paulson@2002
   244
(** Lemmas concerning the form of items passed in messages **)
paulson@2002
   245
paulson@2002
   246
paulson@2002
   247
(****
paulson@2002
   248
 The following is to prove theorems of the form
paulson@2002
   249
paulson@2002
   250
          Key K : analz (insert (Key (newK evt)) (sees Enemy evs)) ==>
paulson@2002
   251
          Key K : analz (sees Enemy evs)
paulson@2002
   252
paulson@2002
   253
 A more general formula must be proved inductively.
paulson@2002
   254
paulson@2002
   255
****)
paulson@2002
   256
paulson@2002
   257
paulson@2002
   258
(*NOT useful in this form, but it says that session keys are not used
paulson@2002
   259
  to encrypt messages containing other keys, in the actual protocol.
paulson@2002
   260
  We require that agents should behave like this subsequently also.*)
paulson@2002
   261
goal thy 
paulson@2002
   262
 "!!evs. evs : otway ==> \
paulson@2002
   263
\        (Crypt X (newK evt)) : parts (sees Enemy evs) & \
paulson@2002
   264
\        Key K : parts {X} --> Key K : parts (sees Enemy evs)";
paulson@2002
   265
be otway.induct 1;
paulson@2002
   266
by parts_Fake_tac;
paulson@2002
   267
by (ALLGOALS (asm_simp_tac (!simpset addsimps pushes)));
paulson@2002
   268
(*Deals with Faked messages*)
paulson@2002
   269
by (best_tac (!claset addSEs partsEs
paulson@2002
   270
		      addDs [impOfSubs analz_subset_parts,
paulson@2002
   271
                             impOfSubs parts_insert_subset_Un]
paulson@2002
   272
                      addss (!simpset)) 2);
paulson@2002
   273
(*Base case and Reveal*)
paulson@2002
   274
by (Auto_tac());
paulson@2002
   275
result();
paulson@2002
   276
paulson@2002
   277
paulson@2002
   278
(** Specialized rewriting for this proof **)
paulson@2002
   279
paulson@2002
   280
Delsimps [image_insert];
paulson@2002
   281
Addsimps [image_insert RS sym];
paulson@2002
   282
paulson@2002
   283
Delsimps [image_Un];
paulson@2002
   284
Addsimps [image_Un RS sym];
paulson@2002
   285
paulson@2002
   286
goal thy "insert (Key (newK x)) (sees A evs) = \
paulson@2002
   287
\         Key `` (newK``{x}) Un (sees A evs)";
paulson@2002
   288
by (Fast_tac 1);
paulson@2002
   289
val insert_Key_singleton = result();
paulson@2002
   290
paulson@2002
   291
goal thy "insert (Key (f x)) (Key``(f``E) Un C) = \
paulson@2002
   292
\         Key `` (f `` (insert x E)) Un C";
paulson@2002
   293
by (Fast_tac 1);
paulson@2002
   294
val insert_Key_image = result();
paulson@2002
   295
paulson@2002
   296
paulson@2002
   297
(*This lets us avoid analyzing the new message -- unless we have to!*)
paulson@2002
   298
(*NEEDED??*)
paulson@2002
   299
goal thy "synth (analz (sees Enemy evs)) <=   \
paulson@2002
   300
\         synth (analz (sees Enemy (Says A B X # evs)))";
paulson@2002
   301
by (Simp_tac 1);
paulson@2002
   302
br (subset_insertI RS analz_mono RS synth_mono) 1;
paulson@2002
   303
qed "synth_analz_thin";
paulson@2002
   304
paulson@2002
   305
AddIs [impOfSubs synth_analz_thin];
paulson@2002
   306
paulson@2002
   307
paulson@2002
   308
paulson@2002
   309
(** Session keys are not used to encrypt other session keys **)
paulson@2002
   310
paulson@2002
   311
(*Describes the form of Key K when the following message is sent.  The use of
paulson@2002
   312
  "parts" strengthens the induction hyp for proving the Fake case.  The
paulson@2002
   313
  assumptions on A are needed to prevent its being a Faked message.  (Based
paulson@2002
   314
  on NS_Shared/Says_S_message_form) *)
paulson@2002
   315
goal thy
paulson@2002
   316
 "!!evs. evs: otway ==>  \
paulson@2002
   317
\          Crypt {|N, Key K|} (shrK A) : parts (sees Enemy evs) & \
paulson@2002
   318
\          A ~: bad --> \
paulson@2002
   319
\        (EX evt:otway. K = newK evt)";
paulson@2002
   320
be otway.induct 1;
paulson@2002
   321
by parts_Fake_tac;
paulson@2002
   322
by (Auto_tac());
paulson@2002
   323
(*Deals with Fake message*)
paulson@2002
   324
by (best_tac (!claset addDs [impOfSubs analz_subset_parts,
paulson@2002
   325
			     impOfSubs Fake_parts_insert]) 1);
paulson@2002
   326
val lemma = result() RS mp;
paulson@2002
   327
paulson@2002
   328
paulson@2002
   329
(*EITHER describes the form of Key K when the following message is sent, 
paulson@2002
   330
  OR     reduces it to the Fake case.*)
paulson@2002
   331
goal thy 
paulson@2002
   332
 "!!evs. [| Says B' A {|N, Crypt {|N, Key K|} (shrK A)|} : set_of_list evs;  \
paulson@2002
   333
\           evs : otway |]                      \
paulson@2002
   334
\        ==> (EX evt:otway. K = newK evt) | Key K : analz (sees Enemy evs)";
paulson@2002
   335
by (excluded_middle_tac "A : bad" 1);
paulson@2002
   336
by (fast_tac (!claset addSDs [Says_imp_sees_Enemy RS analz.Inj]
paulson@2002
   337
	              addss (!simpset)) 2);
paulson@2002
   338
by (forward_tac [lemma] 1);
paulson@2002
   339
by (fast_tac (!claset addEs  partsEs
paulson@2002
   340
	              addSDs [Says_imp_sees_Enemy RS parts.Inj]) 1);
paulson@2002
   341
by (Fast_tac 1);
paulson@2002
   342
qed "Reveal_message_form";
paulson@2002
   343
paulson@2002
   344
paulson@2002
   345
(*Lemma for the trivial direction of the if-and-only-if*)
paulson@2002
   346
goal thy  
paulson@2002
   347
 "!!evs. (Key K : analz (Key``nE Un sEe)) --> \
paulson@2002
   348
\         (K : nE | Key K : analz sEe)  ==>     \
paulson@2002
   349
\        (Key K : analz (Key``nE Un sEe)) = (K : nE | Key K : analz sEe)";
paulson@2002
   350
by (fast_tac (!claset addSEs [impOfSubs analz_mono]) 1);
paulson@2002
   351
val lemma = result();
paulson@2002
   352
paulson@2002
   353
paulson@2002
   354
(*The equality makes the induction hypothesis easier to apply*)
paulson@2002
   355
goal thy  
paulson@2002
   356
 "!!evs. evs : otway ==> \
paulson@2002
   357
\  ALL K E. (Key K : analz (Key``(newK``E) Un (sees Enemy evs))) = \
paulson@2002
   358
\           (K : newK``E | Key K : analz (sees Enemy evs))";
paulson@2002
   359
be otway.induct 1;
paulson@2002
   360
bd OR2_analz_sees_Enemy 4;
paulson@2002
   361
bd OR4_analz_sees_Enemy 6;
paulson@2002
   362
bd Reveal_message_form 7;
paulson@2002
   363
by (REPEAT_FIRST (ares_tac [allI, lemma]));
paulson@2002
   364
by (REPEAT ((eresolve_tac [bexE, disjE] ORELSE' hyp_subst_tac) 7));
paulson@2002
   365
by (ALLGOALS (*Takes 28 secs*)
paulson@2002
   366
    (asm_simp_tac 
paulson@2002
   367
     (!simpset addsimps ([insert_Key_singleton, insert_Key_image, pushKey_newK]
paulson@2002
   368
			 @ pushes)
paulson@2002
   369
               setloop split_tac [expand_if])));
paulson@2002
   370
(** LEVEL 7 **)
paulson@2002
   371
(*Reveal case 2, OR4, OR2, Fake*) 
paulson@2002
   372
by (EVERY (map enemy_analz_tac [7,5,3,2]));
paulson@2002
   373
(*Reveal case 1, OR3, Base*)
paulson@2002
   374
by (Auto_tac());
paulson@2002
   375
qed_spec_mp "analz_image_newK";
paulson@2002
   376
paulson@2002
   377
paulson@2002
   378
goal thy
paulson@2002
   379
 "!!evs. evs : otway ==>                               \
paulson@2002
   380
\        Key K : analz (insert (Key (newK evt)) (sees Enemy evs)) = \
paulson@2002
   381
\        (K = newK evt | Key K : analz (sees Enemy evs))";
paulson@2002
   382
by (asm_simp_tac (HOL_ss addsimps [pushKey_newK, analz_image_newK, 
paulson@2002
   383
				   insert_Key_singleton]) 1);
paulson@2002
   384
by (Fast_tac 1);
paulson@2002
   385
qed "analz_insert_Key_newK";
paulson@2002
   386
paulson@2002
   387
paulson@2002
   388
(*Describes the form of K and NA when the Server sends this message.*)
paulson@2002
   389
goal thy 
paulson@2002
   390
 "!!evs. [| Says Server B \
paulson@2002
   391
\            {|NA, Crypt {|NA, K|} (shrK A),                      \
paulson@2002
   392
\                  Crypt {|NB, K|} (shrK B)|} : set_of_list evs;  \
paulson@2002
   393
\           evs : otway |]                                        \
paulson@2002
   394
\        ==> (EX evt:otway. K = Key(newK evt)) &            \
paulson@2002
   395
\            (EX i. NA = Nonce i)";
paulson@2002
   396
be rev_mp 1;
paulson@2002
   397
be otway.induct 1;
paulson@2002
   398
by (ALLGOALS (fast_tac (!claset addIs [less_SucI] addss (!simpset))));
paulson@2002
   399
qed "Says_Server_message_form";
paulson@2002
   400
paulson@2002
   401
paulson@2002
   402
(*Crucial security property, but not itself enough to guarantee correctness!
paulson@2002
   403
  The need for quantification over N, C seems to indicate the problem.
paulson@2002
   404
  Omitting the Reveal message from the description deprives us of even 
paulson@2002
   405
	this clue. *)
paulson@2002
   406
goal thy 
paulson@2002
   407
 "!!evs. [| A ~: bad;  B ~: bad;  evs : otway;  evt : otway |]        \
paulson@2002
   408
\    ==> Says Server B \
paulson@2002
   409
\          {|Nonce NA, Crypt {|Nonce NA, Key(newK evt)|} (shrK A), \
paulson@2002
   410
\            Crypt {|NB, Key(newK evt)|} (shrK B)|} : set_of_list evs --> \
paulson@2002
   411
\        (ALL N C. Says C Enemy {|N, Key(newK evt)|} ~: set_of_list evs) --> \
paulson@2002
   412
\        Key(newK evt) ~: analz (sees Enemy evs)";
paulson@2002
   413
be otway.induct 1;
paulson@2002
   414
bd OR2_analz_sees_Enemy 4;
paulson@2002
   415
bd OR4_analz_sees_Enemy 6;
paulson@2002
   416
bd Reveal_message_form 7;
paulson@2002
   417
by (REPEAT_FIRST (eresolve_tac [asm_rl, bexE, disjE] ORELSE' hyp_subst_tac));
paulson@2002
   418
by (ALLGOALS
paulson@2002
   419
    (asm_full_simp_tac 
paulson@2002
   420
     (!simpset addsimps ([analz_subset_parts RS contra_subsetD,
paulson@2002
   421
			  analz_insert_Key_newK] @ pushes)
paulson@2002
   422
               setloop split_tac [expand_if])));
paulson@2002
   423
(** LEVEL 6 **)
paulson@2002
   424
(*Reveal case 1*)
paulson@2002
   425
by (Fast_tac 5);
paulson@2002
   426
(*OR3*)
paulson@2002
   427
by (fast_tac (!claset addSIs [parts_insertI]
paulson@2002
   428
		      addEs [Says_imp_old_keys RS less_irrefl]
paulson@2002
   429
	              addss (!simpset)) 3);
paulson@2002
   430
(*Reveal case 2, OR4, OR2, Fake*) 
paulson@2002
   431
br conjI 3;
paulson@2002
   432
by (REPEAT (enemy_analz_tac 1));
paulson@2002
   433
val lemma = result() RS mp RS mp RSN(2,rev_notE);
paulson@2002
   434
paulson@2002
   435
paulson@2002
   436
paulson@2002
   437
(*WEAK VERSION: NEED TO ELIMINATE QUANTIFICATION OVER N, C!!*)
paulson@2002
   438
goal thy 
paulson@2002
   439
 "!!evs. [| Says Server B \
paulson@2002
   440
\            {|NA, Crypt {|NA, K|} (shrK A),                      \
paulson@2002
   441
\                  Crypt {|NB, K|} (shrK B)|} : set_of_list evs;  \
paulson@2002
   442
\           (ALL N C. Says C Enemy {|N, K|} ~: set_of_list evs);  \
paulson@2002
   443
\           A ~: bad;  B ~: bad;  evs : otway |]                  \
paulson@2002
   444
\        ==> K ~: analz (sees Enemy evs)";
paulson@2002
   445
by (forward_tac [Says_Server_message_form] 1 THEN assume_tac 1);
paulson@2002
   446
by (fast_tac (!claset addSEs [lemma]) 1);
paulson@2002
   447
qed "Enemy_not_see_encrypted_key";
paulson@2002
   448
paulson@2002
   449
paulson@2002
   450
(*** Attempting to prove stronger properties ***)
paulson@2002
   451
paulson@2002
   452
(** The Key K uniquely identifies the Server's  message. **)
paulson@2002
   453
paulson@2002
   454
fun ex_strip_tac i = REPEAT (ares_tac [exI, conjI] i) THEN assume_tac (i+1);
paulson@2002
   455
paulson@2002
   456
goal thy 
paulson@2002
   457
 "!!evs. evs : otway ==>                      \
paulson@2002
   458
\      EX A' B' NA' NB'. ALL A B NA NB.                    \
paulson@2002
   459
\       Says Server B \
paulson@2002
   460
\            {|NA, Crypt {|NA, K|} (shrK A),                      \
paulson@2002
   461
\                  Crypt {|NB, K|} (shrK B)|} : set_of_list evs --> \
paulson@2002
   462
\       A=A' & B=B' & NA=NA' & NB=NB'";
paulson@2002
   463
be otway.induct 1;
paulson@2002
   464
by (ALLGOALS (asm_simp_tac (!simpset addsimps [all_conj_distrib])));
paulson@2002
   465
by (Step_tac 1);
paulson@2002
   466
(*Remaining cases: OR3 and OR4*)
paulson@2002
   467
by (ex_strip_tac 2);
paulson@2002
   468
by (Fast_tac 2);
paulson@2002
   469
by (excluded_middle_tac "K = Key(newK evsa)" 1);
paulson@2002
   470
by (Asm_simp_tac 1);
paulson@2002
   471
by (REPEAT (ares_tac [refl,exI,impI,conjI] 1));
paulson@2002
   472
(*...we assume X is a very new message, and handle this case by contradiction*)
paulson@2002
   473
by (fast_tac (!claset addEs [Says_imp_old_keys RS less_irrefl]
paulson@2002
   474
	              delrules [conjI]    (*prevent split-up into 4 subgoals*)
paulson@2002
   475
	              addss (!simpset addsimps [parts_insertI])) 1);
paulson@2002
   476
val lemma = result();
paulson@2002
   477
paulson@2002
   478
paulson@2002
   479
goal thy 
paulson@2002
   480
 "!!evs. [| Says Server B                                          \
paulson@2002
   481
\              {|NA, Crypt {|NA, K|} (shrK A),                     \
paulson@2002
   482
\                    Crypt {|NB, K|} (shrK B)|}                    \
paulson@2002
   483
\            : set_of_list evs;                                    \ 
paulson@2002
   484
\           Says Server B'                                         \
paulson@2002
   485
\              {|NA', Crypt {|NA', K|} (shrK A'),                  \
paulson@2002
   486
\                     Crypt {|NB', K|} (shrK B')|}                 \
paulson@2002
   487
\            : set_of_list evs;                                    \
paulson@2002
   488
\           evs : otway |]                                         \
paulson@2002
   489
\        ==> A=A' & B=B' & NA=NA' & NB=NB'";
paulson@2002
   490
bd lemma 1;
paulson@2002
   491
by (REPEAT (etac exE 1));
paulson@2002
   492
(*Duplicate the assumption*)
paulson@2002
   493
by (forw_inst_tac [("psi", "ALL C.?P(C)")] asm_rl 1);
paulson@2002
   494
by (fast_tac (!claset addSDs [spec]) 1);
paulson@2002
   495
qed "unique_session_keys";
paulson@2002
   496
paulson@2002
   497
paulson@2002
   498
(*Could probably remove the A ~= B premise using another induction*)
paulson@2002
   499
goal thy 
paulson@2002
   500
 "!!evs. [| A ~: bad;  A ~= B; evs : otway |]               \
paulson@2002
   501
\        ==> Crypt {|NA, Agent A, Agent B|} (shrK A)        \
paulson@2002
   502
\             : parts (sees Enemy evs) -->                  \
paulson@2002
   503
\            Says A B {|NA, Agent A, Agent B,               \
paulson@2002
   504
\                       Crypt {|NA, Agent A, Agent B|} (shrK A)|}  \
paulson@2002
   505
\             : set_of_list evs";
paulson@2002
   506
be otway.induct 1;
paulson@2002
   507
by parts_Fake_tac;
paulson@2002
   508
by (ALLGOALS Asm_simp_tac);
paulson@2002
   509
(*Fake*)
paulson@2002
   510
by (best_tac (!claset addSDs [impOfSubs analz_subset_parts,
paulson@2002
   511
			      impOfSubs Fake_parts_insert]) 2);
paulson@2002
   512
by (Auto_tac());
paulson@2002
   513
qed_spec_mp "Crypt_imp_OR1";
paulson@2002
   514
paulson@2002
   515
paulson@2002
   516
(*This key property is FALSE.  Somebody could make a fake message to Server
paulson@2002
   517
          substituting some other nonce NA' for NB.*)
paulson@2002
   518
goal thy 
paulson@2002
   519
 "!!evs. [| A ~: bad;  evs : otway |]                                 \
paulson@2002
   520
\        ==> Crypt {|Nonce NA, Key K|} (shrK A) : parts (sees Enemy evs) --> \
paulson@2002
   521
\            Says A B {|Nonce NA, Agent A, Agent B,  \
paulson@2002
   522
\                       Crypt {|Nonce NA, Agent A, Agent B|} (shrK A)|}  \
paulson@2002
   523
\             : set_of_list evs --> \
paulson@2002
   524
\            (EX B NB. Says Server B               \
paulson@2002
   525
\                 {|Nonce NA,               \
paulson@2002
   526
\                   Crypt {|Nonce NA, Key K|} (shrK A),              \
paulson@2002
   527
\                   Crypt {|Nonce NB, Key K|} (shrK B)|}             \
paulson@2002
   528
\                   : set_of_list evs)";
paulson@2002
   529
be otway.induct 1;
paulson@2002
   530
fun ftac rl = forward_tac [rl];
paulson@2002
   531
by (
paulson@2002
   532
    ftac (OR2_analz_sees_Enemy RS (impOfSubs analz_subset_parts)) 4 THEN
paulson@2002
   533
    ftac (OR4_analz_sees_Enemy RS (impOfSubs analz_subset_parts)) 6 THEN
paulson@2002
   534
    ftac Reveal_parts_sees_Enemy 7);
paulson@2002
   535
paulson@2002
   536
(*  by parts_Fake_tac;  ?*)
paulson@2002
   537
by (ALLGOALS Asm_simp_tac);
paulson@2002
   538
(*Fake*)
paulson@2002
   539
by (best_tac (!claset addSDs [impOfSubs analz_subset_parts,
paulson@2002
   540
			      impOfSubs Fake_parts_insert]) 1);
paulson@2002
   541
(*OR1: it cannot be a new Nonce, contradiction.*)
paulson@2002
   542
by (fast_tac (!claset addSIs [parts_insertI]
paulson@2002
   543
		      addSEs partsEs
paulson@2002
   544
		      addEs [Says_imp_old_nonces RS less_irrefl]
paulson@2002
   545
	              addss (!simpset)) 1);
paulson@2002
   546
(*OR3 and OR4*)  (** LEVEL 5 **)
paulson@2002
   547
(*OR4*)
paulson@2002
   548
by (REPEAT (Safe_step_tac 2));
paulson@2002
   549
by (best_tac (!claset addSDs [parts_cut]) 3);
paulson@2002
   550
by (best_tac (!claset addSDs [parts_cut]) 3);
paulson@2002
   551
by (forward_tac [Crypt_imp_OR1] 2);
paulson@2002
   552
by (fast_tac (!claset addEs  partsEs
paulson@2002
   553
	              addSDs [Says_imp_sees_Enemy RS parts.Inj]) 4);
paulson@2002
   554
by (REPEAT (Fast_tac 2));
paulson@2002
   555
(*OR3*)  (** LEVEL 11 **)
paulson@2002
   556
by (ALLGOALS (asm_simp_tac (!simpset addsimps [ex_disj_distrib])));
paulson@2002
   557
fr impI;
paulson@2002
   558
by (REPEAT (etac conjE 1 ORELSE hyp_subst_tac 1));
paulson@2002
   559
fr impI;
paulson@2002
   560
(*The hypotheses at this point suggest an attack in which nonce NA is used
paulson@2002
   561
  in two different places*)
paulson@2002
   562
writeln "GIVE UP!";
paulson@2002
   563
paulson@2002
   564
paulson@2002
   565
paulson@2002
   566
(*What can A deduce from receipt of OR4?  This too is probably FALSE*)
paulson@2002
   567
goal thy 
paulson@2002
   568
 "!!evs. [| A ~: bad;  evs : otway |]                                 \
paulson@2002
   569
\        ==> ALL B' NA K B.  \
paulson@2002
   570
\            Says B' A {|Nonce NA, Crypt {|Nonce NA, Key K|} (shrK A)|} \
paulson@2002
   571
\             : set_of_list evs -->  \
paulson@2002
   572
\            Says A B {|Nonce NA, Agent A, Agent B,                     \
paulson@2002
   573
\                       Crypt {|Nonce NA, Agent A, Agent B|} (shrK A)|} \
paulson@2002
   574
\             : set_of_list evs --> \
paulson@2002
   575
\            (EX NB. Says Server B \
paulson@2002
   576
\                     {|Nonce NA,               \
paulson@2002
   577
\                       Crypt {|Nonce NA, Key K|} (shrK A),              \
paulson@2002
   578
\                       Crypt {|Nonce NB, Key K|} (shrK B)|}             \
paulson@2002
   579
\                       : set_of_list evs)";
paulson@2002
   580
be otway.induct 1;
paulson@2002
   581
by (ALLGOALS (asm_simp_tac (!simpset addcongs [conj_cong])));
paulson@2002
   582
(*OR2*)
paulson@2002
   583
by (Fast_tac 3);
paulson@2002
   584
(*OR1: it cannot be a new Nonce, contradiction.*)
paulson@2002
   585
by (fast_tac (!claset addSIs [parts_insertI]
paulson@2002
   586
		      addEs [Says_imp_old_nonces RS less_irrefl]
paulson@2002
   587
	              addss (!simpset)) 2);
paulson@2002
   588
by (ALLGOALS 
paulson@2002
   589
    (asm_simp_tac (!simpset addsimps [all_conj_distrib, de_Morgan_disj, de_Morgan_conj])));
paulson@2002
   590
(*Fake, OR4*) (** LEVEL 5 **)
paulson@2002
   591
by (step_tac (!claset delrules [MPair_analz]) 1);
paulson@2002
   592
by (ALLGOALS Asm_simp_tac);
paulson@2002
   593
by (fast_tac (!claset addSDs [spec]) 4);
paulson@2002
   594
by (forward_tac [Crypt_imp_OR1] 3);
paulson@2002
   595
by (fast_tac (!claset addEs  partsEs
paulson@2002
   596
	              addSDs [Says_imp_sees_Enemy RS parts.Inj]) 5);
paulson@2002
   597
by (REPEAT (Fast_tac 3));
paulson@2002
   598
(** LEVEL 11 **)
paulson@2002
   599
(*Fake (??) and OR4*)
paulson@2002
   600
paulson@2002
   601
paulson@2002
   602
by (ALLGOALS (asm_simp_tac (!simpset addsimps [all_conj_distrib, ex_disj_distrib,  de_Morgan_disj, de_Morgan_conj])));
paulson@2002
   603
paulson@2002
   604
paulson@2002
   605
(*** Session keys are issued at most once, and identify the principals ***)
paulson@2002
   606
paulson@2002
   607
(** First, two lemmas for the Fake, OR2 and OR4 cases **)
paulson@2002
   608
paulson@2002
   609
goal thy 
paulson@2002
   610
 "!!evs. [| X : synth (analz (sees Enemy evs));                \
paulson@2002
   611
\           Crypt X' (shrK C) : parts{X};                      \
paulson@2002
   612
\           C ~: bad;  evs : otway |]  \
paulson@2002
   613
\        ==> Crypt X' (shrK C) : parts (sees Enemy evs)";
paulson@2002
   614
by (best_tac (!claset addSEs [impOfSubs analz_subset_parts]
paulson@2002
   615
	              addDs [impOfSubs parts_insert_subset_Un]
paulson@2002
   616
                      addss (!simpset)) 1);
paulson@2002
   617
qed "Crypt_Fake_parts";
paulson@2002
   618
paulson@2002
   619
goal thy 
paulson@2002
   620
 "!!evs. [| Crypt X' K : parts (sees A evs);  evs : otway |]  \
paulson@2002
   621
\        ==> EX S S' Y. Says S S' Y : set_of_list evs &       \
paulson@2002
   622
\            Crypt X' K : parts {Y}";
paulson@2002
   623
bd parts_singleton 1;
paulson@2002
   624
by (fast_tac (!claset addSDs [seesD] addss (!simpset)) 1);
paulson@2002
   625
qed "Crypt_parts_singleton";
paulson@2002
   626
paulson@2002
   627
(*The Key K uniquely identifies a pair of senders in the message encrypted by
paulson@2002
   628
  C, but if C=Enemy then he could send all sorts of nonsense.*)
paulson@2002
   629
goal thy 
paulson@2002
   630
 "!!evs. evs : otway ==>                                     \
paulson@2002
   631
\      EX A B. ALL C.                                        \
paulson@2002
   632
\         C ~: bad -->                                       \
paulson@2002
   633
\         (ALL S S' X. Says S S' X : set_of_list evs -->     \
paulson@2002
   634
\           (EX NA. Crypt {|NA, Key K|} (shrK C) : parts{X}) --> C=A | C=B)";
paulson@2002
   635
by (Simp_tac 1);
paulson@2002
   636
be otway.induct 1;
paulson@2002
   637
bd OR2_analz_sees_Enemy 4;
paulson@2002
   638
bd OR4_analz_sees_Enemy 6;
paulson@2002
   639
by (ALLGOALS 
paulson@2002
   640
    (asm_simp_tac (!simpset addsimps [all_conj_distrib, imp_conj_distrib])));
paulson@2002
   641
by (REPEAT_FIRST (etac exE));
paulson@2002
   642
(*OR4*)
paulson@2002
   643
by (ex_strip_tac 4);
paulson@2002
   644
by (fast_tac (!claset addSDs [synth.Inj RS Crypt_Fake_parts, 
paulson@2002
   645
			      Crypt_parts_singleton]) 4);
paulson@2002
   646
(*OR3: Case split propagates some context to other subgoal...*)
paulson@2002
   647
	(** LEVEL 8 **)
paulson@2002
   648
by (excluded_middle_tac "K = newK evsa" 3);
paulson@2002
   649
by (Asm_simp_tac 3);
paulson@2002
   650
by (REPEAT (ares_tac [exI] 3));
paulson@2002
   651
(*...we prove this case by contradiction: the key is too new!*)
paulson@2002
   652
by (fast_tac (!claset addIs [parts_insertI]
paulson@2002
   653
		      addSEs partsEs
paulson@2002
   654
		      addEs [Says_imp_old_keys RS less_irrefl]
paulson@2002
   655
	              addss (!simpset)) 3);
paulson@2002
   656
(*OR2*) (** LEVEL 12 **)
paulson@2002
   657
(*enemy_analz_tac just does not work here: it is an entirely different proof!*)
paulson@2002
   658
by (ex_strip_tac 2);
paulson@2002
   659
by (res_inst_tac [("x1","X")] (insert_commute RS ssubst) 2);
paulson@2002
   660
by (Simp_tac 2);
paulson@2002
   661
by (fast_tac (!claset addSDs [synth.Inj RS Crypt_Fake_parts, 
paulson@2002
   662
			      Crypt_parts_singleton]) 2);
paulson@2002
   663
(*Fake*) (** LEVEL 16 **)
paulson@2002
   664
by (ex_strip_tac 1);
paulson@2002
   665
by (fast_tac (!claset addSDs [Crypt_Fake_parts, Crypt_parts_singleton]) 1);
paulson@2002
   666
qed "unique_session_keys2";
paulson@2002
   667
paulson@2002
   668