src/HOL/Auth/Yahalom2.ML
author paulson
Fri Oct 18 11:43:14 1996 +0200 (1996-10-18)
changeset 2111 81c8d46edfa3
child 2155 dc85854810eb
permissions -rw-r--r--
New version of Yahalom, as recommended on p 259 of BAN paper
paulson@2111
     1
(*  Title:      HOL/Auth/Yahalom2
paulson@2111
     2
    ID:         $Id$
paulson@2111
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@2111
     4
    Copyright   1996  University of Cambridge
paulson@2111
     5
paulson@2111
     6
Inductive relation "yahalom" for the Yahalom protocol, Variant 2.
paulson@2111
     7
paulson@2111
     8
This version trades encryption of NB for additional explicitness in YM3.
paulson@2111
     9
paulson@2111
    10
From page 259 of
paulson@2111
    11
  Burrows, Abadi and Needham.  A Logic of Authentication.
paulson@2111
    12
  Proc. Royal Soc. 426 (1989)
paulson@2111
    13
*)
paulson@2111
    14
paulson@2111
    15
open Yahalom2;
paulson@2111
    16
paulson@2111
    17
proof_timing:=true;
paulson@2111
    18
HOL_quantifiers := false;
paulson@2111
    19
paulson@2111
    20
paulson@2111
    21
(*Weak liveness: there are traces that reach the end*)
paulson@2111
    22
paulson@2111
    23
goal thy 
paulson@2111
    24
 "!!A B. [| A ~= B; A ~= Server; B ~= Server |]   \
paulson@2111
    25
\        ==> EX X NB K. EX evs: yahalom lost.          \
paulson@2111
    26
\               Says A B {|X, Crypt (Nonce NB) K|} : set_of_list evs";
paulson@2111
    27
by (REPEAT (resolve_tac [exI,bexI] 1));
paulson@2111
    28
by (rtac (yahalom.Nil RS yahalom.YM1 RS yahalom.YM2 RS yahalom.YM3 RS yahalom.YM4) 2);
paulson@2111
    29
by (ALLGOALS (simp_tac (!simpset setsolver safe_solver)));
paulson@2111
    30
by (ALLGOALS Fast_tac);
paulson@2111
    31
result();
paulson@2111
    32
paulson@2111
    33
paulson@2111
    34
(**** Inductive proofs about yahalom ****)
paulson@2111
    35
paulson@2111
    36
(*Monotonicity*)
paulson@2111
    37
goal thy "!!evs. lost' <= lost ==> yahalom lost' <= yahalom lost";
paulson@2111
    38
by (rtac subsetI 1);
paulson@2111
    39
by (etac yahalom.induct 1);
paulson@2111
    40
by (REPEAT_FIRST
paulson@2111
    41
    (best_tac (!claset addIs (impOfSubs (sees_mono RS analz_mono RS synth_mono)
paulson@2111
    42
                              :: yahalom.intrs))));
paulson@2111
    43
qed "yahalom_mono";
paulson@2111
    44
paulson@2111
    45
paulson@2111
    46
(*Nobody sends themselves messages*)
paulson@2111
    47
goal thy "!!evs. evs: yahalom lost ==> ALL A X. Says A A X ~: set_of_list evs";
paulson@2111
    48
by (etac yahalom.induct 1);
paulson@2111
    49
by (Auto_tac());
paulson@2111
    50
qed_spec_mp "not_Says_to_self";
paulson@2111
    51
Addsimps [not_Says_to_self];
paulson@2111
    52
AddSEs   [not_Says_to_self RSN (2, rev_notE)];
paulson@2111
    53
paulson@2111
    54
paulson@2111
    55
(** For reasoning about the encrypted portion of messages **)
paulson@2111
    56
paulson@2111
    57
(*Lets us treat YM4 using a similar argument as for the Fake case.*)
paulson@2111
    58
goal thy "!!evs. Says S A {|NB, Crypt Y (shrK A), X|} : set_of_list evs ==> \
paulson@2111
    59
\                X : analz (sees lost Spy evs)";
paulson@2111
    60
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS analz.Inj]) 1);
paulson@2111
    61
