src/HOL/Auth/Yahalom2.ML
author paulson
Mon Jul 14 12:47:21 1997 +0200 (1997-07-14)
changeset 3519 ab0a9fbed4c0
parent 3516 470626799511
child 3674 65ec38fbb265
permissions -rw-r--r--
Changing "lost" from a parameter of protocol definitions to a constant.

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