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