src/HOL/Auth/Yahalom.ML
author paulson
Fri Nov 29 18:03:21 1996 +0100 (1996-11-29)
changeset 2284 80ebd1a213fd
parent 2269 820f68aec6ee
child 2322 fbe6dd4abddc
permissions -rw-r--r--
Swapped arguments of Crypt (for clarity and because it is conventional)
paulson@1995
     1
(*  Title:      HOL/Auth/Yahalom
paulson@1985
     2
    ID:         $Id$
paulson@1985
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@1985
     4
    Copyright   1996  University of Cambridge
paulson@1985
     5
paulson@1985
     6
Inductive relation "otway" for the Yahalom protocol.
paulson@1985
     7
paulson@1985
     8
From page 257 of
paulson@1985
     9
  Burrows, Abadi and Needham.  A Logic of Authentication.
paulson@1985
    10
  Proc. Royal Soc. 426 (1989)
paulson@1985
    11
*)
paulson@1985
    12
paulson@1995
    13
open Yahalom;
paulson@1985
    14
paulson@1985
    15
proof_timing:=true;
paulson@1985
    16
HOL_quantifiers := false;
paulson@2133
    17
Pretty.setdepth 20;
paulson@1985
    18
paulson@1995
    19
paulson@2013
    20
(*Weak liveness: there are traces that reach the end*)
paulson@1995
    21
paulson@1995
    22
goal thy 
paulson@1995
    23
 "!!A B. [| A ~= B; A ~= Server; B ~= Server |]   \
paulson@2032
    24
\        ==> EX X NB K. EX evs: yahalom lost.          \
paulson@2284
    25
\               Says A B {|X, Crypt K (Nonce NB)|} : set_of_list evs";
paulson@1995
    26
by (REPEAT (resolve_tac [exI,bexI] 1));
paulson@2032
    27
by (rtac (yahalom.Nil RS yahalom.YM1 RS yahalom.YM2 RS yahalom.YM3 RS yahalom.YM4) 2);
paulson@1995
    28
by (ALLGOALS (simp_tac (!simpset setsolver safe_solver)));
paulson@1995
    29
by (ALLGOALS Fast_tac);
paulson@2013
    30
result();
paulson@1995
    31
paulson@1995
    32
paulson@1985
    33
(**** Inductive proofs about yahalom ****)
paulson@1985
    34
paulson@2110
    35
(*Monotonicity*)
paulson@2045
    36
goal thy "!!evs. lost' <= lost ==> yahalom lost' <= yahalom lost";
paulson@2045
    37
by (rtac subsetI 1);
paulson@2045
    38
by (etac yahalom.induct 1);
paulson@2045
    39
by (REPEAT_FIRST
paulson@2045
    40
    (best_tac (!claset addIs (impOfSubs (sees_mono RS analz_mono RS synth_mono)
paulson@2045
    41
                              :: yahalom.intrs))));
paulson@2045
    42
qed "yahalom_mono";
paulson@2045
    43
paulson@1985
    44
paulson@1985
    45
(*Nobody sends themselves messages*)
paulson@2051
    46
goal thy "!!evs. evs: yahalom lost ==> ALL A X. Says A A X ~: set_of_list evs";
paulson@2032
    47
by (etac yahalom.induct 1);
paulson@1985
    48
by (Auto_tac());
paulson@1985
    49
qed_spec_mp "not_Says_to_self";
paulson@1985
    50
Addsimps [not_Says_to_self];
paulson@1985
    51
AddSEs   [not_Says_to_self RSN (2, rev_notE)];
paulson@1985
    52
paulson@1985
    53
paulson@1985
    54
(** For reasoning about the encrypted portion of messages **)
paulson@1985
    55
paulson@1995
    56
(*Lets us treat YM4 using a similar argument as for the Fake case.*)
paulson@2284
    57
goal thy "!!evs. Says S A {|Crypt (shrK A) Y, X|} : set_of_list evs ==> \
paulson@2032
    58
\                X : analz (sees lost Spy evs)";
paulson@2032
    59
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS analz.Inj]) 1);
paulson@2032
    60
qed "YM4_analz_sees_Spy";
paulson@1985
    61
paulson@2110
    62
bind_thm ("YM4_parts_sees_Spy",
paulson@2110
    63
          YM4_analz_sees_Spy RS (impOfSubs analz_subset_parts));
paulson@2110
    64
paulson@2133
    65
(*Relates to both YM4 and Oops*)
paulson@2284
    66
goal thy "!!evs. Says S A {|Crypt (shrK A) {|B, K, NA, NB|}, X|} \
paulson@1995
    67
\                  : set_of_list evs ==> \
paulson@2032
    68
\                K : parts (sees lost Spy evs)";
paulson@1985
    69
by (fast_tac (!claset addSEs partsEs
paulson@2032
    70
                      addSDs [Says_imp_sees_Spy RS parts.Inj]) 1);
paulson@2110
    71
qed "YM4_Key_parts_sees_Spy";
paulson@2110
    72
paulson@2110
    73
(*We instantiate the variable to "lost".  Leaving it as a Var makes proofs
paulson@2110
    74
  harder: the simplifier does less.*)
paulson@2110
    75
val parts_Fake_tac = 
paulson@2110
    76
    forw_inst_tac [("lost","lost")] YM4_parts_sees_Spy 6 THEN
paulson@2110
    77
    forw_inst_tac [("lost","lost")] YM4_Key_parts_sees_Spy 7;
paulson@1985
    78
paulson@2110
    79
(*For proving the easier theorems about X ~: parts (sees lost Spy evs) *)
paulson@2110
    80
fun parts_induct_tac i = SELECT_GOAL
paulson@2110
    81
    (DETERM (etac yahalom.induct 1 THEN parts_Fake_tac THEN
paulson@2170
    82
             (*Fake message*)
paulson@2170
    83
             TRY (best_tac (!claset addDs [impOfSubs analz_subset_parts,
paulson@2170
    84
                                           impOfSubs Fake_parts_insert]
paulson@2110
    85
                                    addss (!simpset)) 2)) THEN
paulson@2110
    86
     (*Base case*)
paulson@2110
    87
     fast_tac (!claset addss (!simpset)) 1 THEN
paulson@2110
    88
     ALLGOALS Asm_simp_tac) i;
paulson@1985
    89
paulson@1985
    90
paulson@2032
    91
(** Theorems of the form X ~: parts (sees lost Spy evs) imply that NOBODY
paulson@2013
    92
    sends messages containing X! **)
paulson@1985
    93
paulson@2133
    94
(*Spy never sees another agent's shared key! (unless it's lost at start)*)
paulson@1985
    95
goal thy 
paulson@2133
    96
 "!!evs. evs : yahalom lost \
paulson@2133
    97
\        ==> (Key (shrK A) : parts (sees lost Spy evs)) = (A : lost)";
paulson@2110
    98
by (parts_induct_tac 1);
paulson@1985
    99
by (Auto_tac());
paulson@2133
   100
qed "Spy_see_shrK";
paulson@2133
   101
Addsimps [Spy_see_shrK];
paulson@1985
   102
paulson@2133
   103
goal thy 
paulson@2133
   104
 "!!evs. evs : yahalom lost \
paulson@2133
   105
