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