src/HOL/Auth/NS_Shared.ML
author paulson
Fri Sep 13 13:22:08 1996 +0200 (1996-09-13)
changeset 1997 6efba890341e
parent 1967 0ff58b41c037
child 1999 b5efc4108d04
permissions -rw-r--r--
No longer assumes Alice is not the Enemy in NS3.
Proofs do not need it, and the assumption complicated the liveness argument
paulson@1934
     1
(*  Title:      HOL/Auth/NS_Shared
paulson@1934
     2
    ID:         $Id$
paulson@1934
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@1934
     4
    Copyright   1996  University of Cambridge
paulson@1934
     5
paulson@1934
     6
Inductive relation "ns_shared" for Needham-Schroeder Shared-Key protocol.
paulson@1934
     7
paulson@1934
     8
From page 247 of
paulson@1934
     9
  Burrows, Abadi and Needham.  A Logic of Authentication.
paulson@1934
    10
  Proc. Royal Soc. 426 (1989)
paulson@1934
    11
*)
paulson@1934
    12
paulson@1934
    13
open NS_Shared;
paulson@1934
    14
paulson@1943
    15
proof_timing:=true;
paulson@1997
    16
HOL_quantifiers := false;
paulson@1997
    17
paulson@1997
    18
(** Weak liveness: there are traces that reach the end **)
paulson@1997
    19
paulson@1997
    20
goal thy 
paulson@1997
    21
 "!!A B. [| A ~= B; A ~= Server; B ~= Server |]   \
paulson@1997
    22
\        ==> EX N K. EX evs: ns_shared.          \
paulson@1997
    23
\               Says A B (Crypt {|Nonce N, Nonce N|} K) : set_of_list evs";
paulson@1997
    24
by (REPEAT (resolve_tac [exI,bexI] 1));
paulson@1997
    25
br (ns_shared.Nil RS ns_shared.NS1 RS ns_shared.NS2 RS ns_shared.NS3 RS ns_shared.NS4 RS ns_shared.NS5) 2;
paulson@1997
    26
by (ALLGOALS (simp_tac (!simpset setsolver safe_solver)));
paulson@1997
    27
by (REPEAT_FIRST (resolve_tac [refl, conjI]));
paulson@1997
    28
by (ALLGOALS (fast_tac (!claset addss (!simpset setsolver safe_solver))));
paulson@1997
    29
qed "weak_liveness";
paulson@1943
    30
paulson@1934
    31
(**** Inductive proofs about ns_shared ****)
paulson@1934
    32
paulson@1934
    33
(*The Enemy can see more than anybody else, except for their initial state*)
paulson@1934
    34
goal thy 
paulson@1934
    35
 "!!evs. evs : ns_shared ==> \
paulson@1934
    36
\     sees A evs <= initState A Un sees Enemy evs";
paulson@1934
    37
be ns_shared.induct 1;
paulson@1934
    38
by (ALLGOALS (fast_tac (!claset addDs [sees_Says_subset_insert RS subsetD] 
paulson@1934
    39
			        addss (!simpset))));
paulson@1934
    40
qed "sees_agent_subset_sees_Enemy";
paulson@1934
    41
paulson@1934
    42
paulson@1934
    43
(*Nobody sends themselves messages*)
paulson@1934
    44
goal thy "!!evs. evs : ns_shared ==> ALL A X. Says A A X ~: set_of_list evs";
paulson@1934
    45
be ns_shared.induct 1;
paulson@1934
    46
by (Auto_tac());
paulson@1934
    47
qed_spec_mp "not_Says_to_self";
paulson@1934
    48
Addsimps [not_Says_to_self];
paulson@1934
    49
AddSEs   [not_Says_to_self RSN (2, rev_notE)];
paulson@1934
    50
paulson@1934
    51
goal thy "!!evs. evs : ns_shared ==> Notes A X ~: set_of_list evs";
paulson@1934
    52
be ns_shared.induct 1;
paulson@1934
    53
by (Auto_tac());
paulson@1934
    54
qed "not_Notes";
paulson@1934
    55
Addsimps [not_Notes];
paulson@1934
    56
AddSEs   [not_Notes RSN (2, rev_notE)];
paulson@1934
    57
paulson@1934
    58
paulson@1943
    59