qed "YM4_analz_sees_Spy";
paulson@2111
    62
paulson@2111
    63
bind_thm ("YM4_parts_sees_Spy",
paulson@2111
    64
          YM4_analz_sees_Spy RS (impOfSubs analz_subset_parts));
paulson@2111
    65
paulson@2111
    66
(*Relates to both YM4 and Revl*)
paulson@2111
    67
goal thy "!!evs. Says S A {|NB, Crypt {|B, K, NA|} (shrK A), X|} \
paulson@2111
    68
\                  : set_of_list evs ==> \
paulson@2111
    69
\                K : parts (sees lost Spy evs)";
paulson@2111
    70
by (fast_tac (!claset addSEs partsEs
paulson@2111
    71
                      addSDs [Says_imp_sees_Spy RS parts.Inj]) 1);
paulson@2111
    72
qed "YM4_Key_parts_sees_Spy";
paulson@2111
    73
paulson@2111
    74
(*We instantiate the variable to "lost".  Leaving it as a Var makes proofs
paulson@2111
    75
  harder: the simplifier does less.*)
paulson@2111
    76
val parts_Fake_tac = 
paulson@2111
    77
    forw_inst_tac [("lost","lost")] YM4_parts_sees_Spy 6 THEN
paulson@2111
    78
    forw_inst_tac [("lost","lost")] YM4_Key_parts_sees_Spy 7;
paulson@2111
    79
paulson@2111
    80
(*For proving the easier theorems about X ~: parts (sees lost Spy evs) *)
paulson@2111
    81
fun parts_induct_tac i = SELECT_GOAL
paulson@2111
    82
    (DETERM (etac yahalom.induct 1 THEN parts_Fake_tac THEN
paulson@2111
    83
	     (*Fake message*)
paulson@2111
    84
	     TRY (best_tac (!claset addDs [impOfSubs analz_subset_parts,
paulson@2111
    85
					   impOfSubs Fake_parts_insert]
paulson@2111
    86
                                    addss (!simpset)) 2)) THEN
paulson@2111
    87
     (*Base case*)
paulson@2111
    88
     fast_tac (!claset addss (!simpset)) 1 THEN
paulson@2111
    89
     ALLGOALS Asm_simp_tac) i;
paulson@2111
    90
paulson@2111
    91
paulson@2111
    92
(** Theorems of the form X ~: parts (sees lost Spy evs) imply that NOBODY
paulson@2111
    93
    sends messages containing X! **)
paulson@2111
    94
paulson@2111
    95
(*Spy never sees another agent's shared key! (unless it is leaked at start)*)
paulson@2111
    96
goal thy 
paulson@2111
    97
 "!!evs. [| evs : yahalom lost;  A ~: lost |]    \
paulson@2111
    98
\        ==> Key (shrK A) ~: parts (sees lost Spy evs)";
paulson@2111
    99
by (parts_induct_tac 1);
paulson@2111
   100
by (Auto_tac());
paulson@2111
   101
qed "Spy_not_see_shrK";
paulson@2111
   102
paulson@2111
   103
bind_thm ("Spy_not_analz_shrK",
paulson@2111
   104
          [analz_subset_parts, Spy_not_see_shrK] MRS contra_subsetD);
paulson@2111
   105
paulson@2111
   106
Addsimps [Spy_not_see_shrK, Spy_not_analz_shrK];
paulson@2111
   107
paulson@2111
   108
(*We go to some trouble to preserve R in the 3rd and 4th subgoals
paulson@2111
   109
  As usual fast_tac cannot be used because it uses the equalities too soon*)
paulson@2111
   110
val major::prems = 
paulson@2111
   111
goal thy  "[| Key (shrK A) : parts (sees lost Spy evs);       \
paulson@2111
   112
\             evs : yahalom lost;                               \
paulson@2111
   113
\             A:lost ==> R                                  \
paulson@2111
   114
\           |] ==> R";
paulson@2111
   115
by (rtac ccontr 1);
paulson@2111
   116
by (rtac ([major, Spy_not_see_shrK] MRS rev_notE) 1);
paulson@2111
   117
by (swap_res_tac prems 2);
paulson@2111
   118