\        ==> (Key (shrK A) : analz (sees lost Spy evs)) = (A : lost)";
paulson@2133
   106
by (auto_tac(!claset addDs [impOfSubs analz_subset_parts], !simpset));
paulson@2133
   107
qed "Spy_analz_shrK";
paulson@2133
   108
Addsimps [Spy_analz_shrK];
paulson@1985
   109
paulson@2133
   110
goal thy  "!!A. [| Key (shrK A) : parts (sees lost Spy evs);       \
paulson@2133
   111
\                  evs : yahalom lost |] ==> A:lost";
paulson@2133
   112
by (fast_tac (!claset addDs [Spy_see_shrK]) 1);
paulson@2133
   113
qed "Spy_see_shrK_D";
paulson@1985
   114
paulson@2133
   115
bind_thm ("Spy_analz_shrK_D", analz_subset_parts RS subsetD RS Spy_see_shrK_D);
paulson@2133
   116
AddSDs [Spy_see_shrK_D, Spy_analz_shrK_D];
paulson@1985
   117
paulson@1985
   118
paulson@1985
   119
(*** Future keys can't be seen or used! ***)
paulson@1985
   120
paulson@2160
   121
(*Nobody can have SEEN keys that will be generated in the future. *)
paulson@2032
   122
goal thy "!!evs. evs : yahalom lost ==> \
paulson@1985
   123
\                length evs <= length evs' --> \
paulson@2160
   124
\                Key (newK evs') ~: parts (sees lost Spy evs)";
paulson@2110
   125
by (parts_induct_tac 1);
paulson@2264
   126
by (REPEAT_FIRST (best_tac (!claset addEs [leD RS notE]
paulson@2264
   127
				    addDs [impOfSubs analz_subset_parts,
paulson@2032
   128
                                           impOfSubs parts_insert_subset_Un,
paulson@2032
   129
                                           Suc_leD]
paulson@2032
   130
                                    addss (!simpset))));
paulson@2160
   131
qed_spec_mp "new_keys_not_seen";
paulson@1985
   132
Addsimps [new_keys_not_seen];
paulson@1985
   133
paulson@2160
   134
(*Variant: old messages must contain old keys!*)
paulson@1985
   135
goal thy 
paulson@1985
   136
 "!!evs. [| Says A B X : set_of_list evs;  \
paulson@1985
   137
\           Key (newK evt) : parts {X};    \
paulson@2032
   138
\           evs : yahalom lost                 \
paulson@1985
   139
\        |] ==> length evt < length evs";
paulson@2032
   140
by (rtac ccontr 1);
paulson@2032
   141
by (dtac leI 1);
paulson@2032
   142
by (fast_tac (!claset addSDs [new_keys_not_seen, Says_imp_sees_Spy]
paulson@2013
   143
                      addIs  [impOfSubs parts_mono]) 1);
paulson@1985
   144
qed "Says_imp_old_keys";
paulson@1985
   145
paulson@1985
   146
paulson@2133
   147
(*Ready-made for the classical reasoner*)
paulson@2284
   148
goal thy "!!evs. [| Says A B {|Crypt K {|b, Key (newK evs), na, nb|}, X|}  \
paulson@2133
   149
\                   : set_of_list evs;  evs : yahalom lost |]              \
paulson@2133
   150
\                ==> R";
paulson@2133
   151
by (fast_tac (!claset addEs [Says_imp_old_keys RS less_irrefl]
paulson@2133
   152
                      addss (!simpset addsimps [parts_insertI])) 1);
paulson@2133
   153
qed "Says_too_new_key";
paulson@2133
   154
AddSEs [Says_too_new_key];
paulson@2133
   155
paulson@2133
   156
paulson@1985
   157
(*Nobody can have USED keys that will be generated in the future.
paulson@1985
   158
  ...very like new_keys_not_seen*)
paulson@2032
   159
goal thy "!!evs. evs : yahalom lost ==> \
paulson@1985
   160
\                length evs <= length evs' --> \
paulson@2160
   161
\                newK evs' ~: keysFor (parts (sees lost Spy evs))";
paulson@2110
   162
by (parts_induct_tac 1);
paulson@1995
   163
(*YM1, YM2 and YM3*)
paulson@1995
   164
by (EVERY (map (fast_tac (!claset addDs [Suc_leD] addss (!simpset))) [4,3,2]));
paulson@2160
   165
(*Fake and Oops: these messages send unknown (X) components*)
paulson@2160
   166
by (EVERY
paulson@2160
   167
    (map (fast_tac
paulson@2170
   168
          (!claset addDs [impOfSubs analz_subset_parts,
paulson@2170
   169
                          impOfSubs (analz_subset_parts RS keysFor_mono),
paulson@2170
   170
                          impOfSubs (parts_insert_subset_Un RS keysFor_mono),
paulson@2170
   171
                          Suc_leD]
paulson@2160
   172
                   addss (!simpset))) [3,1]));
paulson@2160
   173
(*YM4: if K was used then it had been seen, contradicting new_keys_not_seen*)
paulson@2160
   174
by (fast_tac
paulson@2160
   175
      (!claset addSEs partsEs
paulson@2160
   176
               addSDs [Says_imp_sees_Spy RS parts.Inj]
paulson@2032
   177
               addEs [new_keys_not_seen RSN(2,rev_notE)]
paulson@2160
   178
               addDs [Suc_leD]) 1);
paulson@2160
   179
qed_spec_mp "new_keys_not_used";
paulson@1985
   180
paulson@1985
   181
bind_thm ("new_keys_not_analzd",
paulson@2032
   182
          [analz_subset_parts RS keysFor_mono,
paulson@2032
   183
           new_keys_not_used] MRS contra_subsetD);
paulson@1985
   184
paulson@1985
   185
Addsimps [new_keys_not_used, new_keys_not_analzd];
paulson@1985
   186
paulson@1985
   187
paulson@2133
   188
(*Describes the form of K when the Server sends this message.  Useful for
paulson@2133
   189
  Oops as well as main secrecy property.*)
paulson@2110
   190
goal thy 
paulson@2133
   191
 "!!evs. [| Says Server A                                           \
paulson@2284
   192
\            {|Crypt (shrK A) {|Agent B, K, NA, NB|}, X|} : set_of_list evs; \
paulson@2133
   193
\           evs : yahalom lost |]                                   \
paulson@2133
   194
\        ==> (EX evt: yahalom lost. K = Key(newK evt))";
paulson@2133
   195
by (etac rev_mp 1);
paulson@2133
   196
by (etac yahalom.induct 1);
paulson@2133
   197
by (ALLGOALS (fast_tac (!claset addss (!simpset))));
paulson@2133
   198
qed "Says_Server_message_form";
paulson@2110
   199
paulson@2110
   200
paulson@2110
   201
(*For proofs involving analz.  We again instantiate the variable to "lost".*)
paulson@2110
   202
val analz_Fake_tac = 
paulson@2133
   203
    forw_inst_tac [("lost","lost")] YM4_analz_sees_Spy 6 THEN
paulson@2133
   204
    forw_inst_tac [("lost","lost")] Says_Server_message_form 7 THEN
