src/HOL/Auth/Yahalom2.ML
author paulson
Mon Jun 09 10:21:38 1997 +0200 (1997-06-09)
changeset 3432 04412cfe6861
parent 3121 cbb6c0c1c58a
child 3450 cd73bc206d87
permissions -rw-r--r--
Strengthened and streamlined the Yahalom proofs
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@2516
   182
(*Base*)
paulson@3121
   183
by (blast_tac (!claset addIs [image_eqI] addss (!simpset)) 1);
paulson@2155
   184
(*YM4, Fake*) 
paulson@2516
   185
by (REPEAT (spy_analz_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@2155
   200
\      EX A' B' NA' NB' X'. ALL A B NA NB X.                        \
paulson@2111
   201
\          Says Server A                                            \
paulson@2284
   202
\           {|NB, Crypt (shrK A) {|Agent B, Key K, NA|}, X|}        \
paulson@2155
   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@2284
   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@2284
   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@2111
   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@3121
   235
\              {|NB, Crypt (shrK A) {|Agent B, Key K, NA|},          \
paulson@3121
   236
\                    Crypt (shrK B) {|NB, Key K, Agent A|}|}         \
paulson@3121
   237
\             : set_of_list evs -->                                  \
paulson@3121
   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@2516
   244
     (!simpset addsimps [not_parts_not_analz, analz_insert_freshK]
paulson@2111
   245
               setloop split_tac [expand_if])));
paulson@2111
   246
(*YM3*)
paulson@3121
   247
by (blast_tac (!claset delrules [impCE]
paulson@3432
   248
                       addSEs sees_Spy_partsEs
paulson@3432
   249
                       addIs [impOfSubs analz_subset_parts]) 2);
paulson@2155
   250
(*OR4, Fake*) 
paulson@2377
   251
by (REPEAT_FIRST spy_analz_tac);
paulson@2155
   252
(*Oops*)
paulson@3121
   253
by (blast_tac (!claset addDs [unique_session_keys]) 1);
paulson@2111
   254
val lemma = result() RS mp RS mp RSN(2,rev_notE);
paulson@2111
   255
paulson@2111
   256
paulson@3432
   257
(*Final version*)
paulson@2111
   258
goal thy 
paulson@2111
   259
 "!!evs. [| Says Server A                                         \
paulson@2516
   260
\              {|NB, Crypt (shrK A) {|Agent B, Key K, NA|},       \
paulson@2516
   261
\                    Crypt (shrK B) {|NB, Key K, Agent A|}|}      \
paulson@2111
   262
\           : set_of_list evs;                                    \
paulson@2516
   263
\           Says A Spy {|NA, NB, Key K|} ~: set_of_list evs;      \
paulson@2155
   264
\           A ~: lost;  B ~: lost;  evs : yahalom lost |]         \
paulson@2516
   265
\        ==> Key K ~: analz (sees lost Spy evs)";
paulson@2111
   266
by (forward_tac [Says_Server_message_form] 1 THEN assume_tac 1);
paulson@3121
   267
by (blast_tac (!claset addSEs [lemma]) 1);
paulson@2111
   268
qed "Spy_not_see_encrypted_key";
paulson@2111
   269
paulson@2111
   270
paulson@3432
   271
(*And other agents don't see the key either.*)
paulson@2111
   272
goal thy 
paulson@2155
   273
 "!!evs. [| C ~: {A,B,Server};                                    \
paulson@2111
   274
\           Says Server A                                         \
paulson@2516
   275
\              {|NB, Crypt (shrK A) {|Agent B, Key K, NA|},       \
paulson@2516
   276
\                    Crypt (shrK B) {|NB, Key K, Agent A|}|}      \
paulson@2111
   277
\           : set_of_list evs;                                    \
paulson@2516
   278
\           Says A Spy {|NA, NB, Key K|} ~: set_of_list evs;      \
paulson@2155
   279
\           A ~: lost;  B ~: lost;  evs : yahalom lost |]         \
paulson@2516
   280
\        ==> Key K ~: analz (sees lost C evs)";
paulson@2111
   281
by (rtac (subset_insertI RS sees_mono RS analz_mono RS contra_subsetD) 1);
paulson@2111
   282
by (rtac (sees_lost_agent_subset_sees_Spy RS analz_mono RS contra_subsetD) 1);
paulson@2111
   283
by (FIRSTGOAL (rtac Spy_not_see_encrypted_key));
paulson@3121
   284
