src/HOL/Auth/Yahalom2.ML
author paulson
Thu Jun 19 11:28:55 1997 +0200 (1997-06-19)
changeset 3450 cd73bc206d87
parent 3432 04412cfe6861
child 3465 e85c24717cad
permissions -rw-r--r--
Proof tidying and variable renaming (NA->na, NB->nb when of type msg)
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@3432
    20
(*Replacing the variable by a constant improves speed*)
paulson@3432
    21
val Says_imp_sees_Spy' = read_instantiate [("lost","lost")] Says_imp_sees_Spy;
paulson@3432
    22
paulson@3432
    23
paulson@2323
    24
(*A "possibility property": there are traces that reach the end*)
paulson@2111
    25
goal thy 
paulson@2111
    26
 "!!A B. [| A ~= B; A ~= Server; B ~= Server |]   \
paulson@2111
    27
\        ==> EX X NB K. EX evs: yahalom lost.          \
paulson@2284
    28
\               Says A B {|X, Crypt K (Nonce NB)|} : set_of_list evs";
paulson@2111
    29
by (REPEAT (resolve_tac [exI,bexI] 1));
paulson@2516
    30
by (rtac (yahalom.Nil RS yahalom.YM1 RS yahalom.YM2 RS yahalom.YM3 RS 
paulson@2516
    31
          yahalom.YM4) 2);
paulson@2516
    32
by possibility_tac;
paulson@2111
    33
result();
paulson@2111
    34
paulson@2111
    35
paulson@2111
    36
(**** Inductive proofs about yahalom ****)
paulson@2111
    37
paulson@2111
    38
(*Monotonicity*)
paulson@2111
    39
goal thy "!!evs. lost' <= lost ==> yahalom lost' <= yahalom lost";
paulson@2111
    40
by (rtac subsetI 1);
paulson@2111
    41
by (etac yahalom.induct 1);
paulson@2111
    42
by (REPEAT_FIRST
paulson@3432
    43
    (blast_tac (!claset addIs (impOfSubs(sees_mono RS analz_mono RS synth_mono)
paulson@3432
    44
			       :: yahalom.intrs))));
paulson@2111
    45
qed "yahalom_mono";
paulson@2111
    46
paulson@2111
    47
paulson@2111
    48
(*Nobody sends themselves messages*)
paulson@2111
    49
goal thy "!!evs. evs: yahalom lost ==> ALL A X. Says A A X ~: set_of_list evs";
paulson@2111
    50
by (etac yahalom.induct 1);
paulson@2111
    51
by (Auto_tac());
paulson@2111
    52
qed_spec_mp "not_Says_to_self";
paulson@2111
    53
Addsimps [not_Says_to_self];
paulson@2111
    54
AddSEs   [not_Says_to_self RSN (2, rev_notE)];
paulson@2111
    55
paulson@2111
    56
paulson@2111
    57
(** For reasoning about the encrypted portion of messages **)
paulson@2111
    58
paulson@2111
    59
(*Lets us treat YM4 using a similar argument as for the Fake case.*)
paulson@2284
    60
goal thy "!!evs. Says S A {|NB, Crypt (shrK A) Y, X|} : set_of_list evs ==> \
paulson@2111
    61
\                X : analz (sees lost Spy evs)";
paulson@3432
    62