(*For reasoning about the encrypted portion of message NS3*)
paulson@1934
    60
goal thy "!!evs. (Says S A (Crypt {|N, B, K, X|} KA)) : set_of_list evs ==> \
paulson@1934
    61
\                X : parts (sees Enemy evs)";
paulson@1934
    62
by (fast_tac (!claset addSEs partsEs
paulson@1934
    63
	              addSDs [Says_imp_sees_Enemy RS parts.Inj]) 1);
paulson@1934
    64
qed "NS3_msg_in_parts_sees_Enemy";
paulson@1934
    65
			      
paulson@1934
    66
paulson@1943
    67
(*** Shared keys are not betrayed ***)
paulson@1934
    68
paulson@1943
    69
(*Enemy never sees another agent's shared key!*)
paulson@1934
    70
goal thy 
paulson@1967
    71
 "!!evs. [| evs : ns_shared; A ~: bad |] ==> \
paulson@1943
    72
\        Key (shrK A) ~: parts (sees Enemy evs)";
paulson@1934
    73
be ns_shared.induct 1;
paulson@1934
    74
bd NS3_msg_in_parts_sees_Enemy 5;
paulson@1934
    75
by (Auto_tac());
paulson@1934
    76
(*Deals with Fake message*)
paulson@1934
    77
by (best_tac (!claset addDs [impOfSubs analz_subset_parts,
paulson@1943
    78
			     impOfSubs Fake_parts_insert]) 1);
paulson@1943
    79
qed "Enemy_not_see_shrK";
paulson@1934
    80
paulson@1943
    81
bind_thm ("Enemy_not_analz_shrK",
paulson@1943
    82
	  [analz_subset_parts, Enemy_not_see_shrK] MRS contra_subsetD);
paulson@1934
    83
paulson@1967
    84
Addsimps [Enemy_not_see_shrK, Enemy_not_analz_shrK];
paulson@1934
    85
paulson@1965
    86
(*We go to some trouble to preserve R in the 3rd and 4th subgoals
paulson@1967
    87
  As usual fast_tac cannot be used because it uses the equalities too soon*)
paulson@1934
    88
val major::prems = 
paulson@1965
    89
goal thy  "[| Key (shrK A) : parts (sees Enemy evs);       \
paulson@1965
    90
\             evs : ns_shared;                             \
paulson@1967
    91
\             A:bad ==> R                                  \
paulson@1934
    92
\           |] ==> R";
paulson@1934
    93
br ccontr 1;
paulson@1943
    94
br ([major, Enemy_not_see_shrK] MRS rev_notE) 1;
paulson@1934
    95
by (swap_res_tac prems 2);
paulson@1967
    96
by (ALLGOALS (fast_tac (!claset addIs prems)));
paulson@1943
    97
qed "Enemy_see_shrK_E";
paulson@1934
    98
paulson@1943
    99
bind_thm ("Enemy_analz_shrK_E", 
paulson@1943
   100
	  analz_subset_parts RS subsetD RS Enemy_see_shrK_E);
paulson@1934
   101
paulson@1943
   102
AddSEs [Enemy_see_shrK_E, Enemy_analz_shrK_E];
paulson@1934
   103
paulson@1934
   104
paulson@1934
   105
goal thy  
paulson@1965
   106
 "!!evs. evs : ns_shared ==>                              \
paulson@1967
   107
\        (Key (shrK A) : analz (sees Enemy evs)) = (A : bad)";
paulson@1934
   108
by (best_tac (!claset addDs [impOfSubs analz_subset_parts]
paulson@1934
   109
		      addIs [impOfSubs (subset_insertI RS analz_mono)]
paulson@1934
   110
	              addss (!simpset)) 1);
paulson@1943
   111
qed "shrK_mem_analz";
paulson@1934
   112
paulson@1967
   113
Addsimps [shrK_mem_analz];
paulson@1967
   114
paulson@1934
   115
paulson@1934
   116