by (REPEAT_FIRST (blast_tac (!claset addIs [yahalom_mono RS subsetD])));
paulson@2111
   285
qed "Agent_not_see_encrypted_key";
paulson@2111
   286
paulson@2111
   287
paulson@2155
   288
(*** Security Guarantees for A and B ***)
paulson@2155
   289
paulson@3432
   290
(*If the encrypted message appears then it originated with the Server.
paulson@3432
   291
  May now apply Spy_not_see_encrypted_key, subject to its conditions.*)
paulson@2155
   292
goal thy
paulson@2284
   293
 "!!evs. [| Crypt (shrK A) {|Agent B, Key K, NA|}                \
paulson@2155
   294
\            : parts (sees lost Spy evs);                              \
paulson@2155
   295
\           A ~: lost;  evs : yahalom lost |]                          \
paulson@2155
   296
\         ==> EX NB. Says Server A                                     \
paulson@2284
   297
\                      {|NB, Crypt (shrK A) {|Agent B, Key K, NA|},    \
paulson@2284
   298
\                            Crypt (shrK B) {|NB, Key K, Agent A|}|}   \
paulson@2155
   299
\                    : set_of_list evs";
paulson@2155
   300
by (etac rev_mp 1);
paulson@3121
   301
by parts_induct_tac;
paulson@3121
   302
by (Fake_parts_insert_tac 1);
paulson@3121
   303
by (Blast_tac 1);
paulson@2323
   304
qed "A_trusts_YM3";
paulson@2155
   305
paulson@2111
   306
paulson@2111
   307
(*B knows, by the first part of A's message, that the Server distributed 
paulson@2155
   308
  the key for A and B. *)
paulson@2111
   309
goal thy 
paulson@2284
   310
 "!!evs. [| Crypt (shrK B) {|Nonce NB, Key K, Agent A|}              \
paulson@2155
   311
\            : parts (sees lost Spy evs);                            \
paulson@2155
   312
\           B ~: lost;  evs : yahalom lost |]                        \
paulson@2111
   313
\        ==> EX NA. Says Server A                                    \
paulson@2155
   314
\                    {|Nonce NB,                                     \
paulson@2284
   315
\                      Crypt (shrK A) {|Agent B, Key K, Nonce NA|},  \
paulson@2284
   316
\                      Crypt (shrK B) {|Nonce NB, Key K, Agent A|}|} \
paulson@2111
   317
\                       : set_of_list evs";
paulson@2111
   318
by (etac rev_mp 1);
paulson@3121
   319
by parts_induct_tac;
paulson@3121
   320
by (Fake_parts_insert_tac 1);
paulson@2111
   321
(*YM3*)
paulson@3121
   322
by (Blast_tac 1);
paulson@2111
   323
qed "B_trusts_YM4_shrK";
paulson@2111
   324
paulson@2111
   325
(*With this variant we don't bother to use the 2nd part of YM4 at all, since
paulson@3432
   326
  Nonce NB is available in the first part.  However, the 2nd part does assure B
paulson@2111
   327
  of A's existence.*)
paulson@2111
   328
paulson@2155
   329
(*What can B deduce from receipt of YM4?  Stronger and simpler than Yahalom
paulson@2155
   330
  because we do not have to show that NB is secret. *)
paulson@2111
   331
goal thy 
paulson@2284
   332
 "!!evs. [| Says A' B {|Crypt (shrK B) {|Nonce NB, Key K, Agent A|},    \
paulson@2284
   333
\                       Crypt K (Nonce NB)|} : set_of_list evs;         \
paulson@2111
   334
\           A ~: lost;  B ~: lost;  evs : yahalom lost |]               \
paulson@2111
   335
\        ==> EX NA. Says Server A                                       \
paulson@2155
   336
\                    {|Nonce NB,                                        \
paulson@2284
   337
\                      Crypt (shrK A) {|Agent B, Key K, Nonce NA|},     \
paulson@2284
   338
\                      Crypt (shrK B) {|Nonce NB, Key K, Agent A|}|}    \
paulson@2111
   339
\                   : set_of_list evs";
paulson@3432
   340