paulson@2133
   205
    assume_tac 7 THEN Full_simp_tac 7 THEN
paulson@2133
   206
    REPEAT ((etac bexE ORELSE' hyp_subst_tac) 7);
paulson@1985
   207
paulson@1985
   208
paulson@1985
   209
(****
paulson@1985
   210
 The following is to prove theorems of the form
paulson@1985
   211
paulson@2032
   212
          Key K : analz (insert (Key (newK evt)) (sees lost Spy evs)) ==>
paulson@2032
   213
          Key K : analz (sees lost Spy evs)
paulson@1985
   214
paulson@1985
   215
 A more general formula must be proved inductively.
paulson@1985
   216
paulson@1985
   217
****)
paulson@1985
   218
paulson@1985
   219
paulson@1985
   220
(*NOT useful in this form, but it says that session keys are not used
paulson@1985
   221
  to encrypt messages containing other keys, in the actual protocol.
paulson@1985
   222
  We require that agents should behave like this subsequently also.*)
paulson@1985
   223
goal thy 
paulson@2032
   224
 "!!evs. evs : yahalom lost ==> \
paulson@2284
   225
\        (Crypt (newK evt) X) : parts (sees lost Spy evs) & \
paulson@2032
   226
\        Key K : parts {X} --> Key K : parts (sees lost Spy evs)";
paulson@2032
   227
by (etac yahalom.induct 1);
paulson@2110
   228
by parts_Fake_tac;
paulson@2060
   229
by (ALLGOALS Asm_simp_tac);
paulson@1985
   230
(*Deals with Faked messages*)
paulson@2110
   231
by (best_tac (!claset addSEs partsEs
paulson@2110
   232
                      addDs [impOfSubs parts_insert_subset_Un]
paulson@2110
   233
                      addss (!simpset)) 2);
paulson@1995
   234
(*Base case*)
paulson@1985
   235
by (Auto_tac());
paulson@1985
   236
result();
paulson@1985
   237
paulson@1985
   238
paulson@1985
   239
(** Session keys are not used to encrypt other session keys **)
paulson@1985
   240
paulson@1985
   241
goal thy  
paulson@2032
   242
 "!!evs. evs : yahalom lost ==> \
paulson@2032
   243
\  ALL K E. (Key K : analz (Key``(newK``E) Un (sees lost Spy evs))) = \
paulson@2032
   244
\           (K : newK``E | Key K : analz (sees lost Spy evs))";
paulson@2032
   245
by (etac yahalom.induct 1);
paulson@2110
   246
by analz_Fake_tac;
paulson@2045
   247
by (REPEAT_FIRST (resolve_tac [allI, analz_image_newK_lemma]));
paulson@2156
   248
by (ALLGOALS
paulson@1985
   249
    (asm_simp_tac 
paulson@1985
   250
     (!simpset addsimps ([insert_Key_singleton, insert_Key_image, pushKey_newK]
paulson@2032
   251
                         @ pushes)
paulson@1985
   252
               setloop split_tac [expand_if])));
paulson@2110
   253
(** LEVEL 5 **)
paulson@2133
   254
(*YM4, Fake*) 
paulson@2133
   255
by (EVERY (map spy_analz_tac [4, 2]));
paulson@2133
   256
(*Oops, YM3, Base*)
paulson@2110
   257
by (REPEAT (fast_tac (!claset addIs [image_eqI] addss (!simpset)) 1));
paulson@1985
   258
qed_spec_mp "analz_image_newK";
paulson@1985
   259
paulson@1985
   260
goal thy
paulson@2032
   261
 "!!evs. evs : yahalom lost ==>                               \
paulson@2032
   262
\        Key K : analz (insert (Key (newK evt)) (sees lost Spy evs)) = \
paulson@2032
   263
\        (K = newK evt | Key K : analz (sees lost Spy evs))";
paulson@2133
   264
by (asm_simp_tac (HOL_ss addsimps [analz_image_newK, 
paulson@2032
   265
                                   insert_Key_singleton]) 1);
paulson@1985
   266
by (Fast_tac 1);
paulson@1985
   267
qed "analz_insert_Key_newK";
paulson@1985
   268
paulson@1985
   269
paulson@2110
   270
(*** The Key K uniquely identifies the Server's  message. **)
paulson@2110
   271
paulson@2110
   272
goal thy 
paulson@2110
   273
 "!!evs. evs : yahalom lost ==>                                     \
paulson@2133
   274
\      EX A' B' NA' NB' X'. ALL A B NA NB X.                             \
paulson@2110
   275
\          Says Server A                                            \
paulson@2284
   276
\           {|Crypt (shrK A) {|Agent B, Key K, NA, NB|}, X|}        \
paulson@2133
   277
\          : set_of_list evs --> A=A' & B=B' & NA=NA' & NB=NB' & X=X'";
paulson@2110
   278
by (etac yahalom.induct 1);
paulson@2110
   279
by (ALLGOALS (asm_simp_tac (!simpset addsimps [all_conj_distrib])));
paulson@2110
   280
by (Step_tac 1);
paulson@2133
   281
by (ex_strip_tac 2);
paulson@2133
   282
by (Fast_tac 2);
paulson@2110
   283
(*Remaining case: YM3*)
paulson@2110
   284
by (expand_case_tac "K = ?y" 1);
paulson@2110
   285
by (REPEAT (ares_tac [refl,exI,impI,conjI] 2));
paulson@2110
   286
(*...we assume X is a very new message, and handle this case by contradiction*)
paulson@2133
   287
by (Fast_tac 1);  (*uses Says_too_new_key*)
paulson@2110
   288
val lemma = result();
paulson@2110
   289
paulson@2110
   290
goal thy 
paulson@2110
   291
"!!evs. [| Says Server A                                            \
paulson@2284
   292
\           {|Crypt (shrK A) {|Agent B, Key K, NA, NB|}, X|}        \
paulson@2110
   293
\           : set_of_list evs;                                      \
paulson@2110
   294
\          Says Server A'                                           \
paulson@2284
   295
\           {|Crypt (shrK A') {|Agent B', Key K, NA', NB'|}, X'|}   \
paulson@2110
   296
\           : set_of_list evs;                                      \
paulson@2110
   297
\          evs : yahalom lost |]                                    \
paulson@2110
   298
\       ==> A=A' & B=B' & NA=NA' & NB=NB'";
paulson@2110
   299
by (dtac lemma 1);
paulson@2110
   300
by (REPEAT (etac exE 1));
paulson@2110
   301
(*Duplicate the assumption*)
paulson@2110
   302
by (forw_inst_tac [("psi", "ALL C.?P(C)")] asm_rl 1);
paulson@2110
   303
by (fast_tac (!claset addSDs [spec]) 1);
paulson@2110
   304
qed "unique_session_keys";
paulson@2110
   305
paulson@2110
   306
paulson@2110
   307
(*If the encrypted message appears then it originated with the Server*)
paulson@2110
   308
goal thy
paulson@2284
   309
 "!!evs. [| Crypt (shrK A) {|Agent B, Key K, NA, NB|}                  \
paulson@2110
   310
\            : parts (sees lost Spy evs);                              \
paulson@2110
   311
\           A ~: lost;  evs : yahalom lost |]                          \
paulson@2110
   312
\         ==> Says Server A                                            \
paulson@2284
   313
\              {|Crypt (shrK A) {|Agent B, Key K, NA, NB|},            \
paulson@2284
   314
\                Crypt (shrK B) {|Agent A, Key K|}|}                   \
paulson@2110
   315
\             : set_of_list evs";
paulson@2110
   316
by (etac rev_mp 1);
paulson@2110
   317
by (parts_induct_tac 1);
paulson@2110
   318
qed "A_trust_YM3";
paulson@2110
   319
paulson@2110
   320
paulson@2110
   321
(** Crucial secrecy property: Spy does not see the keys sent in msg YM3 **)
paulson@2013
   322
paulson@2013
   323
goal thy 
paulson@2133
   324
 "!!evs. [| A ~: lost;  B ~: lost;  evs : yahalom lost |]         \
paulson@2051
   325
\        ==> Says Server A                                        \
paulson@2284
   326
\              {|Crypt (shrK A) {|Agent B, Key K, NA, NB|},       \
paulson@2284
   327
\                Crypt (shrK B) {|Agent A, Key K|}|}              \
paulson@2110
   328
\             : set_of_list evs -->                               \
paulson@2110
   329
\            Says A Spy {|NA, NB, Key K|} ~: set_of_list evs -->  \
paulson@2051
   330
\            Key K ~: analz (sees lost Spy evs)";
paulson@2032
   331
by (etac yahalom.induct 1);
paulson@2110
   332
by analz_Fake_tac;
paulson@2013
   333
by (ALLGOALS
paulson@2013
   334
    (asm_simp_tac 
paulson@2013
   335
     (!simpset addsimps ([analz_subset_parts RS contra_subsetD,
paulson@2032
   336
                          analz_insert_Key_newK] @ pushes)
paulson@2013
   337
               setloop split_tac [expand_if])));
paulson@2013
   338
(*YM3*)
paulson@2133
   339
by (Fast_tac 2);  (*uses Says_too_new_key*)
paulson@2133
   340
(*OR4, Fake*) 
paulson@2110
   341
by (REPEAT_FIRST (resolve_tac [conjI, impI] ORELSE' spy_analz_tac));
paulson@2133
   342
(*Oops*) (** LEVEL 6 **)
paulson@2110
   343
by (fast_tac (!claset delrules [disjE] 
paulson@2170
   344
                      addDs [unique_session_keys]
paulson@2170
   345
                      addss (!simpset)) 1);
paulson@2110
   346
val lemma = result() RS mp RS mp RSN(2,rev_notE);
paulson@2013
   347
paulson@2013
   348
paulson@2013
   349
(*Final version: Server's message in the most abstract form*)
paulson@1985
   350
goal thy 
paulson@2110
   351
 "!!evs. [| Says Server A                                               \
paulson@2284
   352
\            {|Crypt (shrK A) {|Agent B, K, NA, NB|},                   \
paulson@2284
   353
\              Crypt (shrK B) {|Agent A, K|}|} : set_of_list evs;       \
paulson@2110
   354
\           Says A Spy {|NA, NB, K|} ~: set_of_list evs;                \
paulson@2110
   355
\           A ~: lost;  B ~: lost;  evs : yahalom lost |] ==>           \
paulson@2032
   356
\     K ~: analz (sees lost Spy evs)";
paulson@2013
   357
by (forward_tac [Says_Server_message_form] 1 THEN assume_tac 1);
paulson@2013
   358
by (fast_tac (!claset addSEs [lemma]) 1);
paulson@2032
   359
qed "Spy_not_see_encrypted_key";
paulson@2001
   360
paulson@2001
   361
paulson@2045
   362
goal thy 
paulson@2045
   363
 "!!evs. [| C ~: {A,B,Server};                                          \
paulson@2045
   364
\           Says Server A                                               \
paulson@2284
   365
\            {|Crypt (shrK A) {|Agent B, K, NA, NB|},                   \
paulson@2284
   366
\              Crypt (shrK B) {|Agent A, K|}|} : set_of_list evs;       \
paulson@2110
   367
\           Says A Spy {|NA, NB, K|} ~: set_of_list evs;                \
paulson@2045
   368
\           A ~: lost;  B ~: lost;  evs : yahalom lost |] ==>           \
paulson@2045
   369
\     K ~: analz (sees lost C evs)";
paulson@2045
   370
by (rtac (subset_insertI RS sees_mono RS analz_mono RS contra_subsetD) 1);
paulson@2045
   371
by (rtac (sees_lost_agent_subset_sees_Spy RS analz_mono RS contra_subsetD) 1);
paulson@2045
   372
by (FIRSTGOAL (rtac Spy_not_see_encrypted_key));
paulson@2045
   373
by (REPEAT_FIRST (fast_tac (!claset addIs [yahalom_mono RS subsetD])));
paulson@2045
   374
qed "Agent_not_see_encrypted_key";
paulson@2045
   375
paulson@2045
   376
paulson@2110
   377
(*** Security Guarantee for B upon receiving YM4 ***)
paulson@2013
   378
paulson@2110
   379
(*B knows, by the first part of A's message, that the Server distributed 
paulson@2110
   380
  the key for A and B.  But this part says nothing about nonces.*)
paulson@2001
   381
goal thy 
paulson@2284
   382
 "!!evs. [| Crypt (shrK B) {|Agent A, Key K|} : parts (sees lost Spy evs); \
paulson@2051
   383
\           B ~: lost;  evs : yahalom lost |]                           \
paulson@2001
   384
\        ==> EX NA NB. Says Server A                                    \
paulson@2284
   385
\                        {|Crypt (shrK A) {|Agent B, Key K,                      \
paulson@2284
   386
\                                  Nonce NA, Nonce NB|},       \
paulson@2284
   387
\                          Crypt (shrK B) {|Agent A, Key K|}|}          \
paulson@2013
   388
\                       : set_of_list evs";
paulson@2032
   389
by (etac rev_mp 1);
paulson@2110
   390
by (parts_induct_tac 1);
paulson@2110
   391
(*YM3*)
paulson@2110
   392
by (Fast_tac 1);
paulson@2110
   393
qed "B_trusts_YM4_shrK";
paulson@2110
   394
paulson@2133
   395
paulson@2133
   396
(*** General properties of nonces ***)
paulson@2133
   397
paulson@2133
   398
goal thy "!!evs. evs : yahalom lost ==> \
paulson@2133
   399
\                length evs <= length evt --> \
paulson@2160
   400
\                Nonce (newN evt) ~: parts (sees lost Spy evs)";
paulson@2160
   401
by (parts_induct_tac 1);
paulson@2160
   402
by (REPEAT_FIRST (fast_tac (!claset 
paulson@2160
   403
                              addSEs partsEs
paulson@2160
   404
                              addSDs  [Says_imp_sees_Spy RS parts.Inj]
paulson@2269
   405
                              addEs  [leD RS notE]
paulson@2269
   406
			      addDs  [impOfSubs analz_subset_parts,
paulson@2160
   407
                                      impOfSubs parts_insert_subset_Un,
paulson@2160
   408
                                      Suc_leD]
paulson@2160
   409
                              addss (!simpset))));
paulson@2160
   410
qed_spec_mp "new_nonces_not_seen";
paulson@2133
   411
Addsimps [new_nonces_not_seen];
paulson@2133
   412
paulson@2160
   413
(*Variant: old messages must contain old nonces!*)
paulson@2133
   414
goal thy 
paulson@2160
   415
 "!!evs. [| Says A B X : set_of_list evs;      \
paulson@2160
   416
\           Nonce (newN evt) : parts {X};      \
paulson@2133
   417
\           evs : yahalom lost                 \
paulson@2133
   418
\        |] ==> length evt < length evs";
paulson@2133
   419
by (rtac ccontr 1);
paulson@2133
   420
by (dtac leI 1);
paulson@2133
   421
by (fast_tac (!claset addSDs [new_nonces_not_seen, Says_imp_sees_Spy]
paulson@2133
   422
                      addIs  [impOfSubs parts_mono]) 1);
paulson@2133
   423
qed "Says_imp_old_nonces";
paulson@2133
   424
paulson@2133
   425
paulson@2133
   426
(** The Nonce NB uniquely identifies B's message. **)
paulson@2133
   427
paulson@2133
   428
val nonce_not_seen_now = le_refl RSN (2, new_nonces_not_seen) RSN (2,rev_notE);
paulson@2133
   429
paulson@2133
   430
goal thy 
paulson@2133
   431
 "!!evs. evs : yahalom lost ==> EX NA' A' B'. ALL NA A B. \
paulson@2284
   432
\      Crypt (shrK B) {|Agent A, Nonce NA, NB|} : parts(sees lost Spy evs) \
paulson@2133
   433
\      --> B ~: lost --> NA = NA' & A = A' & B = B'";
paulson@2156
   434
by (parts_induct_tac 1);  (*100 seconds??*)
paulson@2133
   435
by (simp_tac (!simpset addsimps [all_conj_distrib]) 1); 
paulson@2133
   436
(*YM2: creation of new Nonce.  Move assertion into global context*)
paulson@2133
   437
by (expand_case_tac "NB = ?y" 1);
paulson@2133
   438
by (fast_tac (!claset addSEs (nonce_not_seen_now::partsEs)) 1);
paulson@2133
   439
val lemma = result();
paulson@2133
   440
paulson@2110
   441
goal thy 
paulson@2284
   442
 "!!evs.[| Crypt (shrK B) {|Agent A, Nonce NA, NB|} \
paulson@2133
   443
\                  : parts (sees lost Spy evs);         \
paulson@2284
   444
\          Crypt (shrK B') {|Agent A', Nonce NA', NB|} \
paulson@2133
   445
\                  : parts (sees lost Spy evs);         \
paulson@2133
   446
\          evs : yahalom lost;  B ~: lost;  B' ~: lost |]  \
paulson@2133
   447
\        ==> NA' = NA & A' = A & B' = B";
paulson@2133
   448
by (dtac lemma 1);
paulson@2133
   449
by (REPEAT (etac exE 1));
paulson@2133
   450
(*Duplicate the assumption*)
paulson@2133
   451
by (forw_inst_tac [("psi", "ALL C.?P(C)")] asm_rl 1);
paulson@2133
   452
by (fast_tac (!claset addSDs [spec]) 1);
paulson@2133
   453
qed "unique_NB";
paulson@2133
   454
paulson@2133
   455
fun lost_tac s =
paulson@2133
   456
    case_tac ("(" ^ s ^ ") : lost") THEN'
paulson@2133
   457
    SELECT_GOAL 
paulson@2133
   458
      (REPEAT_DETERM (dtac (Says_imp_sees_Spy RS analz.Inj) 1) THEN
paulson@2133
   459
       REPEAT_DETERM (etac MPair_analz 1) THEN
paulson@2133
   460
       dres_inst_tac [("A", s)] Crypt_Spy_analz_lost 1 THEN
paulson@2133
   461
       assume_tac 1 THEN Fast_tac 1);
paulson@2133
   462
paulson@2133
   463
fun lost_tac s =
paulson@2133
   464
    case_tac ("(" ^ s ^ ") : lost") THEN'
paulson@2133
   465
    SELECT_GOAL 
paulson@2133
   466
      (REPEAT_DETERM (dtac (Says_imp_sees_Spy RS analz.Inj) 1) THEN
paulson@2133
   467
       REPEAT_DETERM (etac MPair_analz 1) THEN
paulson@2133
   468
       THEN_BEST_FIRST 
paulson@2133
   469
         (dres_inst_tac [("A", s)] Crypt_Spy_analz_lost 1 THEN assume_tac 1)
paulson@2170
   470
         (has_fewer_prems 1, size_of_thm)
paulson@2170
   471
         (Step_tac 1));
paulson@2133
   472
paulson@2133
   473
paulson@2133
   474
(*Variant useful for proving secrecy of NB*)
paulson@2133
   475
goal thy 
paulson@2284
   476
 "!!evs.[| Says C D   {|X,  Crypt (shrK B) {|Agent A, Nonce NA, NB|}|} \
paulson@2133
   477
\          : set_of_list evs;  B ~: lost;         \
paulson@2284
   478
\          Says C' D' {|X', Crypt (shrK B') {|Agent A', Nonce NA', NB|}|} \
paulson@2133
   479
\          : set_of_list evs;                           \
paulson@2133
   480
\          NB ~: analz (sees lost Spy evs);             \
paulson@2133
   481
\          evs : yahalom lost |]  \
paulson@2133
   482
\        ==> NA' = NA & A' = A & B' = B";
paulson@2133
   483
by (lost_tac "B'" 1);
paulson@2133
   484
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS parts.Inj]
paulson@2133
   485
                      addSEs [MPair_parts]