by (ALLGOALS (fast_tac (!claset addIs prems)));
paulson@2111
   119
qed "Spy_see_shrK_E";
paulson@2111
   120
paulson@2111
   121
bind_thm ("Spy_analz_shrK_E", 
paulson@2111
   122
          analz_subset_parts RS subsetD RS Spy_see_shrK_E);
paulson@2111
   123
paulson@2111
   124
AddSEs [Spy_see_shrK_E, Spy_analz_shrK_E];
paulson@2111
   125
paulson@2111
   126
paulson@2111
   127
(*** Future keys can't be seen or used! ***)
paulson@2111
   128
paulson@2111
   129
(*Nobody can have SEEN keys that will be generated in the future.
paulson@2111
   130
  This has to be proved anew for each protocol description,
paulson@2111
   131
  but should go by similar reasoning every time.  Hardest case is the
paulson@2111
   132
  standard Fake rule.  
paulson@2111
   133
      The Union over C is essential for the induction! *)
paulson@2111
   134
goal thy "!!evs. evs : yahalom lost ==> \
paulson@2111
   135
\                length evs <= length evs' --> \
paulson@2111
   136
\                          Key (newK evs') ~: (UN C. parts (sees lost C evs))";
paulson@2111
   137
by (parts_induct_tac 1);
paulson@2111
   138
by (REPEAT_FIRST (best_tac (!claset addDs [impOfSubs analz_subset_parts,
paulson@2111
   139
                                           impOfSubs parts_insert_subset_Un,
paulson@2111
   140
                                           Suc_leD]
paulson@2111
   141
                                    addss (!simpset))));
paulson@2111
   142
val lemma = result();
paulson@2111
   143
paulson@2111
   144
(*Variant needed for the main theorem below*)
paulson@2111
   145
goal thy 
paulson@2111
   146
 "!!evs. [| evs : yahalom lost;  length evs <= length evs' |]    \
paulson@2111
   147
\        ==> Key (newK evs') ~: parts (sees lost C evs)";
paulson@2111
   148
by (fast_tac (!claset addDs [lemma]) 1);
paulson@2111
   149
qed "new_keys_not_seen";
paulson@2111
   150
Addsimps [new_keys_not_seen];
paulson@2111
   151
paulson@2111
   152
(*Another variant: old messages must contain old keys!*)
paulson@2111
   153
goal thy 
paulson@2111
   154
 "!!evs. [| Says A B X : set_of_list evs;  \
paulson@2111
   155
\           Key (newK evt) : parts {X};    \
paulson@2111
   156
\           evs : yahalom lost                 \
paulson@2111
   157
\        |] ==> length evt < length evs";
paulson@2111
   158
by (rtac ccontr 1);
paulson@2111
   159
by (dtac leI 1);
paulson@2111
   160
by (fast_tac (!claset addSDs [new_keys_not_seen, Says_imp_sees_Spy]
paulson@2111
   161
                      addIs  [impOfSubs parts_mono]) 1);
paulson@2111
   162
qed "Says_imp_old_keys";
paulson@2111
   163
paulson@2111
   164
paulson@2111
   165
(*Nobody can have USED keys that will be generated in the future.
paulson@2111
   166
  ...very like new_keys_not_seen*)
paulson@2111
   167
goal thy "!!evs. evs : yahalom lost ==> \
paulson@2111
   168
\                length evs <= length evs' --> \
paulson@2111
   169
\                newK evs' ~: keysFor (UN C. parts (sees lost C evs))";
paulson@2111
   170
by (parts_induct_tac 1);
paulson@2111
   171
by (dresolve_tac [YM4_Key_parts_sees_Spy] 5);
paulson@2111
   172
paulson@2111
   173
(*YM1, YM2 and YM3*)
paulson@2111
   174
by (EVERY (map (fast_tac (!claset addDs [Suc_leD] addss (!simpset))) [4,3,2]));
paulson@2111
   175
(*Fake and YM4: these messages send unknown (X) components*)
paulson@2111
   176
by (stac insert_commute 2);
paulson@2111
   177
by (Simp_tac 2);
paulson@2111
   178
(*YM4: the only way K could have been used is if it had been seen,
paulson@2111
   179
  contradicting new_keys_not_seen*)
paulson@2111
   180
by (REPEAT
paulson@2111
   181
     (best_tac
paulson@2111
   182
      (!claset addDs [impOfSubs analz_subset_parts,
paulson@2111
   183
                      impOfSubs (analz_subset_parts RS keysFor_mono),
paulson@2111
   184
                      impOfSubs (parts_insert_subset_Un RS keysFor_mono),
paulson@2111
   185
                      Suc_leD]
paulson@2111
   186
               addEs [new_keys_not_seen RSN(2,rev_notE)]
paulson@2111
   187
               addss (!simpset)) 1));
paulson@2111
   188
val lemma = result();
paulson@2111
   189
paulson@2111
   190
goal thy 
paulson@2111
   191
 "!!evs. [| evs : yahalom lost;  length evs <= length evs' |]    \
paulson@2111
   192
\        ==> newK evs' ~: keysFor (parts (sees lost C evs))";
paulson@2111
   193
by (fast_tac (!claset addSDs [lemma] addss (!simpset)) 1);
paulson@2111
   194
qed "new_keys_not_used";
paulson@2111
   195
paulson@2111
   196
bind_thm ("new_keys_not_analzd",
paulson@2111
   197
          [analz_subset_parts RS keysFor_mono,
paulson@2111
   198
           new_keys_not_used] MRS contra_subsetD);
paulson@2111
   199
paulson@2111
   200
Addsimps [new_keys_not_used, new_keys_not_analzd];
paulson@2111
   201
paulson@2111
   202
paulson@2111
   203
(*Describes the form of Key K when the following message is sent.  The use of
paulson@2111
   204
  "parts" strengthens the induction hyp for proving the Fake case.  The
paulson@2111
   205
  assumption A ~: lost prevents its being a Faked message.  (Based
paulson@2111
   206
  on NS_Shared/Says_S_message_form) *)
paulson@2111
   207
goal thy
paulson@2111
   208
 "!!evs. evs: yahalom lost ==>                                        \
paulson@2111
   209
\        Crypt {|B, Key K, NA|} (shrK A) : parts (sees lost Spy evs)  \
paulson@2111
   210
\        --> A ~: lost --> (EX evt: yahalom lost. K = newK evt)";
paulson@2111
   211
by (parts_induct_tac 1);
paulson@2111
   212
by (Auto_tac());
paulson@2111
   213
qed_spec_mp "Reveal_message_lemma";
paulson@2111
   214
paulson@2111
   215
(*EITHER describes the form of Key K when the following message is sent, 
paulson@2111
   216
  OR     reduces it to the Fake case.*)
paulson@2111
   217
paulson@2111
   218
goal thy 
paulson@2111
   219
 "!!evs. [| Says S A {|NB, Crypt {|B, Key K, NA|} (shrK A), X|} \
paulson@2111
   220
\           : set_of_list evs;                                  \
paulson@2111
   221
\           evs : yahalom lost |]                               \
paulson@2111
   222
\        ==> (EX evt: yahalom lost. K = newK evt)               \
paulson@2111
   223
\          | Key K : analz (sees lost Spy evs)";
paulson@2111
   224
br (Reveal_message_lemma RS disjCI) 1;
paulson@2111
   225
ba 1;
paulson@2111
   226
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS analz.Inj]
paulson@2111
   227
                      addDs [impOfSubs analz_subset_parts]) 1);