by (etac (Says_imp_sees_Spy' RS parts.Inj RS MPair_parts) 1);
paulson@3121
   341
by (blast_tac (!claset addSDs [B_trusts_YM4_shrK]) 1);
paulson@2323
   342
qed "B_trusts_YM4";
paulson@3432
   343
paulson@3432
   344
paulson@3432
   345
paulson@3432
   346
(*** Authenticating B to A ***)
paulson@3432
   347
paulson@3432
   348
(*The encryption in message YM2 tells us it cannot be faked.*)
paulson@3432
   349
goal thy 
paulson@3432
   350
 "!!evs. evs : yahalom lost                                            \
paulson@3432
   351
\  ==> Crypt (shrK B) {|Agent A, Nonce NA|} : parts (sees lost Spy evs) -->  \
paulson@3432
   352
\      B ~: lost --> \
paulson@3432
   353
\      (EX NB. Says B Server {|Agent B, Nonce NB,                      \
paulson@3432
   354
\                              Crypt (shrK B) {|Agent A, Nonce NA|}|}  \
paulson@3432
   355
\         : set_of_list evs)";
paulson@3432
   356
by parts_induct_tac;
paulson@3432
   357
by (Fake_parts_insert_tac 1);
paulson@3432
   358
(*YM2*)
paulson@3432
   359
by (Blast_tac 1);
paulson@3432
   360
bind_thm ("B_Said_YM2", result() RSN (2, rev_mp) RS mp);
paulson@3432
   361
paulson@3432
   362
(*If the server sends YM3 then B sent YM2, perhaps with a different NB*)
paulson@3432
   363
goal thy 
paulson@3432
   364
 "!!evs. evs : yahalom lost                                       \
paulson@3432
   365
\  ==> Says Server A {|nb, Crypt (shrK A) {|Agent B, Key K, Nonce NA|}, X|} \
paulson@3432
   366
\         : set_of_list evs -->                                          \
paulson@3432
   367
\      B ~: lost -->                                                     \
paulson@3432
   368
\      (EX nb'. Says B Server {|Agent B, nb',                            \
paulson@3432
   369
\                               Crypt (shrK B) {|Agent A, Nonce NA|}|}   \
paulson@3432
   370
\                 : set_of_list evs)";
paulson@3432
   371
by (etac yahalom.induct 1);
paulson@3432
   372
by (ALLGOALS Asm_simp_tac);
paulson@3432
   373
(*YM3*)
paulson@3432
   374
by (blast_tac (!claset addSDs [B_Said_YM2]
paulson@3432
   375
		       addSEs [MPair_parts]
paulson@3432
   376
		       addDs [Says_imp_sees_Spy' RS parts.Inj]) 3);
paulson@3432
   377
(*Fake, YM2*)
paulson@3432
   378
by (ALLGOALS Blast_tac);
paulson@3432
   379
bind_thm ("Says_Server_imp_B_Said_YM2", result() RSN (2, rev_mp) RS mp);
paulson@3432
   380
paulson@3432
   381
(*If A receives YM3 then B has used nonce NA (and therefore is alive)*)
paulson@3432
   382
goal thy
paulson@3432
   383
 "!!evs. [| Says S A {|Nonce NB, Crypt (shrK A) {|Agent B, Key K, Nonce NA|}, \
paulson@3432
   384
\                                X|}  : set_of_list evs;               \
paulson@3432
   385
\           A ~: lost;  B ~: lost;  evs : yahalom lost |]              \
paulson@3432
   386
\         ==> EX nb. Says B Server                                     \
paulson@3432
   387
\                     {|Agent B, nb, Crypt (shrK B) {|Agent A, Nonce NA|}|}   \
paulson@3432
   388
\                    : set_of_list evs";
paulson@3432
   389
by (blast_tac (!claset addSDs [A_trusts_YM3, Says_Server_imp_B_Said_YM2]
paulson@3432
   390
		       addEs sees_Spy_partsEs) 1);
paulson@3432
   391
qed "YM3_auth_B_to_A";
paulson@3432
   392
paulson@3432
   393
paulson@3432
   394
(*Induction for theorems of the form X ~: analz (sees lost Spy evs) --> ...
paulson@3432
   395
  It simplifies the proof by discarding needless information about
paulson@3432
   396
	analz (insert X (sees lost Spy evs)) 
paulson@3432
   397
*)
paulson@3432
   398
val analz_mono_parts_induct_tac = 
paulson@3432
   399
    etac yahalom.induct 1 
paulson@3432
   400
    THEN 
paulson@3432
   401
    REPEAT_FIRST  
paulson@3432
   402
      (rtac impI THEN' 
paulson@3432
   403
       dtac (sees_subset_sees_Says RS analz_mono RS contra_subsetD) THEN'
paulson@3432
   404
       mp_tac)  
paulson@3432
   405
    THEN  parts_sees_tac;
paulson@3432
   406
paulson@3432
   407
fun lost_tac s =
paulson@3432
   408
    case_tac ("(" ^ s ^ ") : lost") THEN'
paulson@3432
   409
    SELECT_GOAL 
paulson@3432
   410
      (REPEAT_DETERM (dtac (Says_imp_sees_Spy' RS analz.Inj) 1) THEN
paulson@3432
   411
       REPEAT_DETERM (etac MPair_analz 1) THEN
paulson@3432
   412
       THEN_BEST_FIRST 
paulson@3432
   413
         (dres_inst_tac [("A", s)] Crypt_Spy_analz_lost 1 THEN assume_tac 1)
paulson@3432
   414
         (has_fewer_prems 1, size_of_thm)
paulson@3432
   415
         (Step_tac 1));
paulson@3432
   416
paulson@3432
   417
paulson@3432
   418
(*Assuming the session key is secure, if it is used to encrypt NB then
paulson@3432
   419
  A has said NB.  We can't be sure about the rest of A's message, but only
paulson@3432
   420
  NB matters for freshness.*)  
paulson@3432
   421
goal thy 
paulson@3432
   422
 "!!evs. evs : yahalom lost                                             \
paulson@3432
   423
\        ==> Key K ~: analz (sees lost Spy evs) -->                     \
paulson@3432
   424
\            Crypt K (Nonce NB) : parts (sees lost Spy evs) -->         \
paulson@3432
   425
\            Crypt (shrK B) {|Nonce NB, Key K, Agent A|}                \
paulson@3432
   426
\              : parts (sees lost Spy evs) -->                          \
paulson@3432
   427
\             B ~: lost -->                                             \
paulson@3432
   428
\             (EX X. Says A B {|X, Crypt K (Nonce NB)|} : set_of_list evs)";
paulson@3432
   429
by analz_mono_parts_induct_tac;
paulson@3432
   430
(*Fake*)
paulson@3432
   431
by (Fake_parts_insert_tac 1);
paulson@3432
   432
(*YM3: by new_keys_not_used we note that Crypt K (Nonce NB) could not exist*)
paulson@3432
   433
by (fast_tac (!claset addSDs [Crypt_imp_invKey_keysFor] addss (!simpset)) 1); 
paulson@3432
   434
(*YM4*)
paulson@3432
   435
by(Step_tac 1);
paulson@3432
   436
by (REPEAT (Blast_tac 2));
paulson@3432
   437
by (lost_tac "Aa" 1);
paulson@3432
   438
by (blast_tac (!claset addSEs [MPair_parts]
paulson@3432
   439
                       addSDs [A_trusts_YM3, B_trusts_YM4_shrK]
paulson@3432
   440
		       addDs  [Says_imp_sees_Spy' RS parts.Inj,
paulson@3432
   441
			       unique_session_keys]) 1);
paulson@3432
   442
val lemma = normalize_thm [RSspec, RSmp] (result());
paulson@3432
   443
paulson@3432
   444
(*If B receives YM4 then A has used nonce NB (and therefore is alive).
paulson@3432
   445
  Other premises guarantee secrecy of K.*)
paulson@3432
   446
goal thy 
paulson@3432
   447
 "!!evs. [| Says A' B {|Crypt (shrK B) {|Nonce NB, Key K, Agent A|},    \
paulson@3432
   448
\                       Crypt K (Nonce NB)|} : set_of_list evs;         \
paulson@3432
   449
\           (ALL NA. Says A Spy {|Nonce NA, Nonce NB, Key K|}           \
paulson@3432
   450
\               ~: set_of_list evs);                                    \
paulson@3432
   451
\           A ~: lost;  B ~: lost;  evs : yahalom lost |]               \
paulson@3432
   452
\        ==> EX X. Says A B {|X, Crypt K (Nonce NB)|} : set_of_list evs";
paulson@3432
   453
be (Says_imp_sees_Spy' RS parts.Inj RS MPair_parts) 1;
paulson@3432
   454
bd (B_trusts_YM4_shrK) 1;
paulson@3432
   455
by (safe_tac (!claset));
paulson@3432
   456
br lemma 1;
paulson@3432
   457
br Spy_not_see_encrypted_key 2;
paulson@3432
   458
by (REPEAT_FIRST assume_tac);
paulson@3432
   459
by (ALLGOALS (blast_tac (!claset addSEs [MPair_parts]
paulson@3432
   460
			 addDs [Says_imp_sees_Spy' RS parts.Inj])));
paulson@3432
   461
qed_spec_mp "YM4_imp_A_Said_YM3";