paulson@2133
   486
                      addDs  [unique_NB]) 1);
paulson@2133
   487
qed "Says_unique_NB";
paulson@2133
   488
paulson@2133
   489
goal thy 
paulson@2133
   490
 "!!evs. [| B ~: lost;  evs : yahalom lost  |]               \
paulson@2133
   491
\ ==>  Nonce NB ~: analz (sees lost Spy evs) -->  \
paulson@2284
   492
\      Crypt (shrK B) {|Agent A, Nonce NA, Nonce NB|} : parts (sees lost Spy evs) \
paulson@2284
   493
\ --> Crypt (shrK B') {|Agent A', Nonce NB, NB'|} ~: parts (sees lost Spy evs)";
paulson@2133
   494
by (etac yahalom.induct 1);
paulson@2133
   495
by parts_Fake_tac;
paulson@2133
   496
by (REPEAT_FIRST 
paulson@2133
   497
    (rtac impI THEN' 
paulson@2133
   498
     dtac (sees_subset_sees_Says RS analz_mono RS contra_subsetD) THEN'
paulson@2133
   499
     mp_tac));
paulson@2133
   500
by (best_tac (!claset addDs [impOfSubs analz_subset_parts,
paulson@2170
   501
                             impOfSubs Fake_parts_insert]
paulson@2170
   502
                      addss (!simpset)) 2);
paulson@2133
   503
by (ALLGOALS Asm_simp_tac);
paulson@2133
   504
by (fast_tac (!claset addss (!simpset)) 1);
paulson@2133
   505
by (fast_tac (!claset addDs [Says_imp_sees_Spy RS analz.Inj]
paulson@2170
   506
                      addSIs [parts_insertI]
paulson@2133
   507
                      addSEs partsEs
paulson@2133
   508
                      addEs [Says_imp_old_nonces RS less_irrefl]
paulson@2133
   509
                      addss (!simpset)) 1);
paulson@2133
   510
val no_nonce_YM1_YM2 = standard (result() RS mp RSN (2, rev_mp) RS notE);
paulson@2133
   511
paulson@2133
   512
paulson@2133
   513
paulson@2133
   514
(**** Towards proving secrecy of Nonce NB ****)
paulson@2133
   515
paulson@2133
   516
(*B knows, by the second part of A's message, that the Server distributed 
paulson@2133
   517
  the key quoting nonce NB.  This part says nothing about agent names. 
paulson@2133
   518
  Secrecy of NB is crucial.*)
paulson@2133
   519
goal thy 
paulson@2133
   520
 "!!evs. evs : yahalom lost                                             \
paulson@2133
   521
\        ==> Nonce NB ~: analz (sees lost Spy evs) -->                  \
paulson@2284
   522
\            Crypt K (Nonce NB) : parts (sees lost Spy evs) -->         \
paulson@2133
   523
\            (EX A B NA. Says Server A                                  \
paulson@2284
   524
\                        {|Crypt (shrK A) {|Agent B, Key K,                      \
paulson@2284
   525
\                                  Nonce NA, Nonce NB|},       \
paulson@2284
   526
\                          Crypt (shrK B) {|Agent A, Key K|}|}          \
paulson@2133
   527
\                       : set_of_list evs)";
paulson@2133
   528
by (etac yahalom.induct 1);
paulson@2133
   529
by parts_Fake_tac;
paulson@2133
   530
by (fast_tac (!claset addss (!simpset)) 1);
paulson@2133
   531
by (REPEAT_FIRST
paulson@2133
   532
    (rtac impI THEN'
paulson@2133
   533
     dtac (sees_subset_sees_Says RS analz_mono RS contra_subsetD)));
paulson@2133
   534
by (ALLGOALS Asm_simp_tac);
paulson@2133
   535
(*Fake, YM3, YM4*)
paulson@2133
   536
by (Fast_tac 2);
paulson@2133
   537
by (fast_tac (!claset addSDs [impOfSubs Fake_parts_insert]
paulson@2133
   538
                      addDs [impOfSubs analz_subset_parts]
paulson@2133
   539
                      addss (!simpset)) 1);
paulson@2133
   540
(*YM4*)
paulson@2133
   541
by (Step_tac 1);
paulson@2133
   542
by (lost_tac "A" 1);
paulson@2133
   543
by (fast_tac (!claset addDs [Says_imp_sees_Spy RS parts.Inj RS parts.Fst RS
paulson@2170
   544
                             A_trust_YM3]) 1);
paulson@2133
   545
val B_trusts_YM4_newK = result() RS mp RSN (2, rev_mp);
paulson@2133
   546
paulson@2133
   547
paulson@2133
   548
(*This is the original version of the result above.  But it is of little
paulson@2133
   549
  value because it assumes secrecy of K, which we cannot be assured of
paulson@2133
   550
  until we know that K is fresh -- which we do not know at the point this
paulson@2133
   551
  result is applied.*)
paulson@2133
   552
goal thy 
paulson@2133
   553
 "!!evs. evs : yahalom lost                                             \
paulson@2133
   554
\        ==> Key K ~: analz (sees lost Spy evs) -->                     \
paulson@2284
   555
\            Crypt K (Nonce NB) : parts (sees lost Spy evs) -->         \
paulson@2110
   556
\            (EX A B NA. Says Server A                                  \
paulson@2284
   557
\                        {|Crypt (shrK A) {|Agent B, Key K,                      \
paulson@2284
   558
\                                  Nonce NA, Nonce NB|},       \
paulson@2284
   559
\                          Crypt (shrK B) {|Agent A, Key K|}|}          \
paulson@2110
   560
\                       : set_of_list evs)";
paulson@2032
   561
by (etac yahalom.induct 1);
paulson@2110
   562
by parts_Fake_tac;
paulson@2001
   563
by (fast_tac (!claset addss (!simpset)) 1);
paulson@2110
   564
by (TRYALL (rtac impI));
paulson@2110
   565
by (REPEAT_FIRST
paulson@2110
   566
    (dtac (sees_subset_sees_Says RS analz_mono RS contra_subsetD)));
paulson@2110
   567
by (ALLGOALS Asm_simp_tac);
paulson@2110
   568
(*Fake, YM3, YM4*)
paulson@2110
   569
by (fast_tac (!claset addSDs [Crypt_Fake_parts_insert]
paulson@2133
   570
                      addDs  [impOfSubs analz_subset_parts]) 1);
paulson@2110
   571
by (Fast_tac 1);
paulson@2110
   572
(*YM4*)
paulson@2110
   573
by (Step_tac 1);
paulson@2133
   574
by (lost_tac "A" 1);
paulson@2110
   575
by (fast_tac (!claset addDs [Says_imp_sees_Spy RS parts.Inj RS parts.Fst RS
paulson@2170
   576
                             A_trust_YM3]) 1);
paulson@2133
   577
result() RS mp RSN (2, rev_mp);
paulson@2133
   578
paulson@2133
   579
paulson@2133
   580
(*YM3 can only be triggered by YM2*)
paulson@2133
   581
goal thy 
paulson@2133
   582
 "!!evs. [| Says Server A                                           \
paulson@2284
   583
\            {|Crypt (shrK A) {|Agent B, k, na, nb|}, X|} : set_of_list evs; \
paulson@2133
   584
\           evs : yahalom lost |]                                        \
paulson@2133
   585