by (blast_tac (!claset addSDs [Says_imp_sees_Spy' RS analz.Inj]) 1);
paulson@2111
    63
qed "YM4_analz_sees_Spy";
paulson@2111
    64
paulson@2111
    65
bind_thm ("YM4_parts_sees_Spy",
paulson@2111
    66
          YM4_analz_sees_Spy RS (impOfSubs analz_subset_parts));
paulson@2111
    67
paulson@2155
    68
(*Relates to both YM4 and Oops*)
paulson@2284
    69
goal thy "!!evs. Says S A {|NB, Crypt (shrK A) {|B, K, NA|}, X|} \
paulson@2111
    70
\                  : set_of_list evs ==> \
paulson@2111
    71
\                K : parts (sees lost Spy evs)";
paulson@3121
    72
by (blast_tac (!claset addSEs partsEs
paulson@3432
    73
                      addSDs [Says_imp_sees_Spy' RS parts.Inj]) 1);
paulson@2111
    74
qed "YM4_Key_parts_sees_Spy";
paulson@2111
    75
paulson@3121
    76
(*For proving the easier theorems about X ~: parts (sees lost Spy evs).
paulson@3121
    77
  We instantiate the variable to "lost" since leaving it as a Var would
paulson@3121
    78
  interfere with simplification.*)
paulson@3432
    79
val parts_sees_tac = 
paulson@3121
    80
    forw_inst_tac [("lost","lost")] YM4_parts_sees_Spy 6     THEN
paulson@3121
    81
    forw_inst_tac [("lost","lost")] YM4_Key_parts_sees_Spy 7 THEN
paulson@3121
    82
    prove_simple_subgoals_tac  1;
paulson@2111
    83
paulson@3432
    84
val parts_induct_tac = 
paulson@3432
    85
    etac yahalom.induct 1 THEN parts_sees_tac;
paulson@3432
    86
paulson@2111
    87
paulson@2111
    88
(** Theorems of the form X ~: parts (sees lost Spy evs) imply that NOBODY
paulson@2111
    89
    sends messages containing X! **)
paulson@2111
    90
paulson@2516
    91
(*Spy never sees another agent's shared key! (unless it's lost at start)*)
paulson@2111
    92
goal thy 
paulson@2516
    93
 "!!evs. evs : yahalom lost \
paulson@2516
    94
\        ==> (Key (shrK A) : parts (sees lost Spy evs)) = (A : lost)";
paulson@3121
    95
by parts_induct_tac;
paulson@3121
    96
by (Fake_parts_insert_tac 1);
paulson@3121
    97
by (Blast_tac 1);
paulson@2516
    98
qed "Spy_see_shrK";
paulson@2516
    99
Addsimps [Spy_see_shrK];
paulson@2111
   100
paulson@2516
   101
goal thy 
paulson@2516
   102
 "!!evs. evs : yahalom lost \
paulson@2516
   103
\        ==> (Key (shrK A) : analz (sees lost Spy evs)) = (A : lost)";
paulson@2516
   104
by (auto_tac(!claset addDs [impOfSubs analz_subset_parts], !simpset));
paulson@2516
   105
qed "Spy_analz_shrK";
paulson@2516
   106
Addsimps [Spy_analz_shrK];
paulson@2111
   107
paulson@2516
   108
goal thy  "!!A. [| Key (shrK A) : parts (sees lost Spy evs);       \
paulson@2516
   109
\                  evs : yahalom lost |] ==> A:lost";
paulson@3121
   110
by (blast_tac (!claset addDs [Spy_see_shrK]) 1);
paulson@2516
   111
qed "Spy_see_shrK_D";
paulson@2111
   112
paulson@2516
   113
bind_thm ("Spy_analz_shrK_D", analz_subset_parts RS subsetD RS Spy_see_shrK_D);
paulson@2516
   114
AddSDs [Spy_see_shrK_D, Spy_analz_shrK_D];
paulson@2111
   115
paulson@2111
   116
paulson@3432
   117
(*Nobody can have used non-existent keys!  Needed to apply analz_insert_Key*)
paulson@2516
   118
goal thy "!!evs. evs : yahalom lost ==>          \
paulson@2516
   119
\         Key K ~: used evs --> K ~: keysFor (parts (sees lost Spy evs))";
paulson@3121
   120
by parts_induct_tac;
paulson@2516
   121
(*YM4: Key K is not fresh!*)
paulson@3121
   122
by (blast_tac (!claset addSEs sees_Spy_partsEs) 3);
paulson@2516
   123
(*YM3*)
paulson@3121
   124
by (blast_tac (!claset addss (!simpset)) 2);
paulson@2516
   125
(*Fake*)
paulson@2516
   126
by (best_tac
paulson@2516
   127
      (!claset addIs [impOfSubs analz_subset_parts]
paulson@2516
   128
               addDs [impOfSubs (analz_subset_parts RS keysFor_mono),
paulson@2516
   129
                      impOfSubs (parts_insert_subset_Un RS keysFor_mono)]
paulson@2516
   130
               addss (!simpset)) 1);
paulson@2160
   131
qed_spec_mp "new_keys_not_used";
paulson@2111
   132
paulson@2111
   133
bind_thm ("new_keys_not_analzd",
paulson@2111
   134
          [analz_subset_parts RS keysFor_mono,
paulson@2111
   135
           new_keys_not_used] MRS contra_subsetD);
paulson@2111
   136
paulson@2111
   137
Addsimps [new_keys_not_used, new_keys_not_analzd];
paulson@2111
   138
paulson@2155
   139
(*Describes the form of K when the Server sends this message.  Useful for
paulson@2155
   140
  Oops as well as main secrecy property.*)
paulson@2111
   141
goal thy 
paulson@2516
   142
 "!!evs. [| Says Server A {|NB', Crypt (shrK A) {|Agent B, Key K, NA|}, X|} \
paulson@2155
   143
\            : set_of_list evs;                                         \
paulson@2155
   144
\           evs : yahalom lost |]                                       \
paulson@2516
   145
\        ==> K ~: range shrK & A ~= B";
paulson@2155
   146
by (etac rev_mp 1);
paulson@2155
   147
by (etac yahalom.induct 1);
paulson@3121
   148
by (ALLGOALS Asm_simp_tac);
paulson@2155
   149
qed "Says_Server_message_form";
paulson@2111
   150
paulson@2111
   151
paulson@2111
   152
(*For proofs involving analz.  We again instantiate the variable to "lost".*)
paulson@3121
   153
val analz_sees_tac = 
paulson@2111
   154
    dres_inst_tac [("lost","lost")] YM4_analz_sees_Spy 6 THEN
paulson@2155
   155
    forw_inst_tac [("lost","lost")] Says_Server_message_form 7 THEN
paulson@2516
   156
    assume_tac 7 THEN
paulson@2516
   157
    REPEAT ((etac conjE ORELSE' hyp_subst_tac) 7);
paulson@2111
   158
paulson@2111
   159
paulson@2111
   160
(****
paulson@2111
   161
 The following is to prove theorems of the form
paulson@2111
   162
paulson@2516
   163
          Key K : analz (insert (Key KAB) (sees lost Spy evs)) ==>
paulson@2111
   164
          Key K : analz (sees lost Spy evs)
paulson@2111
   165
paulson@2111
   166
 A more general formula must be proved inductively.
paulson@2111
   167
paulson@2111
   168
****)
paulson@2111
   169
paulson@2111
   170
(** Session keys are not used to encrypt other session keys **)
paulson@2111
   171
paulson@2111
   172
goal thy  
paulson@2111
   173
 "!!evs. evs : yahalom lost ==> \
paulson@2516
   174
\  ALL K KK. KK <= Compl (range shrK) -->                      \
paulson@2516
   175
\            (Key K : analz (Key``KK Un (sees lost Spy evs))) = \
paulson@2516
   176
\            (K : KK | Key K : analz (sees lost Spy evs))";
paulson@2111
   177
by (etac yahalom.induct 1);
paulson@3121
   178
by analz_sees_tac;
paulson@2516
   179
by (REPEAT_FIRST (resolve_tac [allI, impI]));
paulson@2516
   180
by (REPEAT_FIRST (rtac analz_image_freshK_lemma ));
paulson@2516
   181
by (ALLGOALS (asm_simp_tac analz_image_freshK_ss));
paulson@3450
   182
(*Fake*) 
paulson@3450
   183
by (spy_analz_tac 2);
paulson@2516
   184
(*Base*)
paulson@3450
   185
by (Blast_tac 1);
paulson@2516
   186
qed_spec_mp "analz_image_freshK";
paulson@2111
   187
paulson@2111
   188
goal thy
paulson@2516
   189
 "!!evs. [| evs : yahalom lost;  KAB ~: range shrK |] ==>             \
paulson@2516
   190
\        Key K : analz (insert (Key KAB) (sees lost Spy evs)) = \
paulson@2516
   191
\        (K = KAB | Key K : analz (sees lost Spy evs))";
paulson@2516
   192
by (asm_simp_tac (analz_image_freshK_ss addsimps [analz_image_freshK]) 1);
paulson@2516
   193
qed "analz_insert_freshK";
paulson@2111
   194
paulson@2111
   195
paulson@2111
   196
(*** The Key K uniquely identifies the Server's  message. **)
paulson@2111
   197
paulson@2111
   198
goal thy 
paulson@2111
   199
 "!!evs. evs : yahalom lost ==>                                     \
paulson@3450
   200
\      EX A' B' na' nb' X'. ALL A B na nb X.                        \
paulson@2111
   201
\          Says Server A                                            \
paulson@3450
   202
\           {|nb, Crypt (shrK A) {|Agent B, Key K, na|}, X|}        \
paulson@3450
   203
\          : set_of_list evs --> A=A' & B=B' & na=na' & nb=nb' & X=X'";
paulson@2111
   204
by (etac yahalom.induct 1);
paulson@2111
   205
by (ALLGOALS (asm_simp_tac (!simpset addsimps [all_conj_distrib])));
paulson@2111
   206
by (Step_tac 1);
paulson@2111
   207
(*Remaining case: YM3*)
paulson@2111
   208
by (expand_case_tac "K = ?y" 1);
paulson@2111
   209
by (REPEAT (ares_tac [refl,exI,impI,conjI] 2));
paulson@2516
   210
(*...we assume X is a recent message and handle this case by contradiction*)
paulson@3121
   211
by (blast_tac (!claset addSEs sees_Spy_partsEs
paulson@2111
   212
                      delrules [conjI]    (*prevent split-up into 4 subgoals*)
paulson@2111
   213
                      addss (!simpset addsimps [parts_insertI])) 1);
paulson@2111
   214
val lemma = result();
paulson@2111
   215
paulson@2111
   216
goal thy 
paulson@2111
   217
"!!evs. [| Says Server A                                            \
paulson@3450
   218
\           {|nb, Crypt (shrK A) {|Agent B, Key K, na|}, X|}        \
paulson@2111
   219
\           : set_of_list evs;                                      \
paulson@2111
   220
\          Says Server A'                                           \
paulson@3450
   221
\           {|nb', Crypt (shrK A') {|Agent B', Key K, na'|}, X'|}   \
paulson@2111
   222
\           : set_of_list evs;                                      \
paulson@2111
   223
\          evs : yahalom lost |]                                    \
paulson@3450
   224
\       ==> A=A' & B=B' & na=na' & nb=nb'";
paulson@2451
   225
by (prove_unique_tac lemma 1);
paulson@2111
   226
qed "unique_session_keys";
paulson@2111
   227
paulson@2111
   228
paulson@2111
   229
(** Crucial secrecy property: Spy does not see the keys sent in msg YM3 **)
paulson@2111
   230
paulson@2111
   231
goal thy 
paulson@2155
   232
 "!!evs. [| A ~: lost;  B ~: lost;  A ~= B;                          \
paulson@3121
   233
\           evs : yahalom lost |]                                    \
paulson@2111
   234
\        ==> Says Server A                                           \
paulson@3450
   235
\              {|nb, Crypt (shrK A) {|Agent B, Key K, na|},          \
paulson@3450
   236
\                    Crypt (shrK B) {|nb, Key K, Agent A|}|}         \
paulson@3121
   237
\             : set_of_list evs -->                                  \
paulson@3450
   238
\            Says A Spy {|na, nb, Key K|} ~: set_of_list evs -->     \
paulson@2111
   239
\            Key K ~: analz (sees lost Spy evs)";
paulson@2111
   240
by (etac yahalom.induct 1);
paulson@3121
   241
by analz_sees_tac;
paulson@2111
   242
by (ALLGOALS
paulson@2111
   243
    (asm_simp_tac 
paulson@3450
   244
     (!simpset addsimps [analz_insert_eq, not_parts_not_analz, 
paulson@3450
   245
			 analz_insert_freshK]
paulson@2111
   246
               setloop split_tac [expand_if])));
paulson@3450
   247
(*Oops*)
paulson@3450
   248
by (blast_tac (!claset addDs [unique_session_keys]) 3);
paulson@2111
   249
(*YM3*)
paulson@3121
   250
by (blast_tac (!claset delrules [impCE]
paulson@3432
   251
                       addSEs sees_Spy_partsEs
paulson@3432
   252
                       addIs [impOfSubs analz_subset_parts]) 2);
paulson@3450
   253
(*Fake*) 
paulson@3450
   254
by (spy_analz_tac 1);
paulson@2111
   255
val lemma = result() RS mp RS mp RSN(2,rev_notE);
paulson@2111
   256
paulson@2111
   257
paulson@3432
   258
(*Final version*)
paulson@2111
   259
goal thy 
paulson@2111
   260
 "!!evs. [| Says Server A                                         \
paulson@3450
   261
\              {|nb, Crypt (shrK A) {|Agent B, Key K, na|},       \
paulson@3450
   262
\                    Crypt (shrK B) {|nb, Key K, Agent A|}|}      \
paulson@2111
   263
\           : set_of_list evs;                                    \
paulson@3450
   264
\           Says A Spy {|na, nb, Key K|} ~: set_of_list evs;      \
paulson@2155
   265
\           A ~: lost;  B ~: lost;  evs : yahalom lost |]         \
paulson@2516
   266
\        ==> Key K ~: analz (sees lost Spy evs)";
paulson@2111
   267
by (forward_tac [Says_Server_message_form] 1 THEN assume_tac 1);
paulson@3121
   268
by (blast_tac (!claset addSEs [lemma]) 1);
paulson@2111
   269
qed "Spy_not_see_encrypted_key";
paulson@2111
   270
paulson@2111
   271
paulson@3432
   272
(*And other agents don't see the key either.*)
paulson@2111
   273
goal thy 
paulson@2155
   274
 "!!evs. [| C ~: {A,B,Server};                                    \
paulson@2111
   275
\           Says Server A                                         \
paulson@3450
   276
\              {|nb, Crypt (shrK A) {|Agent B, Key K, na|},       \
paulson@3450
   277
\                    Crypt (shrK B) {|nb, Key K, Agent A|}|}      \
paulson@2111
   278
\           : set_of_list evs;                                    \
paulson@3450
   279
\           Says A Spy {|na, nb, Key K|} ~: set_of_list evs;      \
paulson@2155
   280
\           A ~: lost;  B ~: lost;  evs : yahalom lost |]         \
paulson@2516
   281
\        ==> Key K ~: analz (sees lost C evs)";
paulson@2111
   282
by (rtac (subset_insertI RS sees_mono RS analz_mono RS contra_subsetD) 1);
paulson@2111
   283
by (rtac (sees_lost_agent_subset_sees_Spy RS analz_mono RS contra_subsetD) 1);
paulson@2111
   284
by (FIRSTGOAL (rtac Spy_not_see_encrypted_key));
paulson@3121
   285
by (REPEAT_FIRST (blast_tac (!claset addIs [yahalom_mono RS subsetD])));
paulson@2111
   286
qed "Agent_not_see_encrypted_key";
paulson@2111
   287
paulson@2111
   288
paulson@3450
   289
(** Security Guarantee for A upon receiving YM3 **)
paulson@2155
   290
paulson@3432
   291
(*If the encrypted message appears then it originated with the Server.
paulson@3432
   292
  May now apply Spy_not_see_encrypted_key, subject to its conditions.*)
paulson@2155
   293
goal thy
paulson@3450
   294
 "!!evs. [| Crypt (shrK A) {|Agent B, Key K, na|}                      \
paulson@2155
   295
\            : parts (sees lost Spy evs);                              \
paulson@2155
   296
\           A ~: lost;  evs : yahalom lost |]                          \
paulson@3450
   297
\         ==> EX nb. Says Server A                                     \
paulson@3450
   298
\                      {|nb, Crypt (shrK A) {|Agent B, Key K, na|},    \
paulson@3450
   299
\                            Crypt (shrK B) {|nb, Key K, Agent A|}|}   \
paulson@2155
   300
\                    : set_of_list evs";
paulson@2155
   301
by (etac rev_mp 1);
paulson@3121
   302
by parts_induct_tac;
paulson@3121
   303
by (Fake_parts_insert_tac 1);
paulson@3121
   304
by (Blast_tac 1);
paulson@2323
   305
qed "A_trusts_YM3";
paulson@2155
   306
paulson@2111
   307
paulson@3450
   308
(** Security Guarantee for B upon receiving YM4 **)
paulson@3450
   309
paulson@2111
   310
(*B knows, by the first part of A's message, that the Server distributed 
paulson@3450
   311
  the key for A and B, and has associated it with NB. *)
paulson@2111
   312
goal thy 
paulson@2284
   313
 "!!evs. [| Crypt (shrK B) {|Nonce NB, Key K, Agent A|}              \
paulson@2155
   314
\            : parts (sees lost Spy evs);                            \
paulson@2155
   315
\           B ~: lost;  evs : yahalom lost |]                        \
paulson@2111
   316
\        ==> EX NA. Says Server A                                    \
paulson@2155
   317
\                    {|Nonce NB,                                     \
paulson@2284
   318
\                      Crypt (shrK A) {|Agent B, Key K, Nonce NA|},  \
paulson@2284
   319
\                      Crypt (shrK B) {|Nonce NB, Key K, Agent A|}|} \
paulson@2111
   320
\                       : set_of_list evs";
paulson@2111
   321
by (etac rev_mp 1);
paulson@3121
   322
by parts_induct_tac;
paulson@3121
   323
by (Fake_parts_insert_tac 1);
paulson@2111
   324
(*YM3*)
paulson@3121
   325
by (Blast_tac 1);
paulson@2111
   326
qed "B_trusts_YM4_shrK";
paulson@2111
   327
paulson@3450
   328
paulson@3450
   329
(*With this protocol variant, we don't need the 2nd part of YM4 at all:
paulson@3450
   330
  Nonce NB is available in the first part.*)
paulson@2111
   331
paulson@2155
   332
(*What can B deduce from receipt of YM4?  Stronger and simpler than Yahalom
paulson@2155
   333
  because we do not have to show that NB is secret. *)
paulson@2111
   334
goal thy 
paulson@3450
   335
 "!!evs. [| Says A' B {|Crypt (shrK B) {|Nonce NB, Key K, Agent A|}, X|} \
paulson@3450
   336
\             : set_of_list evs;                                         \
paulson@3450
   337
\           A ~: lost;  B ~: lost;  evs : yahalom lost |]                \
paulson@3450
   338