paulson@2111
   228
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS analz.Inj]
paulson@2111
   229
                      addss (!simpset)) 1);
paulson@2111
   230
qed "Reveal_message_form";
paulson@2111
   231
paulson@2111
   232
paulson@2111
   233
(*For proofs involving analz.  We again instantiate the variable to "lost".*)
paulson@2111
   234
val analz_Fake_tac = 
paulson@2111
   235
    dres_inst_tac [("lost","lost")] YM4_analz_sees_Spy 6 THEN
paulson@2111
   236
    forw_inst_tac [("lost","lost")] Reveal_message_form 7;
paulson@2111
   237
paulson@2111
   238
paulson@2111
   239
(****
paulson@2111
   240
 The following is to prove theorems of the form
paulson@2111
   241
paulson@2111
   242
          Key K : analz (insert (Key (newK evt)) (sees lost Spy evs)) ==>
paulson@2111
   243
          Key K : analz (sees lost Spy evs)
paulson@2111
   244
paulson@2111
   245
 A more general formula must be proved inductively.
paulson@2111
   246
paulson@2111
   247
****)
paulson@2111
   248
paulson@2111
   249
(** Session keys are not used to encrypt other session keys **)
paulson@2111
   250
paulson@2111
   251
goal thy  
paulson@2111
   252
 "!!evs. evs : yahalom lost ==> \
paulson@2111
   253