\        ==> EX B'. Says B' Server                                       \
paulson@2284
   586
\                      {| Agent B, Crypt (shrK B) {|Agent A, na, nb|} |} \
paulson@2133
   587
\                   : set_of_list evs";
paulson@2133
   588
by (etac rev_mp 1);
paulson@2133
   589
by (etac yahalom.induct 1);
paulson@2133
   590
by (ALLGOALS Asm_simp_tac);
paulson@2133
   591
by (ALLGOALS Fast_tac);
paulson@2133
   592
qed "Says_Server_imp_YM2";
paulson@2133
   593
paulson@2133
   594
paulson@2133
   595
(** Dedicated tactics for the nonce secrecy proofs **)
paulson@2133
   596
paulson@2133
   597
val no_nonce_tac = SELECT_GOAL
paulson@2133
   598
   (REPEAT (resolve_tac [impI, notI] 1) THEN
paulson@2133
   599
    REPEAT (hyp_subst_tac 1) THEN
paulson@2133
   600
    etac (Says_imp_sees_Spy RS parts.Inj RS parts.Snd RS no_nonce_YM1_YM2) 1
paulson@2133
   601
    THEN
paulson@2133
   602
    etac (Says_imp_sees_Spy RS parts.Inj RS parts.Snd) 4
paulson@2133
   603
    THEN 
paulson@2133
   604
    REPEAT_FIRST assume_tac);