(*** Future keys can't be seen or used! ***)
paulson@1934
   117
paulson@1934
   118
(*Nobody can have SEEN keys that will be generated in the future.
paulson@1934
   119
  This has to be proved anew for each protocol description,
paulson@1934
   120
  but should go by similar reasoning every time.  Hardest case is the
paulson@1934
   121
  standard Fake rule.  
paulson@1934
   122
      The length comparison, and Union over C, are essential for the 
paulson@1934
   123
  induction! *)
paulson@1934
   124
goal thy "!!evs. evs : ns_shared ==> \
paulson@1934
   125
\                length evs <= length evs' --> \
paulson@1934
   126
\                          Key (newK evs') ~: (UN C. parts (sees C evs))";
paulson@1934
   127
be ns_shared.induct 1;
paulson@1934
   128
bd NS3_msg_in_parts_sees_Enemy 5;
paulson@1934
   129
(*auto_tac does not work here, as it performs safe_tac first*)
paulson@1934
   130
by (ALLGOALS Asm_simp_tac);
paulson@1934
   131
by (ALLGOALS (best_tac (!claset addDs [impOfSubs analz_subset_parts,
paulson@1934
   132
				       impOfSubs parts_insert_subset_Un,
paulson@1934
   133
				       Suc_leD]
paulson@1934
   134
			        addss (!simpset))));
paulson@1934
   135
val lemma = result();
paulson@1934
   136
paulson@1934
   137
(*Variant needed for the main theorem below*)
paulson@1934
   138
goal thy 
paulson@1934
   139
 "!!evs. [| evs : ns_shared;  length evs <= length evs' |] ==> \
paulson@1934
   140
\        Key (newK evs') ~: parts (sees C evs)";
paulson@1934
   141
by (fast_tac (!claset addDs [lemma]) 1);
paulson@1934
   142
qed "new_keys_not_seen";
paulson@1934
   143
Addsimps [new_keys_not_seen];
paulson@1934
   144
paulson@1934
   145
(*Another variant: old messages must contain old keys!*)
paulson@1934
   146
goal thy 
paulson@1934
   147
 "!!evs. [| Says A B X : set_of_list evs;  \
paulson@1934
   148
\           Key (newK evt) : parts {X};    \
paulson@1934
   149
\           evs : ns_shared                 \
paulson@1934
   150
\        |] ==> length evt < length evs";
paulson@1934
   151
br ccontr 1;
paulson@1934
   152
by (fast_tac (!claset addSDs [new_keys_not_seen, Says_imp_sees_Enemy]
paulson@1934
   153
	              addIs [impOfSubs parts_mono, leI]) 1);
paulson@1934
   154
qed "Says_imp_old_keys";
paulson@1934
   155
paulson@1934
   156
paulson@1934
   157
(*Nobody can have USED keys that will be generated in the future.
paulson@1934
   158
  ...very like new_keys_not_seen*)
paulson@1934
   159
goal thy "!!evs. evs : ns_shared ==> \
paulson@1934
   160
\                length evs <= length evs' --> \
paulson@1934
   161
\                newK evs' ~: keysFor (UN C. parts (sees C evs))";
paulson@1934
   162
be ns_shared.induct 1;
paulson@1934
   163
bd NS3_msg_in_parts_sees_Enemy 5;
paulson@1934
   164
by (ALLGOALS Asm_simp_tac);
paulson@1934
   165
(*NS1 and NS2*)
paulson@1934
   166
map (by o fast_tac (!claset addDs [Suc_leD] addss (!simpset))) [3,2];
paulson@1934
   167
(*Fake and NS3*)
paulson@1934
   168
map (by o best_tac
paulson@1997
   169
     (!claset addDs [impOfSubs (analz_subset_parts RS keysFor_mono),
paulson@1934
   170
		     impOfSubs (parts_insert_subset_Un RS keysFor_mono),
paulson@1934
   171
		     Suc_leD]
paulson@1934
   172
	      addEs [new_keys_not_seen RS not_parts_not_analz RSN (2,rev_notE)]
paulson@1934
   173
	      addss (!simpset)))
paulson@1934
   174
    [2,1];
paulson@1934
   175
(*NS4 and NS5: nonce exchange*)
paulson@1997
   176
by (ALLGOALS (deepen_tac (!claset addSDs [Says_imp_old_keys]
paulson@1934
   177
	                          addIs  [less_SucI, impOfSubs keysFor_mono]
paulson@1934
   178
		                  addss (!simpset addsimps [le_def])) 0));
paulson@1934
   179
val lemma = result();
paulson@1934
   180
paulson@1934
   181
goal thy 
paulson@1934
   182
 "!!evs. [| evs : ns_shared;  length evs <= length evs' |] ==> \
paulson@1934
   183
\        newK evs' ~: keysFor (parts (sees C evs))";
paulson@1934
   184
by (fast_tac (!claset addSDs [lemma] addss (!simpset)) 1);
paulson@1934
   185
qed "new_keys_not_used";
paulson@1934
   186
paulson@1934
   187
bind_thm ("new_keys_not_analzd",
paulson@1934
   188
	  [analz_subset_parts RS keysFor_mono,
paulson@1934
   189
	   new_keys_not_used] MRS contra_subsetD);
paulson@1934
   190
paulson@1934
   191
Addsimps [new_keys_not_used, new_keys_not_analzd];
paulson@1934
   192
paulson@1934
   193
paulson@1934
   194
(** Lemmas concerning the form of items passed in messages **)
paulson@1934
   195
paulson@1934
   196
(*Describes the form *and age* of K, and the form of X,
paulson@1934
   197
  when the following message is sent*)
paulson@1934
   198
goal thy 
paulson@1934
   199
 "!!evs. [| Says Server A (Crypt {|N, Agent B, K, X|} K') : set_of_list evs; \
paulson@1934
   200
\           evs : ns_shared    \
paulson@1934
   201
\        |] ==> (EX evt:ns_shared. \
paulson@1934
   202
\                         K = Key(newK evt) & \
paulson@1943
   203
\                         X = (Crypt {|K, Agent A|} (shrK B)) & \
paulson@1943
   204
\                         K' = shrK A & \
paulson@1934
   205
\                         length evt < length evs)";
paulson@1934
   206
be rev_mp 1;
paulson@1934
   207
be ns_shared.induct 1;
paulson@1934
   208
by (ALLGOALS (fast_tac (!claset addIs [less_SucI] addss (!simpset))));
paulson@1934
   209
qed "Says_Server_message_form";
paulson@1934
   210
paulson@1934
   211
paulson@1943
   212
(*Describes the form of X when the following message is sent.  The use of
paulson@1965
   213
  "parts" strengthens the induction hyp for proving the Fake case.  The
paulson@1965
   214
  assumptions on A are needed to prevent its being a Faked message.*)
paulson@1934
   215
goal thy
paulson@1965
   216
 "!!evs. evs : ns_shared ==>                                              \
paulson@1965
   217
\        ALL A NA B K X.                                                  \
paulson@1967
   218
\            Crypt {|Nonce NA, Agent B, Key K, X|} (shrK A)               \
paulson@1965
   219
\               : parts (sees Enemy evs) &                                \
paulson@1967
   220
\            A ~: bad --> \
paulson@1934
   221
\          (EX evt:ns_shared. K = newK evt & \
paulson@1943
   222
\                             X = (Crypt {|Key K, Agent A|} (shrK B)))";
paulson@1934
   223
be ns_shared.induct 1;
paulson@1934
   224
bd NS3_msg_in_parts_sees_Enemy 5;
paulson@1934
   225
by (Step_tac 1);
paulson@1934
   226
by (ALLGOALS Asm_full_simp_tac);
paulson@1965
   227
by (fast_tac (!claset addss (!simpset)) 1);
paulson@1934
   228
(*Remaining cases are Fake and NS2*)
paulson@1934
   229
by (fast_tac (!claset addSDs [spec]) 2);
paulson@1934
   230
(*Now for the Fake case*)
paulson@1967
   231
by (best_tac (!claset addSDs [impOfSubs Fake_parts_insert]
paulson@1967
   232
	              addDs  [impOfSubs analz_subset_parts]
paulson@1967
   233
	              addss  (!simpset)) 1);
paulson@1934
   234
qed_spec_mp "encrypted_form";
paulson@1934
   235
paulson@1934
   236
paulson@1965
   237
(*If such a message is sent with a bad key then the Enemy sees it (even if
paulson@1965
   238
  he didn't send it in the first place).*)
paulson@1965
   239
goal thy
paulson@1967
   240
 "!!evs. [| Says S A (Crypt {|N, B, K, X|} (shrK A)) : set_of_list evs;   \
paulson@1967
   241
\           A : bad |]                                                    \
paulson@1965
   242
\        ==> X : analz (sees Enemy evs)";
paulson@1965
   243
by (fast_tac (!claset addSDs [Says_imp_sees_Enemy RS analz.Inj]
paulson@1965
   244
	              addss (!simpset)) 1);
paulson@1965
   245
qed_spec_mp "bad_encrypted_form";
paulson@1934
   246
paulson@1934
   247
paulson@1965
   248
paulson@1965
   249
(*EITHER describes the form of X when the following message is sent, 
paulson@1965
   250
  OR     reduces it to the Fake case.
paulson@1965
   251
  Use Says_Server_message_form if applicable.*)
paulson@1934
   252
goal thy 
paulson@1943
   253
 "!!evs. [| Says S A (Crypt {|Nonce NA, Agent B, Key K, X|} (shrK A))    \
paulson@1965
   254
\            : set_of_list evs;  evs : ns_shared |]                      \
paulson@1943
   255
\        ==> (EX evt:ns_shared. K = newK evt & length evt < length evs & \
paulson@1965
   256
\                               X = (Crypt {|Key K, Agent A|} (shrK B))) | \
paulson@1965
   257
\            X : analz (sees Enemy evs)";
paulson@1967
   258
by (excluded_middle_tac "A : bad" 1);
paulson@1965
   259
by (fast_tac (!claset addIs [bad_encrypted_form]) 2);
paulson@1934
   260
by (forward_tac [encrypted_form] 1);
paulson@1934
   261
br (parts.Inj RS conjI) 1;
paulson@1934
   262
by (auto_tac (!claset addIs [Says_imp_old_keys], !simpset));
paulson@1934
   263
qed "Says_S_message_form";
paulson@1934
   264
paulson@1934
   265
paulson@1934
   266
paulson@1934
   267
(****
paulson@1934
   268
 The following is to prove theorems of the form
paulson@1934
   269
paulson@1965
   270
          Key K : analz (insert (Key (newK evt)) (sees Enemy evs)) ==>
paulson@1965
   271
          Key K : analz (sees Enemy evs)
paulson@1934
   272
paulson@1934
   273
 A more general formula must be proved inductively.
paulson@1934
   274
paulson@1934
   275
****)
paulson@1934
   276
paulson@1934
   277
paulson@1934
   278
(*NOT useful in this form, but it says that session keys are not used
paulson@1934
   279
  to encrypt messages containing other keys, in the actual protocol.
paulson@1934
   280
  We require that agents should behave like this subsequently also.*)
paulson@1934
   281
goal thy 
paulson@1934
   282
 "!!evs. evs : ns_shared ==> \
paulson@1934
   283
\        (Crypt X (newK evt)) : parts (sees Enemy evs) & \
paulson@1934
   284
\        Key K : parts {X} --> Key K : parts (sees Enemy evs)";
paulson@1934
   285
be ns_shared.induct 1;
paulson@1934
   286
bd NS3_msg_in_parts_sees_Enemy 5;
paulson@1934
   287
by (ALLGOALS (asm_simp_tac (!simpset addsimps pushes)));
paulson@1934
   288
(*Deals with Faked messages*)
paulson@1934
   289
by (best_tac (!claset addSEs partsEs
paulson@1934
   290
		      addDs [impOfSubs analz_subset_parts,
paulson@1934
   291
                             impOfSubs parts_insert_subset_Un]
paulson@1965
   292
                      addss (!simpset)) 2);
paulson@1965
   293
(*Base, NS4 and NS5*)
paulson@1934
   294
by (ALLGOALS (fast_tac (!claset addss (!simpset))));
paulson@1934
   295
result();
paulson@1934
   296
paulson@1934
   297
paulson@1934
   298
(** Specialized rewriting for this proof **)
paulson@1934
   299
paulson@1934
   300
Delsimps [image_insert];
paulson@1934
   301
Addsimps [image_insert RS sym];
paulson@1934
   302
paulson@1965
   303
Delsimps [image_Un];
paulson@1965
   304
Addsimps [image_Un RS sym];
paulson@1965
   305
paulson@1934
   306
goal thy "insert (Key (newK x)) (sees A evs) = \
paulson@1934
   307
\         Key `` (newK``{x}) Un (sees A evs)";
paulson@1934
   308
by (Fast_tac 1);
paulson@1934
   309
val insert_Key_singleton = result();
paulson@1934
   310
paulson@1934
   311
goal thy "insert (Key (f x)) (Key``(f``E) Un C) = \
paulson@1934
   312
\         Key `` (f `` (insert x E)) Un C";
paulson@1934
   313
by (Fast_tac 1);
paulson@1934
   314
val insert_Key_image = result();
paulson@1934
   315
paulson@1934
   316
paulson@1934
   317
(** Session keys are not used to encrypt other session keys **)
paulson@1934
   318
paulson@1943
   319
(*Lemma for the trivial direction of the if-and-only-if*)
paulson@1943
   320
goal thy  
paulson@1965
   321
 "!!evs. (Key K : analz (Key``nE Un sEe)) --> \
paulson@1965
   322
\         (K : nE | Key K : analz sEe)  ==>     \
paulson@1965
   323
\        (Key K : analz (Key``nE Un sEe)) = (K : nE | Key K : analz sEe)";
paulson@1943
   324
by (fast_tac (!claset addSEs [impOfSubs analz_mono]) 1);
paulson@1943
   325
val lemma = result();
paulson@1943
   326
paulson@1934
   327
goal thy  
paulson@1934
   328
 "!!evs. evs : ns_shared ==> \
paulson@1965
   329
\  ALL K E. (Key K : analz (Key``(newK``E) Un (sees Enemy evs))) = \
paulson@1965
   330
\           (K : newK``E | Key K : analz (sees Enemy evs))";
paulson@1934
   331
be ns_shared.induct 1;
paulson@1934
   332
by (forward_tac [Says_S_message_form] 5 THEN assume_tac 5);	
paulson@1965
   333
by (REPEAT ((eresolve_tac [bexE, conjE, disjE] ORELSE' hyp_subst_tac) 5));
paulson@1943
   334
by (REPEAT_FIRST (resolve_tac [allI, lemma]));
paulson@1934
   335
by (ALLGOALS 
paulson@1934
   336
    (asm_simp_tac 
paulson@1934
   337
     (!simpset addsimps ([insert_Key_singleton, insert_Key_image, pushKey_newK]
paulson@1934
   338
			 @ pushes)
paulson@1934
   339
               setloop split_tac [expand_if])));
paulson@1943
   340
(** LEVEL 5 **)
paulson@1965
   341
(*NS3, Fake subcase*)
paulson@1965
   342
by (enemy_analz_tac 5);
paulson@1934
   343
(*Cases NS2 and NS3!!  Simple, thanks to auto case splits*)
paulson@1934
   344
by (REPEAT (Fast_tac 3));
paulson@1965
   345
(*Fake case*) (** LEVEL 7 **)
paulson@1965
   346
by (enemy_analz_tac 2);
paulson@1934
   347
(*Base case*)
paulson@1934
   348
by (fast_tac (!claset addIs [image_eqI] addss (!simpset)) 1);
paulson@1934
   349
qed_spec_mp "analz_image_newK";
paulson@1934
   350
paulson@1934
   351
paulson@1934
   352
goal thy
paulson@1934
   353
 "!!evs. evs : ns_shared ==>                               \
paulson@1965
   354
\        Key K : analz (insert (Key (newK evt)) (sees Enemy evs)) = \
paulson@1965
   355
\        (K = newK evt | Key K : analz (sees Enemy evs))";
paulson@1934
   356
by (asm_simp_tac (HOL_ss addsimps [pushKey_newK, analz_image_newK, 
paulson@1934
   357
				   insert_Key_singleton]) 1);
paulson@1934
   358
by (Fast_tac 1);
paulson@1934
   359
qed "analz_insert_Key_newK";
paulson@1934
   360
paulson@1934
   361
paulson@1965
   362
(** First, two lemmas for the Fake and NS3 cases **)
paulson@1965
   363
paulson@1965
   364
goal thy 
paulson@1965
   365
 "!!evs. [| X : synth (analz (sees Enemy evs));                \
paulson@1965
   366
\           Crypt X' (shrK C) : parts{X};                      \
paulson@1967
   367
\           C ~: bad;  evs : ns_shared |]  \
paulson@1965
   368
\        ==> Crypt X' (shrK C) : parts (sees Enemy evs)";
paulson@1965
   369
by (best_tac (!claset addSEs [impOfSubs analz_subset_parts]
paulson@1965
   370
	              addDs [impOfSubs parts_insert_subset_Un]
paulson@1965
   371
                      addss (!simpset)) 1);
paulson@1965
   372
qed "Crypt_Fake_parts";
paulson@1965
   373
paulson@1965
   374
goal thy 
paulson@1965
   375
 "!!evs. [| Crypt X' K : parts (sees A evs);  evs : ns_shared |]  \
paulson@1965
   376
\        ==> EX S S' Y. Says S S' Y : set_of_list evs &       \
paulson@1965
   377
\            Crypt X' K : parts {Y}";
paulson@1965
   378
bd parts_singleton 1;
paulson@1965
   379
by (fast_tac (!claset addSDs [seesD] addss (!simpset)) 1);
paulson@1965
   380
qed "Crypt_parts_singleton";
paulson@1965
   381
paulson@1965
   382
fun ex_strip_tac i = REPEAT (ares_tac [exI, conjI] i) THEN assume_tac (i+1);
paulson@1934
   383
paulson@1934
   384
(*This says that the Key, K, uniquely identifies the message.
paulson@1965
   385
    But if Enemy knows C's key then he could send all sorts of nonsense.*)
paulson@1934
   386
goal thy 
paulson@1934
   387
 "!!evs. evs : ns_shared ==>                      \
paulson@1967
   388
\      EX X'. ALL C.                              \
paulson@1967
   389
\       C ~: bad -->                              \
paulson@1965
   390
\        (ALL S A Y. Says S A Y : set_of_list evs -->     \
paulson@1965
   391
\         (ALL N B X. Crypt {|N, Agent B, Key K, X|} (shrK C) : parts{Y} --> \
paulson@1965
   392
\          X=X'))";
paulson@1934
   393
be ns_shared.induct 1;
paulson@1934
   394
by (forward_tac [Says_S_message_form] 5 THEN assume_tac 5);	
paulson@1934
   395
by (ALLGOALS 
paulson@1934
   396
    (asm_simp_tac (!simpset addsimps [all_conj_distrib, imp_conj_distrib])));
paulson@1965
   397
by (REPEAT_FIRST (eresolve_tac [exE,disjE]));
paulson@1965
   398
(*NS3: Fake (compromised) case*)
paulson@1965
   399
by (ex_strip_tac 4);
paulson@1965
   400
by (fast_tac (!claset addSDs [synth.Inj RS Crypt_Fake_parts, 
paulson@1965
   401
			      Crypt_parts_singleton]) 4);
paulson@1965
   402
(*NS3: Good case, no relevant messages*)
paulson@1965
   403
by (fast_tac (!claset addSEs [exI] addss (!simpset)) 3);
paulson@1934
   404
(*NS2: Case split propagates some context to other subgoal...*)
paulson@1934
   405
by (excluded_middle_tac "K = newK evsa" 2);
paulson@1934
   406
by (Asm_simp_tac 2);
paulson@1965
   407
be exI 2;
paulson@1934
   408
(*...we assume X is a very new message, and handle this case by contradiction*)
paulson@1934
   409
by (fast_tac (!claset addIs [impOfSubs (subset_insertI RS parts_mono)]
paulson@1934
   410
		      addSEs partsEs
paulson@1934
   411
		      addEs [Says_imp_old_keys RS less_irrefl]
paulson@1934
   412
	              addss (!simpset)) 2);
paulson@1965
   413
(*Fake*) (** LEVEL 11 **)
paulson@1965
   414
by (ex_strip_tac 1);
paulson@1965
   415
by (fast_tac (!claset addSDs [Crypt_Fake_parts, Crypt_parts_singleton]) 1);
paulson@1934
   416
val lemma = result();
paulson@1934
   417
paulson@1934
   418
paulson@1934
   419
(*In messages of this form, the session key uniquely identifies the rest*)
paulson@1934
   420
goal thy 
paulson@1934
   421
 "!!evs. [| Says S A          \
paulson@1943
   422
\             (Crypt {|N, Agent B, Key K, X|} (shrK C))     \
paulson@1965
   423
\                  : set_of_list evs; \ 
paulson@1965
   424
\           Says S' A'                                         \
paulson@1943
   425
\             (Crypt {|N', Agent B', Key K, X'|} (shrK C')) \
paulson@1934
   426
\                  : set_of_list evs;                         \
paulson@1967
   427
\           evs : ns_shared;  C ~= Enemy;  C ~: bad;  C' ~: bad |] ==> X = X'";
paulson@1934
   428
bd lemma 1;
paulson@1934
   429
be exE 1;
paulson@1965
   430
(*Duplicate the assumption*)
paulson@1934
   431
by (forw_inst_tac [("psi", "ALL C.?P(C)")] asm_rl 1);
paulson@1965
   432
(*Are these instantiations essential?*)
paulson@1965
   433
by (dres_inst_tac [("x","C")] spec 1);
paulson@1965
   434
by (dres_inst_tac [("x","C'")] spec 1);
paulson@1965
   435
by (fast_tac (!claset addSDs [spec]) 1);
paulson@1934
   436
qed "unique_session_keys";
paulson@1934
   437
paulson@1934
   438
paulson@1934
   439
paulson@1965
   440
(*Crucial secrecy property: Enemy does not see the keys sent in msg NS2*)
paulson@1934
   441
goal thy 
paulson@1967
   442
 "!!evs. [| Says Server A                                       \
paulson@1967
   443
\            (Crypt {|N, Agent B, K, X|} K') : set_of_list evs;  \
paulson@1967
   444
\           A ~: bad;  B ~: bad;  evs : ns_shared                  \
paulson@1965
   445
\        |] ==>                                                          \
paulson@1965
   446
\     K ~: analz (sees Enemy evs)";
paulson@1934
   447
be rev_mp 1;
paulson@1934
   448
be ns_shared.induct 1;
paulson@1965
   449
by (ALLGOALS Asm_simp_tac);
paulson@1934
   450
(*Next 3 steps infer that K has the form "Key (newK evs'" ... *)
paulson@1934
   451
by (REPEAT_FIRST (resolve_tac [conjI, impI]));
paulson@1934
   452
by (TRYALL (forward_tac [Says_Server_message_form] THEN' assume_tac));
paulson@1934
   453
by (REPEAT_FIRST (eresolve_tac [bexE, conjE] ORELSE' hyp_subst_tac));
paulson@1934
   454
by (ALLGOALS 
paulson@1934
   455
    (asm_full_simp_tac 
paulson@1934
   456
     (!simpset addsimps ([analz_subset_parts RS contra_subsetD,
paulson@1934
   457
			  analz_insert_Key_newK] @ pushes)
paulson@1934
   458
               setloop split_tac [expand_if])));
paulson@1934
   459
(*NS2*)
paulson@1934
   460
by (fast_tac (!claset addSEs [less_irrefl]) 2);
paulson@1965
   461
(*Fake case*) (** LEVEL 8 **)
paulson@1965
   462
by (enemy_analz_tac 1);
paulson@1934
   463
(*NS3: that message from the Server was sent earlier*)
paulson@1934
   464
by (mp_tac 1);
paulson@1934
   465
by (forward_tac [Says_S_message_form] 1 THEN assume_tac 1);
paulson@1967
   466
by (Step_tac 1);
paulson@1965
   467
by (enemy_analz_tac 2);		(*Prove the Fake subcase*)
paulson@1934
   468
by (asm_full_simp_tac
paulson@1934
   469
    (!simpset addsimps (mem_if::analz_insert_Key_newK::pushes)) 1);
paulson@1967
   470
by (Step_tac 1);
paulson@1965
   471
(**LEVEL 15 **)
paulson@1997
   472
by (excluded_middle_tac "Aa : bad" 1);
paulson@1967
   473
(*But this contradicts Key (newK evta) ~: analz (sees Enemy evsa) *)
paulson@1965
   474
bd (Says_imp_sees_Enemy RS analz.Inj) 2;
paulson@1965
   475
bd analz.Decrypt 2;
paulson@1967
   476
by (Asm_full_simp_tac 2);
paulson@1965
   477
by (Fast_tac 2);
paulson@1967
   478
(*So now we know that (Friend i) is a good agent*)
paulson@1934
   479
bd unique_session_keys 1;
paulson@1934
   480
by (REPEAT_FIRST assume_tac);
paulson@1967
   481
by (Auto_tac ());
paulson@1934
   482
qed "Enemy_not_see_encrypted_key";