\  ALL K E. (Key K : analz (Key``(newK``E) Un (sees lost Spy evs))) = \
paulson@2111
   254
\           (K : newK``E | Key K : analz (sees lost Spy evs))";
paulson@2111
   255
by (etac yahalom.induct 1);
paulson@2111
   256
by analz_Fake_tac;
paulson@2111
   257
by (REPEAT_FIRST (resolve_tac [allI, analz_image_newK_lemma]));
paulson@2111
   258
by (REPEAT ((eresolve_tac [bexE, disjE] ORELSE' hyp_subst_tac) 8));
paulson@2111
   259
by (ALLGOALS  (*Takes 26 secs*)
paulson@2111
   260
    (asm_simp_tac 
paulson@2111
   261
     (!simpset addsimps ([insert_Key_singleton, insert_Key_image, pushKey_newK]
paulson@2111
   262
                         @ pushes)
paulson@2111
   263
               setloop split_tac [expand_if])));
paulson@2111
   264
(** LEVEL 5 **)
paulson@2111
   265
(*Reveal case 2, YM4, Fake*) 
paulson@2111
   266
by (EVERY (map spy_analz_tac [6, 4, 2]));
paulson@2111
   267
(*Reveal case 1, YM3, Base*)
paulson@2111
   268
by (REPEAT (fast_tac (!claset addIs [image_eqI] addss (!simpset)) 1));
paulson@2111
   269
qed_spec_mp "analz_image_newK";
paulson@2111
   270
paulson@2111
   271
goal thy
paulson@2111
   272
 "!!evs. evs : yahalom lost ==>                               \
paulson@2111
   273
\        Key K : analz (insert (Key (newK evt)) (sees lost Spy evs)) = \
paulson@2111
   274
\        (K = newK evt | Key K : analz (sees lost Spy evs))";
paulson@2111
   275
by (asm_simp_tac (HOL_ss addsimps [pushKey_newK, analz_image_newK, 
paulson@2111
   276
                                   insert_Key_singleton]) 1);
paulson@2111
   277
by (Fast_tac 1);
paulson@2111
   278
qed "analz_insert_Key_newK";
paulson@2111
   279
paulson@2111
   280
paulson@2111
   281
(*** The Key K uniquely identifies the Server's  message. **)
paulson@2111
   282
paulson@2111
   283
goal thy 
paulson@2111
   284
 "!!evs. evs : yahalom lost ==>                                     \
paulson@2111
   285
\      EX A' B' NA' NB'. ALL A B NA NB.                             \
paulson@2111
   286
\          Says Server A                                            \
paulson@2111
   287
\           {|NB, Crypt {|Agent B, Key K, NA|} (shrK A),            \
paulson@2111
   288
\                 Crypt {|Agent A, Key K, NB, NB|} (shrK B)|}           \
paulson@2111
   289
\          : set_of_list evs --> A=A' & B=B' & NA=NA' & NB=NB'";
paulson@2111
   290
by (etac yahalom.induct 1);
paulson@2111
   291
by (ALLGOALS (asm_simp_tac (!simpset addsimps [all_conj_distrib])));
paulson@2111
   292
by (Step_tac 1);
paulson@2111
   293
(*Remaining case: YM3*)
paulson@2111
   294
by (expand_case_tac "K = ?y" 1);
paulson@2111
   295
by (REPEAT (ares_tac [refl,exI,impI,conjI] 2));
paulson@2111
   296
(*...we assume X is a very new message, and handle this case by contradiction*)
paulson@2111
   297
by (fast_tac (!claset addEs [Says_imp_old_keys RS less_irrefl]
paulson@2111
   298
                      delrules [conjI]    (*prevent split-up into 4 subgoals*)
paulson@2111
   299
                      addss (!simpset addsimps [parts_insertI])) 1);
paulson@2111
   300
val lemma = result();
paulson@2111
   301
paulson@2111
   302
goal thy 
paulson@2111
   303
"!!evs. [| Says Server A                                            \
paulson@2111
   304
\           {|NB, Crypt {|Agent B, Key K, NA|} (shrK A),            \
paulson@2111
   305
\                 Crypt {|Agent A, Key K, NB, NB|} (shrK B)|}           \
paulson@2111
   306
\           : set_of_list evs;                                      \
paulson@2111
   307
\          Says Server A'                                           \
paulson@2111
   308
\           {|NB', Crypt {|Agent B', Key K, NA'|} (shrK A'),        \
paulson@2111
   309
\                  Crypt {|Agent A', Key K, NB', NB'|} (shrK B')|}       \
paulson@2111
   310
\           : set_of_list evs;                                      \
paulson@2111
   311
\          evs : yahalom lost |]                                    \
paulson@2111
   312
\       ==> A=A' & B=B' & NA=NA' & NB=NB'";
paulson@2111
   313
by (dtac lemma 1);
paulson@2111
   314
by (REPEAT (etac exE 1));
paulson@2111
   315
(*Duplicate the assumption*)
paulson@2111
   316
by (forw_inst_tac [("psi", "ALL C.?P(C)")] asm_rl 1);
paulson@2111
   317
by (fast_tac (!claset addSDs [spec]) 1);
paulson@2111
   318
qed "unique_session_keys";
paulson@2111
   319
paulson@2111
   320
paulson@2111
   321
(*If the encrypted message appears then it originated with the Server*)
paulson@2111
   322
goal thy
paulson@2111
   323
 "!!evs. [| Crypt {|Agent B, Key K, Nonce NA|} (shrK A)                \
paulson@2111
   324
\            : parts (sees lost Spy evs);                              \
paulson@2111
   325
\           A ~: lost;  evs : yahalom lost |]                          \
paulson@2111
   326
\         ==> EX NB. Says Server A                                            \
paulson@2111
   327
\              {|NB, Crypt {|Agent B, Key K, Nonce NA|} (shrK A),            \
paulson@2111
   328
\                    Crypt {|Agent A, Key K, NB, NB|} (shrK B)|}           \
paulson@2111
   329
\             : set_of_list evs";
paulson@2111
   330
by (etac rev_mp 1);
paulson@2111
   331
by (parts_induct_tac 1);
paulson@2111
   332
by (Fast_tac 1);
paulson@2111
   333
qed "A_trust_YM3";
paulson@2111
   334
paulson@2111
   335
paulson@2111
   336
(*Describes the form of K when the Server sends this message.*)
paulson@2111
   337
goal thy 
paulson@2111
   338
 "!!evs. [| Says Server A                                           \
paulson@2111
   339
\            {|NB, Crypt {|Agent B, K, NA|} (shrK A),           \
paulson@2111
   340
\                  Crypt {|Agent A, K, NB, NB|} (shrK B)|}          \
paulson@2111
   341
\            : set_of_list evs;   \
paulson@2111
   342
\           evs : yahalom lost |]                                   \
paulson@2111
   343