paulson@2133
   605
paulson@2133
   606
val not_analz_insert = subset_insertI RS analz_mono RS contra_subsetD;
paulson@2133
   607
paulson@2133
   608
fun grind_tac i = 
paulson@2133
   609
 SELECT_GOAL
paulson@2133
   610
  (REPEAT_FIRST 
paulson@2133
   611
   (Safe_step_tac ORELSE' (dtac spec THEN' mp_tac) ORELSE'
paulson@2133
   612
    assume_tac ORELSE'
paulson@2133
   613
    depth_tac (!claset delrules [conjI]
paulson@2170
   614
                       addSIs [exI, impOfSubs (subset_insertI RS analz_mono),
paulson@2170
   615
                               impOfSubs (Un_upper2 RS analz_mono)]) 2)) i;
paulson@2133
   616
paulson@2133
   617
(*The only nonces that can be found with the help of session keys are
paulson@2133
   618
  those distributed as nonce NB by the Server.  The form of the theorem
paulson@2133
   619
  recalls analz_image_newK, but it is much more complicated.*)
paulson@2133
   620
goal thy 
paulson@2133
   621
 "!!evs. evs : yahalom lost ==>                                           \
paulson@2133
   622
\     ALL E. Nonce NB : analz (Key``(newK``E) Un (sees lost Spy evs)) --> \
paulson@2133
   623