\        ==> EX NA. Says Server A                                        \
paulson@3450
   339
\                    {|Nonce NB,                                         \
paulson@3450
   340
\                      Crypt (shrK A) {|Agent B, Key K, Nonce NA|},      \
paulson@3450
   341
\                      Crypt (shrK B) {|Nonce NB, Key K, Agent A|}|}     \
paulson@2111
   342
\                   : set_of_list evs";
paulson@3432
   343
by (etac (Says_imp_sees_Spy' RS parts.Inj RS MPair_parts) 1);
paulson@3121
   344
by (blast_tac (!claset addSDs [B_trusts_YM4_shrK]) 1);
paulson@2323
   345
qed "B_trusts_YM4";
paulson@3432
   346
paulson@3432
   347
paulson@3432
   348
paulson@3432
   349
(*** Authenticating B to A ***)
paulson@3432
   350
paulson@3432
   351
(*The encryption in message YM2 tells us it cannot be faked.*)
paulson@3432
   352
goal thy 
paulson@3432
   353
 "!!evs. evs : yahalom lost                                            \
paulson@3432
   354
\  ==> Crypt (shrK B) {|Agent A, Nonce NA|} : parts (sees lost Spy evs) -->  \
paulson@3450
   355
\      B ~: lost -->                                                   \
paulson@3432
   356
\      (EX NB. Says B Server {|Agent B, Nonce NB,                      \
paulson@3432
   357
\                              Crypt (shrK B) {|Agent A, Nonce NA|}|}  \
paulson@3432
   358
\         : set_of_list evs)";
paulson@3432
   359
by parts_induct_tac;
paulson@3432
   360
by (Fake_parts_insert_tac 1);
paulson@3432
   361
(*YM2*)
paulson@3432
   362
by (Blast_tac 1);
paulson@3432
   363
bind_thm ("B_Said_YM2", result() RSN (2, rev_mp) RS mp);
paulson@3432
   364
paulson@3432
   365
(*If the server sends YM3 then B sent YM2, perhaps with a different NB*)
paulson@3432
   366
goal thy 
paulson@3432
   367
 "!!evs. evs : yahalom lost                                       \
paulson@3432
   368
\  ==> Says Server A {|nb, Crypt (shrK A) {|Agent B, Key K, Nonce NA|}, X|} \
paulson@3432
   369
\         : set_of_list evs -->                                          \
paulson@3432
   370
\      B ~: lost -->                                                     \
paulson@3432
   371
\      (EX nb'. Says B Server {|Agent B, nb',                            \
paulson@3432
   372
\                               Crypt (shrK B) {|Agent A, Nonce NA|}|}   \
paulson@3432
   373
\                 : set_of_list evs)";
paulson@3432
   374
by (etac yahalom.induct 1);
paulson@3432
   375
by (ALLGOALS Asm_simp_tac);
paulson@3432
   376
(*YM3*)
paulson@3432
   377
by (blast_tac (!claset addSDs [B_Said_YM2]
paulson@3432
   378
		       addSEs [MPair_parts]
paulson@3432
   379
		       addDs [Says_imp_sees_Spy' RS parts.Inj]) 3);
paulson@3432
   380
(*Fake, YM2*)
paulson@3432
   381
by (ALLGOALS Blast_tac);
paulson@3450
   382
val lemma = result() RSN (2, rev_mp) RS mp |> standard;
paulson@3432
   383
paulson@3432
   384
(*If A receives YM3 then B has used nonce NA (and therefore is alive)*)
paulson@3432
   385
goal thy
paulson@3450
   386
 "!!evs. [| Says S A {|nb, Crypt (shrK A) {|Agent B, Key K, Nonce NA|}, X|} \
paulson@3450
   387
\             : set_of_list evs;                                            \
paulson@3450
   388
\           A ~: lost;  B ~: lost;  evs : yahalom lost |]                   \
paulson@3450
   389
\   ==> EX nb'. Says B Server                                               \
paulson@3450
   390
\                    {|Agent B, nb', Crypt (shrK B) {|Agent A, Nonce NA|}|} \
paulson@3450
   391
\                 : set_of_list evs";
paulson@3450
   392
by (blast_tac (!claset addSDs [A_trusts_YM3, lemma]
paulson@3432
   393
		       addEs sees_Spy_partsEs) 1);
paulson@3432
   394
qed "YM3_auth_B_to_A";
paulson@3432
   395
paulson@3432
   396
paulson@3450
   397
(*** Authenticating A to B using the certificate Crypt K (Nonce NB) ***)
paulson@3450
   398
paulson@3432
   399
(*Induction for theorems of the form X ~: analz (sees lost Spy evs) --> ...
paulson@3432
   400
  It simplifies the proof by discarding needless information about
paulson@3432
   401
	analz (insert X (sees lost Spy evs)) 
paulson@3432
   402
*)
paulson@3432
   403
val analz_mono_parts_induct_tac = 
paulson@3432
   404
    etac yahalom.induct 1 
paulson@3432
   405
    THEN 
paulson@3432
   406
    REPEAT_FIRST  
paulson@3432
   407
      (rtac impI THEN' 
paulson@3432
   408
       dtac (sees_subset_sees_Says RS analz_mono RS contra_subsetD) THEN'
paulson@3432
   409
       mp_tac)  
paulson@3432
   410
    THEN  parts_sees_tac;
paulson@3432
   411
paulson@3450
   412
(*Assuming the session key is secure, if both certificates are present then
paulson@3432
   413
  A has said NB.  We can't be sure about the rest of A's message, but only
paulson@3432
   414
  NB matters for freshness.*)  
paulson@3432
   415
goal thy 
paulson@3432
   416
 "!!evs. evs : yahalom lost                                             \
paulson@3432
   417
\        ==> Key K ~: analz (sees lost Spy evs) -->                     \
paulson@3432
   418
\            Crypt K (Nonce NB) : parts (sees lost Spy evs) -->         \
paulson@3432
   419
\            Crypt (shrK B) {|Nonce NB, Key K, Agent A|}                \
paulson@3432
   420
\              : parts (sees lost Spy evs) -->                          \
paulson@3450
   421
\            B ~: lost -->                                              \
paulson@3432
   422
\             (EX X. Says A B {|X, Crypt K (Nonce NB)|} : set_of_list evs)";
paulson@3432
   423
by analz_mono_parts_induct_tac;
paulson@3432
   424
(*Fake*)
paulson@3432
   425
by (Fake_parts_insert_tac 1);
paulson@3432
   426
(*YM3: by new_keys_not_used we note that Crypt K (Nonce NB) could not exist*)
paulson@3432
   427
by (fast_tac (!claset addSDs [Crypt_imp_invKey_keysFor] addss (!simpset)) 1); 
paulson@3450
   428
(*YM4: was Crypt K (Nonce NB) the very last message?  If not, use ind. hyp.*)
paulson@3450
   429
by (asm_simp_tac (!simpset addsimps [ex_disj_distrib]) 1);
paulson@3450
   430
(*yes: apply unicity of session keys*)
paulson@3450
   431
by (not_lost_tac "Aa" 1);
paulson@3432
   432
by (blast_tac (!claset addSEs [MPair_parts]
paulson@3432
   433
                       addSDs [A_trusts_YM3, B_trusts_YM4_shrK]
paulson@3432
   434
		       addDs  [Says_imp_sees_Spy' RS parts.Inj,
paulson@3432
   435
			       unique_session_keys]) 1);
paulson@3450
   436
val lemma = normalize_thm [RSspec, RSmp] (result()) |> standard;
paulson@3432
   437
paulson@3432
   438
(*If B receives YM4 then A has used nonce NB (and therefore is alive).
paulson@3450
   439
  Moreover, A associates K with NB (thus is talking about the same run).
paulson@3432
   440
  Other premises guarantee secrecy of K.*)
paulson@3432
   441
goal thy 
paulson@3432
   442
 "!!evs. [| Says A' B {|Crypt (shrK B) {|Nonce NB, Key K, Agent A|},    \
paulson@3432
   443
\                       Crypt K (Nonce NB)|} : set_of_list evs;         \
paulson@3432
   444
\           (ALL NA. Says A Spy {|Nonce NA, Nonce NB, Key K|}           \
paulson@3432
   445
\               ~: set_of_list evs);                                    \
paulson@3432
   446
\           A ~: lost;  B ~: lost;  evs : yahalom lost |]               \
paulson@3432
   447
\        ==> EX X. Says A B {|X, Crypt K (Nonce NB)|} : set_of_list evs";
paulson@3450
   448
by (etac (Says_imp_sees_Spy' RS parts.Inj RS MPair_parts) 1);
paulson@3450
   449
by (dtac B_trusts_YM4_shrK 1);
paulson@3432
   450
by (safe_tac (!claset));
paulson@3450
   451
by (rtac lemma 1);
paulson@3450
   452
by (rtac Spy_not_see_encrypted_key 2);
paulson@3432
   453
by (REPEAT_FIRST assume_tac);
paulson@3432
   454
by (ALLGOALS (blast_tac (!claset addSEs [MPair_parts]
paulson@3450
   455
			         addDs [Says_imp_sees_Spy' RS parts.Inj])));
paulson@3432
   456
qed_spec_mp "YM4_imp_A_Said_YM3";