\        ==> (EX evt: yahalom lost. K = Key(newK evt))";
paulson@2111
   344
by (etac rev_mp 1);
paulson@2111
   345
by (etac yahalom.induct 1);
paulson@2111
   346
by (ALLGOALS (fast_tac (!claset addss (!simpset))));
paulson@2111
   347
qed "Says_Server_message_form";
paulson@2111
   348
paulson@2111
   349
paulson@2111
   350
(** Crucial secrecy property: Spy does not see the keys sent in msg YM3 **)
paulson@2111
   351
paulson@2111
   352
goal thy 
paulson@2111
   353
 "!!evs. [| A ~: lost;  B ~: lost;                                \
paulson@2111
   354
\           evs : yahalom lost;  evt : yahalom lost |]            \
paulson@2111
   355
\        ==> Says Server A                                           \
paulson@2111
   356
\              {|NB, Crypt {|Agent B, Key K, NA|} (shrK A),           \
paulson@2111
   357
\                    Crypt {|Agent A, Key K, NB, NB|} (shrK B)|}          \
paulson@2111
   358
\             : set_of_list evs -->                               \
paulson@2111
   359
\            Says A Spy {|NA, Key K|} ~: set_of_list evs -->  \
paulson@2111
   360
\            Key K ~: analz (sees lost Spy evs)";
paulson@2111
   361