\     (EX K: newK``E. EX A B na X.                                        \
paulson@2133
   624
\            Says Server A                                                \
paulson@2284
   625
\                {|Crypt (shrK A) {|Agent B, Key K, na, Nonce NB|}, X|}   \
paulson@2133
   626
\            : set_of_list evs)  |  Nonce NB : analz (sees lost Spy evs)";
paulson@2133
   627
by (etac yahalom.induct 1);
paulson@2133
   628
by analz_Fake_tac;
paulson@2156
   629
by (ALLGOALS  (*28 seconds*)
paulson@2133
   630
    (asm_simp_tac 
paulson@2133
   631
     (!simpset addsimps ([analz_subset_parts RS contra_subsetD,
paulson@2133
   632
                          analz_image_newK,
paulson@2170
   633
                          insert_Key_singleton, insert_Key_image]
paulson@2170
   634
                         @ pushes)
paulson@2133
   635
               setloop split_tac [expand_if])));
paulson@2133
   636
(*Base*)
paulson@2133
   637
by (fast_tac (!claset addss (!simpset)) 1);
paulson@2133
   638
(*Fake*) (** LEVEL 4 **)
paulson@2133
   639
by (spy_analz_tac 1);
paulson@2156
   640
(*YM1-YM3*) (*29 seconds*)
paulson@2133
   641
by (EVERY (map grind_tac [3,2,1]));
paulson@2133
   642
(*Oops*)
paulson@2133
   643
by (Full_simp_tac 2);
paulson@2170
   644
by (REPEAT ((etac bexE ORELSE' hyp_subst_tac) 2));
paulson@2133
   645
by (simp_tac (!simpset addsimps [insert_Key_image]) 2);
paulson@2133
   646
by (grind_tac 2);
paulson@2133
   647
by (fast_tac (!claset delrules [bexI] 
paulson@2170
   648
                      addDs [unique_session_keys]
paulson@2170
   649
                      addss (!simpset)) 2);
paulson@2133
   650
(*YM4*)
paulson@2133
   651
(** LEVEL 11 **)
paulson@2170
   652
by (rtac (impI RS allI) 1);
paulson@2133
   653
by (dtac (impOfSubs Fake_analz_insert) 1 THEN etac synth.Inj 1 THEN 
paulson@2133
   654
    Fast_tac 1);
paulson@2133
   655
by (eres_inst_tac [("P","Nonce NB : ?HH")] rev_mp 1);
paulson@2133
   656
by (asm_simp_tac (!simpset addsimps [analz_image_newK]
paulson@2170
   657
                           setloop split_tac [expand_if]) 1);
paulson@2133
   658
(** LEVEL 15 **)
paulson@2133
   659
by (grind_tac 1);
paulson@2133
   660
by (REPEAT (dtac not_analz_insert 1));
paulson@2133
   661
by (lost_tac "A" 1);
paulson@2133
   662
by (dtac (Says_imp_sees_Spy RS parts.Inj RS parts.Fst RS A_trust_YM3) 1
paulson@2133
   663
    THEN REPEAT (assume_tac 1));
paulson@2133
   664
by (fast_tac (!claset delrules [allE, conjI] addSIs [bexI, exI]) 1);
paulson@2133
   665
by (fast_tac (!claset delrules [conjI]
paulson@2170
   666
                      addIs [impOfSubs (subset_insertI RS analz_mono)]
paulson@2170
   667
                      addss (!simpset)) 1);
paulson@2133
   668
val Nonce_secrecy = result() RS spec RSN (2, rev_mp) |> standard;
paulson@2133
   669
paulson@2133
   670
paulson@2133
   671
(*Version required below: if NB can be decrypted using a session key then it
paulson@2133
   672
  was distributed with that key.  The more general form above is required
paulson@2133
   673
  for the induction to carry through.*)
paulson@2133
   674
goal thy 
paulson@2133
   675
 "!!evs. [| Says Server A                                                     \
paulson@2284
   676
\            {|Crypt (shrK A) {|Agent B, Key (newK evt), na, Nonce NB'|}, X|} \
paulson@2133
   677
\           : set_of_list evs;                                                \
paulson@2133
   678
\           Nonce NB : analz (insert (Key (newK evt)) (sees lost Spy evs));   \
paulson@2133
   679
\           evs : yahalom lost |]                                             \
paulson@2133
   680
\ ==> Nonce NB : analz (sees lost Spy evs) | NB = NB'";
paulson@2133
   681
by (asm_full_simp_tac (HOL_ss addsimps [insert_Key_singleton]) 1);
paulson@2133
   682
by (dtac Nonce_secrecy 1 THEN assume_tac 1);
paulson@2133
   683
by (fast_tac (!claset addDs [unique_session_keys]
paulson@2170
   684
                      addss (!simpset)) 1);
paulson@2133
   685
val single_Nonce_secrecy = result();
paulson@2133
   686
paulson@2133
   687
paulson@2133
   688
goal thy 
paulson@2133
   689
 "!!evs. [| A ~: lost;  B ~: lost;  Spy: lost;  evs : yahalom lost |]  \
paulson@2133
   690
\ ==> Says B Server                                                    \
paulson@2284
   691
\          {|Agent B, Crypt (shrK B) {|Agent A, Nonce NA, Nonce NB|}|} \
paulson@2133
   692
\     : set_of_list evs -->                               \
paulson@2133
   693
\     (ALL k. Says A Spy {|Nonce NA, Nonce NB, k|} ~: set_of_list evs) -->  \
paulson@2133
   694
\     Nonce NB ~: analz (sees lost Spy evs)";
paulson@2133
   695
by (etac yahalom.induct 1);
paulson@2133
   696
by analz_Fake_tac;
paulson@2133
   697
by (ALLGOALS
paulson@2133
   698
    (asm_simp_tac 
paulson@2133
   699
     (!simpset addsimps ([analz_subset_parts RS contra_subsetD,
paulson@2133
   700
                          analz_insert_Key_newK] @ pushes)
paulson@2133
   701
               setloop split_tac [expand_if])));
paulson@2133
   702
by (fast_tac (!claset addSIs [parts_insertI]
paulson@2133
   703
                      addSEs partsEs
paulson@2133
   704
                      addEs [Says_imp_old_nonces RS less_irrefl]
paulson@2133
   705
                      addss (!simpset)) 2);
paulson@2133
   706
(*Proof of YM2*) (** LEVEL 5 **)
paulson@2133
   707
by (REPEAT (Safe_step_tac 2 ORELSE Fast_tac 2)); 
paulson@2133
   708
by (fast_tac (!claset addIs [parts_insertI]
paulson@2133
   709
                      addSEs partsEs
paulson@2133
   710
                      addEs [Says_imp_old_nonces RS less_irrefl]
paulson@2133
   711
                      addss (!simpset)) 3);
paulson@2133
   712
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS analz.Inj]) 2);
paulson@2133
   713
(*Prove YM3 by showing that no NB can also be an NA*)
paulson@2133
   714
by (REPEAT (Safe_step_tac 2 ORELSE no_nonce_tac 2));
paulson@2133
   715
by (deepen_tac (!claset addDs [Says_unique_NB]) 1 2);
paulson@2133
   716
(*Fake*) (** LEVEL 10 **)
paulson@2133
   717
by (SELECT_GOAL (REPEAT (Safe_step_tac 1 ORELSE spy_analz_tac 1)) 1);
paulson@2133
   718
(*YM4*)
paulson@2133
   719
by (res_inst_tac [("x1","X")] (insert_commute RS ssubst) 1);
paulson@2133
   720
by (simp_tac (!simpset setloop split_tac [expand_if]) 1);
paulson@2133
   721
by (SELECT_GOAL (REPEAT_FIRST (Safe_step_tac ORELSE' spy_analz_tac)) 1);
paulson@2133
   722
(** LEVEL 14 **)
paulson@2133
   723
by (lost_tac "Aa" 1);
paulson@2170
   724
by (dtac (Says_imp_sees_Spy RS parts.Inj RS parts.Fst RS A_trust_YM3) 1);
paulson@2133
   725
by (forward_tac [Says_Server_message_form] 3);
paulson@2133
   726
by (forward_tac [Says_Server_imp_YM2] 4);
paulson@2133
   727
by (REPEAT_FIRST ((eresolve_tac [asm_rl, bexE, exE, disjE])));
paulson@2133
   728
by (Full_simp_tac 1);
paulson@2133
   729
(** LEVEL 20 **)
paulson@2133
   730
by (REPEAT_FIRST hyp_subst_tac);
paulson@2133
   731
by (lost_tac "Ba" 1);
paulson@2170
   732
by (dtac (Says_imp_sees_Spy RS parts.Inj RS parts.Snd RS unique_NB) 1);
paulson@2133
   733
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS parts.Inj]
paulson@2133
   734
                      addSEs [MPair_parts]) 1);
paulson@2133
   735
by (REPEAT (assume_tac 1 ORELSE Safe_step_tac 1)); 
paulson@2170
   736
by (dtac Spy_not_see_encrypted_key 1);
paulson@2133
   737
by (REPEAT (assume_tac 1 ORELSE Fast_tac 1)); 
paulson@2133
   738
by (spy_analz_tac 1);
paulson@2133
   739
(*Oops case*) (** LEVEL 28 **)
paulson@2133
   740
by (full_simp_tac (!simpset addsimps [all_conj_distrib]) 1);
paulson@2133
   741
by (step_tac (!claset delrules [disjE, conjI]) 1);
paulson@2133
   742
by (forward_tac [Says_Server_imp_YM2] 1 THEN assume_tac 1 THEN etac exE 1);
paulson@2133
   743
by (expand_case_tac "NB = NBa" 1);
paulson@2133
   744
by (deepen_tac (!claset addDs [Says_unique_NB]) 1 1);
paulson@2170
   745
by (rtac conjI 1);
paulson@2133
   746
by (no_nonce_tac 1);
paulson@2133
   747
(** LEVEL 35 **)
paulson@2133
   748
by (thin_tac "?PP|?QQ" 1);  (*subsumption!*)
paulson@2133
   749
by (fast_tac (!claset addSDs [single_Nonce_secrecy]) 1);
paulson@2133
   750
val Spy_not_see_NB = result() RSN(2,rev_mp) RSN(2,rev_mp) |> standard;
paulson@2133
   751
paulson@2001
   752
paulson@2110
   753
(*What can B deduce from receipt of YM4?  Note how the two components of
paulson@2110
   754
  the message contribute to a single conclusion about the Server's message.
paulson@2110
   755
  It's annoying that the "Says A Spy" assumption must quantify over 
paulson@2133
   756
  ALL POSSIBLE keys instead of our particular K (though at least the
paulson@2133
   757
  nonces are forced to agree with NA and NB). *)
paulson@2001
   758
goal thy 
paulson@2133
   759
 "!!evs. [| Says B Server                                        \
paulson@2284
   760
\            {|Agent B, Crypt (shrK B) {|Agent A, Nonce NA, Nonce NB|}|}  \
paulson@2133
   761
\           : set_of_list evs;       \
paulson@2284
   762
\           Says A' B {|Crypt (shrK B) {|Agent A, Key K|},              \
paulson@2284
   763
\                       Crypt K (Nonce NB)|} : set_of_list evs;         \
paulson@2133
   764
\           ALL k. Says A Spy {|Nonce NA, Nonce NB, k|} ~: set_of_list evs; \
paulson@2133
   765
\           A ~: lost;  B ~: lost;  Spy: lost;  evs : yahalom lost |]   \
paulson@2133
   766
\         ==> Says Server A                                       \
paulson@2284
   767
\                     {|Crypt (shrK A) {|Agent B, Key K,                         \
paulson@2284
   768
\                               Nonce NA, Nonce NB|},          \
paulson@2284
   769
\                       Crypt (shrK B) {|Agent A, Key K|}|}             \
paulson@2001
   770
\                   : set_of_list evs";
paulson@2133
   771
by (forward_tac [Spy_not_see_NB] 1 THEN REPEAT (assume_tac 1));
paulson@2133
   772
by (etac (Says_imp_sees_Spy RS parts.Inj RS MPair_parts) 1 THEN
paulson@2133
   773
    dtac B_trusts_YM4_shrK 1);
paulson@2170
   774
by (dtac B_trusts_YM4_newK 3);
paulson@2110
   775
by (REPEAT_FIRST (eresolve_tac [asm_rl, exE]));
paulson@2133
   776
by (forward_tac [Says_Server_imp_YM2] 1 THEN assume_tac 1);
paulson@2170
   777
by (dtac unique_session_keys 1 THEN REPEAT (assume_tac 1));
paulson@2133
   778
by (deepen_tac (!claset addDs [Says_unique_NB] addss (!simpset)) 0 1);
paulson@2110
   779
qed "B_trust_YM4";
paulson@2133
   780
paulson@2133
   781
paulson@2133
   782