by (etac yahalom.induct 1);
paulson@2111
   362
by analz_Fake_tac;
paulson@2111
   363
by (REPEAT_FIRST (eresolve_tac [asm_rl, bexE, disjE] ORELSE' hyp_subst_tac));
paulson@2111
   364
by (ALLGOALS
paulson@2111
   365
    (asm_simp_tac 
paulson@2111
   366
     (!simpset addsimps ([analz_subset_parts RS contra_subsetD,
paulson@2111
   367
                          analz_insert_Key_newK] @ pushes)
paulson@2111
   368
               setloop split_tac [expand_if])));
paulson@2111
   369
(*YM3*)
paulson@2111
   370
by (fast_tac (!claset addIs [parts_insertI]
paulson@2111
   371
                      addEs [Says_imp_old_keys RS less_irrefl]
paulson@2111
   372
                      addss (!simpset)) 2);
paulson@2111
   373
(*Reveal case 2, OR4, Fake*) 
paulson@2111
   374
by (REPEAT_FIRST (resolve_tac [conjI, impI] ORELSE' spy_analz_tac));
paulson@2111
   375
(*Reveal case 1*) (** LEVEL 6 **)
paulson@2111
   376
by (case_tac "Aa : lost" 1);
paulson@2111
   377
(*But this contradicts Key K ~: analz (sees lost Spy evsa) *)
paulson@2111
   378
by (dtac (Says_imp_sees_Spy RS analz.Inj) 1);
paulson@2111
   379
by (fast_tac (!claset addSDs [analz.Decrypt] addss (!simpset)) 1);
paulson@2111
   380
(*So now we have  Aa ~: lost *)
paulson@2111
   381
bd (Says_imp_sees_Spy RS parts.Inj) 1;
paulson@2111
   382
by (fast_tac (!claset delrules [disjE] 
paulson@2111
   383
	              addSEs [MPair_parts]
paulson@2111
   384
		      addDs [A_trust_YM3, unique_session_keys]
paulson@2111
   385
	              addss (!simpset)) 1);
paulson@2111
   386
val lemma = result() RS mp RS mp RSN(2,rev_notE);
paulson@2111
   387
paulson@2111
   388
paulson@2111
   389
(*Final version: Server's message in the most abstract form*)
paulson@2111
   390
goal thy 
paulson@2111
   391
 "!!evs. [| Says Server A                                         \
paulson@2111
   392
\              {|NB, Crypt {|Agent B, K, NA|} (shrK A),           \
paulson@2111
   393
\                    Crypt {|Agent A, K, NB, NB|} (shrK B)|}      \
paulson@2111
   394
\           : set_of_list evs;                                    \
paulson@2111
   395
\           Says A Spy {|NA, K|} ~: set_of_list evs;          \
paulson@2111
   396
\           A ~: lost;  B ~: lost;  evs : yahalom lost |] ==>     \
paulson@2111
   397
\     K ~: analz (sees lost Spy evs)";
paulson@2111
   398
by (forward_tac [Says_Server_message_form] 1 THEN assume_tac 1);
paulson@2111
   399
by (fast_tac (!claset addSEs [lemma]) 1);
paulson@2111
   400
qed "Spy_not_see_encrypted_key";
paulson@2111
   401
paulson@2111
   402
paulson@2111
   403
goal thy 
paulson@2111
   404
 "!!evs. [| C ~: {A,B,Server};                                          \
paulson@2111
   405
\           Says Server A                                         \
paulson@2111
   406
\              {|NB, Crypt {|Agent B, K, NA|} (shrK A),           \
paulson@2111
   407
\                    Crypt {|Agent A, K, NB, NB|} (shrK B)|}          \
paulson@2111
   408
\           : set_of_list evs;                                    \
paulson@2111
   409
\           Says A Spy {|NA, K|} ~: set_of_list evs;                \
paulson@2111
   410
\           A ~: lost;  B ~: lost;  evs : yahalom lost |] ==>           \
paulson@2111
   411
\     K ~: analz (sees lost C evs)";
paulson@2111
   412
by (rtac (subset_insertI RS sees_mono RS analz_mono RS contra_subsetD) 1);
paulson@2111
   413
by (rtac (sees_lost_agent_subset_sees_Spy RS analz_mono RS contra_subsetD) 1);
paulson@2111
   414
by (FIRSTGOAL (rtac Spy_not_see_encrypted_key));
paulson@2111
   415
by (REPEAT_FIRST (fast_tac (!claset addIs [yahalom_mono RS subsetD])));
paulson@2111
   416
qed "Agent_not_see_encrypted_key";
paulson@2111
   417
paulson@2111
   418
paulson@2111
   419
(*** Security Guarantee for B upon receiving YM4 ***)
paulson@2111
   420
paulson@2111
   421
(*B knows, by the first part of A's message, that the Server distributed 
paulson@2111
   422
  the key for A and B.  But this part says nothing about nonces.*)
paulson@2111
   423
goal thy 
paulson@2111
   424
 "!!evs. [| Crypt {|Agent A, Key K, Nonce NB, Nonce NB|} (shrK B)    \
paulson@2111
   425
\            : parts (sees lost Spy evs); \
paulson@2111
   426
\           B ~: lost;  evs : yahalom lost |]                           \
paulson@2111
   427
\        ==> EX NA. Says Server A                                    \
paulson@2111
   428
\                    {|Nonce NB,                                   \
paulson@2111
   429
\                      Crypt {|Agent B, Key K, Nonce NA|} (shrK A), \
paulson@2111
   430
\                      Crypt {|Agent A, Key K, Nonce NB, Nonce NB|} (shrK B)|}\
paulson@2111
   431
\                       : set_of_list evs";
paulson@2111
   432
by (etac rev_mp 1);
paulson@2111
   433
by (parts_induct_tac 1);
paulson@2111
   434
(*YM3*)
paulson@2111
   435
by (Fast_tac 1);
paulson@2111
   436
qed "B_trusts_YM4_shrK";
paulson@2111
   437
paulson@2111
   438
(*With this variant we don't bother to use the 2nd part of YM4 at all, since
paulson@2111
   439
  Nonce NB is available in the first part.  However the 2nd part does assure B
paulson@2111
   440
  of A's existence.*)
paulson@2111
   441
paulson@2111
   442
(*What can B deduce from receipt of YM4?  Note how the two components of
paulson@2111
   443
  the message contribute to a single conclusion about the Server's message.*)
paulson@2111
   444
goal thy 
paulson@2111
   445
 "!!evs. [| Says A' B {|Crypt {|Agent A, Key K, Nonce NB, Nonce NB|} (shrK B),              \
paulson@2111
   446
\                       Crypt (Nonce NB) K|} : set_of_list evs;         \
paulson@2111
   447
\           ALL N N'. Says A Spy {|N,N', Key K|} ~: set_of_list evs;    \
paulson@2111
   448
\           A ~: lost;  B ~: lost;  evs : yahalom lost |]               \
paulson@2111
   449
\        ==> EX NA. Says Server A                                       \
paulson@2111
   450
\                    {|Nonce NB,                                   \
paulson@2111
   451
\                      Crypt {|Agent B, Key K, Nonce NA|} (shrK A), \
paulson@2111
   452
\                      Crypt {|Agent A, Key K, Nonce NB, Nonce NB|} (shrK B)|}\
paulson@2111
   453
\                   : set_of_list evs";
paulson@2111
   454
be (Says_imp_sees_Spy RS parts.Inj RS MPair_parts) 1;
paulson@2111
   455
by (fast_tac (!claset addSDs [B_trusts_YM4_shrK]) 1);
paulson@2111
   456
qed "B_trust_YM4";