src/HOL/Auth/Yahalom.ML
author paulson
Fri Jul 04 17:36:41 1997 +0200 (1997-07-04)
changeset 3501 4ab477ffb4c6
parent 3466 30791e5a69c4
child 3516 470626799511
permissions -rw-r--r--
Changed some variables of type msg to lower case (e.g. from NB to nb
paulson@1995
     1
(*  Title:      HOL/Auth/Yahalom
paulson@1985
     2
    ID:         $Id$
paulson@1985
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@1985
     4
    Copyright   1996  University of Cambridge
paulson@1985
     5
paulson@3432
     6
Inductive relation "yahalom" for the Yahalom protocol.
paulson@1985
     7
paulson@1985
     8
From page 257 of
paulson@1985
     9
  Burrows, Abadi and Needham.  A Logic of Authentication.
paulson@1985
    10
  Proc. Royal Soc. 426 (1989)
paulson@1985
    11
*)
paulson@1985
    12
paulson@1995
    13
open Yahalom;
paulson@1985
    14
paulson@1985
    15
proof_timing:=true;
paulson@1985
    16
HOL_quantifiers := false;
paulson@2516
    17
Pretty.setdepth 25;
paulson@1985
    18
paulson@3121
    19
(*Replacing the variable by a constant improves speed*)
paulson@3121
    20
val Says_imp_sees_Spy' = read_instantiate [("lost","lost")] Says_imp_sees_Spy;
oheimb@2637
    21
paulson@1995
    22
paulson@2322
    23
(*A "possibility property": there are traces that reach the end*)
paulson@1995
    24
goal thy 
paulson@1995
    25
 "!!A B. [| A ~= B; A ~= Server; B ~= Server |]   \
paulson@3466
    26
\        ==> EX X NB K. EX evs: yahalom lost.     \
nipkow@3465
    27
\               Says A B {|X, Crypt K (Nonce NB)|} : set evs";
paulson@1995
    28
by (REPEAT (resolve_tac [exI,bexI] 1));
paulson@2516
    29
by (rtac (yahalom.Nil RS yahalom.YM1 RS yahalom.YM2 RS yahalom.YM3 RS 
paulson@2516
    30
          yahalom.YM4) 2);
paulson@2516
    31
by possibility_tac;
paulson@2013
    32
result();
paulson@1995
    33
paulson@1995
    34
paulson@1985
    35
(**** Inductive proofs about yahalom ****)
paulson@1985
    36
paulson@2110
    37
(*Monotonicity*)
paulson@2045
    38
goal thy "!!evs. lost' <= lost ==> yahalom lost' <= yahalom lost";
paulson@2045
    39
by (rtac subsetI 1);
paulson@2045
    40
by (etac yahalom.induct 1);
paulson@2045
    41
by (REPEAT_FIRST
paulson@3466
    42
    (blast_tac (!claset addIs (impOfSubs(sees_mono RS analz_mono RS synth_mono)
paulson@2045
    43
                              :: yahalom.intrs))));
paulson@2045
    44
qed "yahalom_mono";
paulson@2045
    45
paulson@1985
    46
paulson@1985
    47
(*Nobody sends themselves messages*)
nipkow@3465
    48
goal thy "!!evs. evs: yahalom lost ==> ALL A X. Says A A X ~: set evs";
paulson@2032
    49
by (etac yahalom.induct 1);
paulson@1985
    50
by (Auto_tac());
paulson@1985
    51
qed_spec_mp "not_Says_to_self";
paulson@1985
    52
Addsimps [not_Says_to_self];
paulson@1985
    53
AddSEs   [not_Says_to_self RSN (2, rev_notE)];
paulson@1985
    54
paulson@1985
    55
paulson@1985
    56
(** For reasoning about the encrypted portion of messages **)
paulson@1985
    57
paulson@1995
    58
(*Lets us treat YM4 using a similar argument as for the Fake case.*)
nipkow@3465
    59
goal thy "!!evs. Says S A {|Crypt (shrK A) Y, X|} : set evs ==> \
paulson@2032
    60
\                X : analz (sees lost Spy evs)";
paulson@3121
    61
by (blast_tac (!claset addSDs [Says_imp_sees_Spy' RS analz.Inj]) 1);
paulson@2032
    62
qed "YM4_analz_sees_Spy";
paulson@1985
    63
paulson@2110
    64
bind_thm ("YM4_parts_sees_Spy",
paulson@2110
    65
          YM4_analz_sees_Spy RS (impOfSubs analz_subset_parts));
paulson@2110
    66
paulson@2133
    67
(*Relates to both YM4 and Oops*)
paulson@3466
    68
goal thy "!!evs. Says S A {|Crypt (shrK A) {|B,K,NA,NB|}, X|} : set evs ==> \
paulson@2032
    69
\                K : parts (sees lost Spy evs)";
paulson@3121
    70
by (blast_tac (!claset addSEs partsEs
paulson@3121
    71
                      addSDs [Says_imp_sees_Spy' RS parts.Inj]) 1);
paulson@2110
    72
qed "YM4_Key_parts_sees_Spy";
paulson@2110
    73
paulson@3121
    74
(*For proving the easier theorems about X ~: parts (sees lost Spy evs).
paulson@3121
    75
  We instantiate the variable to "lost" since leaving it as a Var would
paulson@3121
    76
  interfere with simplification.*)
paulson@3121
    77
val parts_sees_tac = 
paulson@3121
    78
    forw_inst_tac [("lost","lost")] YM4_parts_sees_Spy 6     THEN
paulson@3121
    79
    forw_inst_tac [("lost","lost")] YM4_Key_parts_sees_Spy 7 THEN
paulson@3121
    80
    prove_simple_subgoals_tac  1;
paulson@1985
    81
paulson@3121
    82
val parts_induct_tac = 
paulson@3121
    83
    etac yahalom.induct 1 THEN parts_sees_tac;
paulson@1985
    84
paulson@1985
    85
paulson@2032
    86
(** Theorems of the form X ~: parts (sees lost Spy evs) imply that NOBODY
paulson@2013
    87
    sends messages containing X! **)
paulson@1985
    88
paulson@2133
    89
(*Spy never sees another agent's shared key! (unless it's lost at start)*)
paulson@1985
    90
goal thy 
paulson@2133
    91
 "!!evs. evs : yahalom lost \
paulson@2133
    92
\        ==> (Key (shrK A) : parts (sees lost Spy evs)) = (A : lost)";
paulson@3121
    93
by parts_induct_tac;
paulson@3121
    94
by (Fake_parts_insert_tac 1);
paulson@3121
    95
by (Blast_tac 1);
paulson@2133
    96
qed "Spy_see_shrK";
paulson@2133
    97
Addsimps [Spy_see_shrK];
paulson@1985
    98
paulson@2133
    99
goal thy 
paulson@2133
   100
 "!!evs. evs : yahalom lost \
paulson@2133
   101
\        ==> (Key (shrK A) : analz (sees lost Spy evs)) = (A : lost)";
paulson@2133
   102
by (auto_tac(!claset addDs [impOfSubs analz_subset_parts], !simpset));
paulson@2133
   103
qed "Spy_analz_shrK";
paulson@2133
   104
Addsimps [Spy_analz_shrK];
paulson@1985
   105
paulson@2133
   106
goal thy  "!!A. [| Key (shrK A) : parts (sees lost Spy evs);       \
paulson@2133
   107
\                  evs : yahalom lost |] ==> A:lost";
paulson@3121
   108
by (blast_tac (!claset addDs [Spy_see_shrK]) 1);
paulson@2133
   109
qed "Spy_see_shrK_D";
paulson@1985
   110
paulson@2133
   111
bind_thm ("Spy_analz_shrK_D", analz_subset_parts RS subsetD RS Spy_see_shrK_D);
paulson@2133
   112
AddSDs [Spy_see_shrK_D, Spy_analz_shrK_D];
paulson@1985
   113
paulson@1985
   114
paulson@3432
   115
(*Nobody can have used non-existent keys!  Needed to apply analz_insert_Key*)
paulson@2516
   116
goal thy "!!evs. evs : yahalom lost ==>          \
paulson@2516
   117
\         Key K ~: used evs --> K ~: keysFor (parts (sees lost Spy evs))";
paulson@3121
   118
by parts_induct_tac;
paulson@2516
   119
(*YM4: Key K is not fresh!*)
paulson@3121
   120
by (blast_tac (!claset addSEs sees_Spy_partsEs) 3);
paulson@2516
   121
(*YM3*)
paulson@3121
   122
by (Blast_tac 2);
paulson@2516
   123
(*Fake*)
paulson@2516
   124
by (best_tac
paulson@2516
   125
      (!claset addIs [impOfSubs analz_subset_parts]
paulson@2516
   126
               addDs [impOfSubs (analz_subset_parts RS keysFor_mono),
paulson@2516
   127
                      impOfSubs (parts_insert_subset_Un RS keysFor_mono)]
paulson@2516
   128
               addss (!simpset)) 1);
paulson@2160
   129
qed_spec_mp "new_keys_not_used";
paulson@1985
   130
paulson@1985
   131
bind_thm ("new_keys_not_analzd",
paulson@2032
   132
          [analz_subset_parts RS keysFor_mono,
paulson@2032
   133
           new_keys_not_used] MRS contra_subsetD);
paulson@1985
   134
paulson@1985
   135
Addsimps [new_keys_not_used, new_keys_not_analzd];
paulson@1985
   136
paulson@1985
   137
paulson@2133
   138
(*Describes the form of K when the Server sends this message.  Useful for
paulson@2133
   139
  Oops as well as main secrecy property.*)
paulson@2110
   140
goal thy 
paulson@3501
   141
 "!!evs. [| Says Server A {|Crypt (shrK A) {|Agent B, Key K, na, nb|}, X|} \
paulson@3466
   142
\             : set evs;                                                   \
paulson@2516
   143
\           evs : yahalom lost |]                                          \
paulson@2516
   144
\        ==> K ~: range shrK";
paulson@2133
   145
by (etac rev_mp 1);
paulson@2133
   146
by (etac yahalom.induct 1);
paulson@3121
   147
by (ALLGOALS Asm_simp_tac);
paulson@3121
   148
by (Blast_tac 1);
paulson@2133
   149
qed "Says_Server_message_form";
paulson@2110
   150
paulson@2110
   151
paulson@2110
   152
(*For proofs involving analz.  We again instantiate the variable to "lost".*)
paulson@3121
   153
val analz_sees_tac = 
paulson@2133
   154
    forw_inst_tac [("lost","lost")] YM4_analz_sees_Spy 6 THEN
paulson@2133
   155
    forw_inst_tac [("lost","lost")] Says_Server_message_form 7 THEN
paulson@2516
   156
    assume_tac 7 THEN REPEAT ((etac exE ORELSE' hyp_subst_tac) 7);
paulson@1985
   157
paulson@1985
   158
paulson@1985
   159
(****
paulson@1985
   160
 The following is to prove theorems of the form
paulson@1985
   161
paulson@2516
   162
  Key K : analz (insert (Key KAB) (sees lost Spy evs)) ==>
paulson@2451
   163
  Key K : analz (sees lost Spy evs)
paulson@1985
   164
paulson@1985
   165
 A more general formula must be proved inductively.
paulson@1985
   166
****)
paulson@1985
   167
paulson@1985
   168
(** Session keys are not used to encrypt other session keys **)
paulson@1985
   169
paulson@1985
   170
goal thy  
paulson@3466
   171
 "!!evs. evs : yahalom lost ==>                                 \
paulson@3466
   172
\  ALL K KK. KK <= Compl (range shrK) -->                       \
paulson@2516
   173
\            (Key K : analz (Key``KK Un (sees lost Spy evs))) = \
paulson@2516
   174
\            (K : KK | Key K : analz (sees lost Spy evs))";
paulson@2032
   175
by (etac yahalom.induct 1);
paulson@3121
   176
by analz_sees_tac;
paulson@2516
   177
by (REPEAT_FIRST (resolve_tac [allI, impI]));
paulson@2516
   178
by (REPEAT_FIRST (rtac analz_image_freshK_lemma ));
paulson@2516
   179
by (ALLGOALS (asm_simp_tac analz_image_freshK_ss));
paulson@3450
   180
(*Fake*) 
paulson@3450
   181
by (spy_analz_tac 2);
paulson@2516
   182
(*Base*)
paulson@3121
   183
by (Blast_tac 1);
paulson@2516
   184
qed_spec_mp "analz_image_freshK";
paulson@1985
   185
paulson@1985
   186
goal thy
paulson@2516
   187
 "!!evs. [| evs : yahalom lost;  KAB ~: range shrK |] ==>             \
paulson@3466
   188
\        Key K : analz (insert (Key KAB) (sees lost Spy evs)) =       \
paulson@2516
   189
\        (K = KAB | Key K : analz (sees lost Spy evs))";
paulson@2516
   190
by (asm_simp_tac (analz_image_freshK_ss addsimps [analz_image_freshK]) 1);
paulson@2516
   191
qed "analz_insert_freshK";
paulson@1985
   192
paulson@1985
   193
paulson@2110
   194
(*** The Key K uniquely identifies the Server's  message. **)
paulson@2110
   195
paulson@2110
   196
goal thy 
paulson@2110
   197
 "!!evs. evs : yahalom lost ==>                                     \
paulson@3466
   198
\      EX A' B' na' nb' X'. ALL A B na nb X.                        \
paulson@2110
   199
\          Says Server A                                            \
paulson@3450
   200
\           {|Crypt (shrK A) {|Agent B, Key K, na, nb|}, X|}        \
nipkow@3465
   201
\          : set evs --> A=A' & B=B' & na=na' & nb=nb' & X=X'";
paulson@2110
   202
by (etac yahalom.induct 1);
paulson@2110
   203
by (ALLGOALS (asm_simp_tac (!simpset addsimps [all_conj_distrib])));
paulson@2110
   204
by (Step_tac 1);
paulson@2133
   205
by (ex_strip_tac 2);
paulson@3121
   206
by (Blast_tac 2);
paulson@2110
   207
(*Remaining case: YM3*)
paulson@2110
   208
by (expand_case_tac "K = ?y" 1);
paulson@2110
   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@3121
   212
                      delrules [conjI]    (*no split-up to 4 subgoals*)) 1);
paulson@2110
   213
val lemma = result();
paulson@2110
   214
paulson@2110
   215
goal thy 
paulson@2110
   216
"!!evs. [| Says Server A                                            \
paulson@3450
   217
\           {|Crypt (shrK A) {|Agent B, Key K, na, nb|}, X|}        \
paulson@3466
   218
\           : set evs;                                              \
paulson@2110
   219
\          Says Server A'                                           \
paulson@3450
   220
\           {|Crypt (shrK A') {|Agent B', Key K, na', nb'|}, X'|}   \
paulson@3466
   221
\           : set evs;                                              \
paulson@2110
   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@2110
   225
qed "unique_session_keys";
paulson@2110
   226
paulson@2110
   227
paulson@2110
   228
(** Crucial secrecy property: Spy does not see the keys sent in msg YM3 **)
paulson@2013
   229
paulson@2013
   230
goal thy 
paulson@2133
   231
 "!!evs. [| A ~: lost;  B ~: lost;  evs : yahalom lost |]         \
paulson@2051
   232
\        ==> Says Server A                                        \
paulson@3450
   233
\              {|Crypt (shrK A) {|Agent B, Key K, na, nb|},       \
paulson@2284
   234
\                Crypt (shrK B) {|Agent A, Key K|}|}              \
paulson@3466
   235
\             : set evs -->                                       \
paulson@3466
   236
\            Says A Spy {|na, nb, Key K|} ~: set evs -->          \
paulson@2051
   237
\            Key K ~: analz (sees lost Spy evs)";
paulson@2032
   238
by (etac yahalom.induct 1);
paulson@3121
   239
by analz_sees_tac;
paulson@2013
   240
by (ALLGOALS
paulson@2013
   241
    (asm_simp_tac 
paulson@3450
   242
     (!simpset addsimps [analz_insert_eq, not_parts_not_analz, 
paulson@3450
   243
			 analz_insert_freshK]
paulson@2013
   244
               setloop split_tac [expand_if])));
paulson@3450
   245
(*Oops*)
paulson@3450
   246
by (blast_tac (!claset addDs [unique_session_keys]) 3);
paulson@2013
   247
(*YM3*)
paulson@3121
   248
by (blast_tac (!claset delrules [impCE]
paulson@3121
   249
                       addSEs sees_Spy_partsEs
paulson@3121
   250
                       addIs [impOfSubs analz_subset_parts]) 2);
paulson@3450
   251
(*Fake*) 
paulson@3450
   252
by (spy_analz_tac 1);
paulson@2110
   253
val lemma = result() RS mp RS mp RSN(2,rev_notE);
paulson@2013
   254
paulson@2013
   255
paulson@3432
   256
(*Final version*)
paulson@1985
   257
goal thy 
paulson@2516
   258
 "!!evs. [| Says Server A                                         \
paulson@3450
   259
\              {|Crypt (shrK A) {|Agent B, Key K, na, nb|},       \
paulson@2516
   260
\                Crypt (shrK B) {|Agent A, Key K|}|}              \
paulson@3466
   261
\             : set evs;                                          \
paulson@3466
   262
\           Says A Spy {|na, nb, Key K|} ~: set evs;              \
paulson@2516
   263
\           A ~: lost;  B ~: lost;  evs : yahalom lost |]         \
paulson@2516
   264
\        ==> Key K ~: analz (sees lost Spy evs)";
paulson@2013
   265
by (forward_tac [Says_Server_message_form] 1 THEN assume_tac 1);
paulson@3121
   266
by (blast_tac (!claset addSEs [lemma]) 1);
paulson@2032
   267
qed "Spy_not_see_encrypted_key";
paulson@2001
   268
paulson@2001
   269
paulson@3432
   270
(*And other agents don't see the key either.*)
paulson@2045
   271
goal thy 
paulson@2516
   272
 "!!evs. [| C ~: {A,B,Server};                                    \
paulson@2516
   273
\           Says Server A                                         \
paulson@3450
   274
\              {|Crypt (shrK A) {|Agent B, Key K, na, nb|},       \
paulson@2516
   275
\                Crypt (shrK B) {|Agent A, Key K|}|}              \
paulson@3466
   276
\             : set evs;                                          \
paulson@3466
   277
\           Says A Spy {|na, nb, Key K|} ~: set evs;              \
paulson@2516
   278
\           A ~: lost;  B ~: lost;  evs : yahalom lost |]         \
paulson@2516
   279
\        ==> Key K ~: analz (sees lost C evs)";
paulson@2045
   280
by (rtac (subset_insertI RS sees_mono RS analz_mono RS contra_subsetD) 1);
paulson@2045
   281
by (rtac (sees_lost_agent_subset_sees_Spy RS analz_mono RS contra_subsetD) 1);
paulson@2045
   282
by (FIRSTGOAL (rtac Spy_not_see_encrypted_key));
paulson@3121
   283
by (REPEAT_FIRST (blast_tac (!claset addIs [yahalom_mono RS subsetD])));
paulson@2045
   284
qed "Agent_not_see_encrypted_key";
paulson@2045
   285
paulson@2045
   286
paulson@3444
   287
(*Induction for theorems of the form X ~: analz (sees lost Spy evs) --> ...
paulson@3444
   288
  It simplifies the proof by discarding needless information about
paulson@3444
   289
	analz (insert X (sees lost Spy evs)) 
paulson@3444
   290
*)
paulson@3444
   291
val analz_mono_parts_induct_tac = 
paulson@3444
   292
    etac yahalom.induct 1 
paulson@3444
   293
    THEN 
paulson@3444
   294
    REPEAT_FIRST  
paulson@3444
   295
      (rtac impI THEN' 
paulson@3444
   296
       dtac (sees_subset_sees_Says RS analz_mono RS contra_subsetD) THEN'
paulson@3444
   297
       mp_tac)  
paulson@3444
   298
    THEN  parts_sees_tac;
paulson@3444
   299
paulson@3444
   300
paulson@3444
   301
(** Security Guarantee for A upon receiving YM3 **)
paulson@3444
   302
paulson@3444
   303
(*If the encrypted message appears then it originated with the Server*)
paulson@3444
   304
goal thy
paulson@3450
   305
 "!!evs. [| Crypt (shrK A) {|Agent B, Key K, na, nb|}                  \
paulson@3444
   306
\            : parts (sees lost Spy evs);                              \
paulson@3444
   307
\           A ~: lost;  evs : yahalom lost |]                          \
paulson@3444
   308
\         ==> Says Server A                                            \
paulson@3450
   309
\              {|Crypt (shrK A) {|Agent B, Key K, na, nb|},            \
paulson@3444
   310
\                Crypt (shrK B) {|Agent A, Key K|}|}                   \
nipkow@3465
   311
\             : set evs";
paulson@3444
   312
by (etac rev_mp 1);
paulson@3444
   313
by parts_induct_tac;
paulson@3444
   314
by (Fake_parts_insert_tac 1);
paulson@3444
   315
qed "A_trusts_YM3";
paulson@3444
   316
paulson@3444
   317
paulson@3444
   318
(** Security Guarantees for B upon receiving YM4 **)
paulson@2013
   319
paulson@2110
   320
(*B knows, by the first part of A's message, that the Server distributed 
paulson@2110
   321
  the key for A and B.  But this part says nothing about nonces.*)
paulson@2001
   322
goal thy 
paulson@2284
   323
 "!!evs. [| Crypt (shrK B) {|Agent A, Key K|} : parts (sees lost Spy evs); \
paulson@2051
   324
\           B ~: lost;  evs : yahalom lost |]                           \
paulson@2001
   325
\        ==> EX NA NB. Says Server A                                    \
paulson@2451
   326
\                        {|Crypt (shrK A) {|Agent B, Key K,             \
paulson@2516
   327
\                                           Nonce NA, Nonce NB|},       \
paulson@2284
   328
\                          Crypt (shrK B) {|Agent A, Key K|}|}          \
nipkow@3465
   329
\                       : set evs";
paulson@2032
   330
by (etac rev_mp 1);
paulson@3121
   331
by parts_induct_tac;
paulson@3121
   332
by (Fake_parts_insert_tac 1);
paulson@2110
   333
(*YM3*)
paulson@3121
   334
by (Blast_tac 1);
paulson@2110
   335
qed "B_trusts_YM4_shrK";
paulson@2110
   336
paulson@3444
   337
(*B knows, by the second part of A's message, that the Server distributed 
paulson@3444
   338
  the key quoting nonce NB.  This part says nothing about agent names. 
paulson@3444
   339
  Secrecy of NB is crucial.*)
paulson@3444
   340
goal thy 
paulson@3444
   341
 "!!evs. evs : yahalom lost                                             \
paulson@3444
   342
\        ==> Nonce NB ~: analz (sees lost Spy evs) -->                  \
paulson@3444
   343
\            Crypt K (Nonce NB) : parts (sees lost Spy evs) -->         \
paulson@3444
   344
\            (EX A B NA. Says Server A                                  \
paulson@3444
   345
\                        {|Crypt (shrK A) {|Agent B, Key K,             \
paulson@3444
   346
\                                  Nonce NA, Nonce NB|},                \
paulson@3444
   347
\                          Crypt (shrK B) {|Agent A, Key K|}|}          \
nipkow@3465
   348
\                       : set evs)";
paulson@3444
   349
by analz_mono_parts_induct_tac;
paulson@3444
   350
(*YM3 & Fake*)
paulson@3444
   351
by (Blast_tac 2);
paulson@3444
   352
by (Fake_parts_insert_tac 1);
paulson@3444
   353
(*YM4*)
paulson@3444
   354
by (Step_tac 1);
paulson@3444
   355
(*A is uncompromised because NB is secure*)
paulson@3444
   356
by (not_lost_tac "A" 1);
paulson@3444
   357
(*A's certificate guarantees the existence of the Server message*)
paulson@3444
   358
by (blast_tac (!claset addDs [Says_imp_sees_Spy' RS parts.Inj RS parts.Fst RS
paulson@3444
   359
			      A_trusts_YM3]) 1);
paulson@3464
   360
bind_thm ("B_trusts_YM4_newK", result() RS mp RSN (2, rev_mp));
paulson@2133
   361
paulson@3444
   362
paulson@3444
   363
(**** Towards proving secrecy of Nonce NB ****)
paulson@3444
   364
paulson@3444
   365
(** Lemmas about the predicate KeyWithNonce **)
paulson@3444
   366
paulson@3444
   367
goalw thy [KeyWithNonce_def]
paulson@3444
   368
 "!!evs. Says Server A                                              \
paulson@3444
   369
\            {|Crypt (shrK A) {|Agent B, Key K, na, Nonce NB|}, X|} \
nipkow@3465
   370
\          : set evs ==> KeyWithNonce K NB evs";
paulson@3444
   371
by (Blast_tac 1);
paulson@3444
   372
qed "KeyWithNonceI";
paulson@3444
   373
paulson@3444
   374
goalw thy [KeyWithNonce_def]
paulson@3444
   375
   "KeyWithNonce K NB (Says S A X # evs) =                                    \
paulson@3444
   376
\    (Server = S &                                                            \
paulson@3444
   377
\     (EX B n X'. X = {|Crypt (shrK A) {|Agent B, Key K, n, Nonce NB|}, X'|}) \
paulson@3444
   378
\    | KeyWithNonce K NB evs)";
paulson@3444
   379
by (Simp_tac 1);
paulson@3444
   380
by (Blast_tac 1);
paulson@3444
   381
qed "KeyWithNonce_Says";
paulson@3444
   382
Addsimps [KeyWithNonce_Says];
paulson@3444
   383
paulson@3464
   384
(*A fresh key cannot be associated with any nonce 
paulson@3464
   385
  (with respect to a given trace). *)
paulson@3444
   386
goalw thy [KeyWithNonce_def]
paulson@3444
   387
 "!!evs. Key K ~: used evs ==> ~ KeyWithNonce K NB evs";
paulson@3444
   388
by (blast_tac (!claset addSEs sees_Spy_partsEs) 1);
paulson@3444
   389
qed "fresh_not_KeyWithNonce";
paulson@3444
   390
paulson@3444
   391
(*The Server message associates K with NB' and therefore not with any 
paulson@3444
   392
  other nonce NB.*)
paulson@3444
   393
goalw thy [KeyWithNonce_def]
paulson@3444
   394
 "!!evs. [| Says Server A                                                \
paulson@3444
   395
\                {|Crypt (shrK A) {|Agent B, Key K, na, Nonce NB'|}, X|} \
paulson@3466
   396
\             : set evs;                                                 \
paulson@3444
   397
\           NB ~= NB';  evs : yahalom lost |]                            \
paulson@3444
   398
\        ==> ~ KeyWithNonce K NB evs";
paulson@3444
   399
by (blast_tac (!claset addDs [unique_session_keys]) 1);
paulson@3444
   400
qed "Says_Server_KeyWithNonce";
paulson@3444
   401
paulson@3444
   402
paulson@3444
   403
(*The only nonces that can be found with the help of session keys are
paulson@3444
   404
  those distributed as nonce NB by the Server.  The form of the theorem
paulson@3444
   405
  recalls analz_image_freshK, but it is much more complicated.*)
paulson@3444
   406
paulson@3444
   407
paulson@3444
   408
(*As with analz_image_freshK, we take some pains to express the property
paulson@3444
   409
  as a logical equivalence so that the simplifier can apply it.*)
paulson@3444
   410
goal thy  
paulson@3444
   411
 "!!evs. P --> (X : analz (G Un H)) --> (X : analz H)  ==> \
paulson@3444
   412
\        P --> (X : analz (G Un H)) = (X : analz H)";
paulson@3444
   413
by (blast_tac (!claset addIs [impOfSubs analz_mono]) 1);
paulson@3444
   414
val lemma = result();
paulson@2133
   415
paulson@2133
   416
goal thy 
paulson@3444
   417
 "!!evs. evs : yahalom lost ==>                                         \
paulson@3444
   418
\        (ALL KK. KK <= Compl (range shrK) -->                          \
paulson@3444
   419
\             (ALL K: KK. ~ KeyWithNonce K NB evs)   -->                \
paulson@3444
   420
\             (Nonce NB : analz (Key``KK Un (sees lost Spy evs))) =     \
paulson@3444
   421
\             (Nonce NB : analz (sees lost Spy evs)))";
paulson@3444
   422
by (etac yahalom.induct 1);
paulson@3444
   423
by analz_sees_tac;
paulson@3444
   424
by (REPEAT_FIRST (resolve_tac [impI RS allI]));
paulson@3444
   425
by (REPEAT_FIRST (rtac lemma));
paulson@3444
   426
(*For Oops, simplification proves NBa~=NB.  By Says_Server_KeyWithNonce,
paulson@3444
   427
  we get (~ KeyWithNonce K NB evsa); then simplification can apply the
paulson@3444
   428
  induction hypothesis with KK = {K}.*)
paulson@3444
   429
by (ALLGOALS  (*22 seconds*)
paulson@3444
   430
    (asm_simp_tac 
paulson@3444
   431
     (analz_image_freshK_ss addsimps
paulson@3444
   432
        ([all_conj_distrib, not_parts_not_analz, analz_image_freshK,
paulson@3444
   433
	  KeyWithNonce_Says, fresh_not_KeyWithNonce, 
paulson@3444
   434
	  imp_disj_not1,  (*Moves NBa~=NB to the front*)
paulson@3444
   435
	  Says_Server_KeyWithNonce] 
paulson@3444
   436
	 @ pushes))));
paulson@3444
   437
(*Base*)
paulson@3444
   438
by (Blast_tac 1);
paulson@3444
   439
(*Fake*) 
paulson@3444
   440
by (spy_analz_tac 1);
paulson@3444
   441
(*YM4*)  (** LEVEL 7 **)
paulson@3444
   442
by (not_lost_tac "A" 1);
paulson@3444
   443
by (dtac (Says_imp_sees_Spy' RS parts.Inj RS parts.Fst RS A_trusts_YM3) 1
paulson@3444
   444
    THEN REPEAT (assume_tac 1));
paulson@3444
   445
by (blast_tac (!claset addIs [KeyWithNonceI]) 1);
paulson@3444
   446
qed_spec_mp "Nonce_secrecy";
paulson@3444
   447
paulson@3444
   448
paulson@3444
   449
(*Version required below: if NB can be decrypted using a session key then it
paulson@3444
   450
  was distributed with that key.  The more general form above is required
paulson@3444
   451
  for the induction to carry through.*)
paulson@3444
   452
goal thy 
paulson@3444
   453
 "!!evs. [| Says Server A                                                 \
paulson@3444
   454
\            {|Crypt (shrK A) {|Agent B, Key KAB, na, Nonce NB'|}, X|}    \
paulson@3466
   455
\           : set evs;                                                    \
paulson@3444
   456
\           NB ~= NB';  KAB ~: range shrK;  evs : yahalom lost |]         \
paulson@3444
   457
\        ==> (Nonce NB : analz (insert (Key KAB) (sees lost Spy evs))) =  \
paulson@3444
   458
\            (Nonce NB : analz (sees lost Spy evs))";
paulson@3444
   459
by (asm_simp_tac (analz_image_freshK_ss addsimps 
paulson@3444
   460
		  [Nonce_secrecy, Says_Server_KeyWithNonce]) 1);
paulson@3444
   461
qed "single_Nonce_secrecy";
paulson@3444
   462
paulson@3444
   463
paulson@3444
   464
(*** The Nonce NB uniquely identifies B's message. ***)
paulson@3444
   465
paulson@3444
   466
goal thy 
paulson@3444
   467
 "!!evs. evs : yahalom lost ==>                                            \
paulson@3444
   468
\   EX NA' A' B'. ALL NA A B.                                              \
paulson@3501
   469
\      Crypt (shrK B) {|Agent A, Nonce NA, nb|} : parts(sees lost Spy evs) \
paulson@2133
   470
\      --> B ~: lost --> NA = NA' & A = A' & B = B'";
paulson@3121
   471
by parts_induct_tac;
paulson@3121
   472
(*Fake*)
paulson@3121
   473
by (REPEAT (etac (exI RSN (2,exE)) 1)   (*stripping EXs makes proof faster*)
paulson@3121
   474
    THEN Fake_parts_insert_tac 1);
paulson@3121
   475
by (asm_simp_tac (!simpset addsimps [all_conj_distrib]) 1); 
paulson@2133
   476
(*YM2: creation of new Nonce.  Move assertion into global context*)
paulson@3501
   477
by (expand_case_tac "nb = ?y" 1);
paulson@2516
   478
by (REPEAT (resolve_tac [exI, conjI, impI, refl] 1));
paulson@3121
   479
by (blast_tac (!claset addSEs sees_Spy_partsEs) 1);
paulson@2133
   480
val lemma = result();
paulson@2133
   481
paulson@2110
   482
goal thy 
paulson@3501
   483
 "!!evs.[| Crypt (shrK B) {|Agent A, Nonce NA, nb|}        \
paulson@3444
   484
\                  : parts (sees lost Spy evs);            \
paulson@3501
   485
\          Crypt (shrK B') {|Agent A', Nonce NA', nb|}     \
paulson@3444
   486
\                  : parts (sees lost Spy evs);            \
paulson@2133
   487
\          evs : yahalom lost;  B ~: lost;  B' ~: lost |]  \
paulson@2133
   488
\        ==> NA' = NA & A' = A & B' = B";
paulson@2451
   489
by (prove_unique_tac lemma 1);
paulson@2133
   490
qed "unique_NB";
paulson@2133
   491
paulson@2133
   492
paulson@3444
   493
(*Variant useful for proving secrecy of NB: the Says... form allows 
paulson@3444
   494
  not_lost_tac to remove the assumption B' ~: lost.*)
paulson@2133
   495
goal thy 
paulson@3501
   496
 "!!evs.[| Says C D   {|X,  Crypt (shrK B) {|Agent A, Nonce NA, nb|}|}    \
paulson@3466
   497
\            : set evs;          B ~: lost;                               \
paulson@3501
   498
\          Says C' D' {|X', Crypt (shrK B') {|Agent A', Nonce NA', nb|}|} \
paulson@3466
   499
\            : set evs;                                                   \
paulson@3501
   500
\          nb ~: analz (sees lost Spy evs);  evs : yahalom lost |]        \
paulson@2133
   501
\        ==> NA' = NA & A' = A & B' = B";
paulson@3444
   502
by (not_lost_tac "B'" 1);
paulson@3121
   503
by (blast_tac (!claset addSDs [Says_imp_sees_Spy' RS parts.Inj]
paulson@3121
   504
                       addSEs [MPair_parts]
paulson@3121
   505
                       addDs  [unique_NB]) 1);
paulson@2133
   506
qed "Says_unique_NB";
paulson@2133
   507
paulson@3444
   508
val Says_unique_NB' = read_instantiate [("lost","lost")] Says_unique_NB;
paulson@3444
   509
paulson@3444
   510
paulson@3444
   511
(** A nonce value is never used both as NA and as NB **)
paulson@3121
   512
paulson@2133
   513
goal thy 
paulson@3464
   514
 "!!evs. [| B ~: lost;  evs : yahalom lost  |]       \
paulson@3464
   515
\ ==> Nonce NB ~: analz (sees lost Spy evs) -->      \
paulson@3501
   516
\     Crypt (shrK B') {|Agent A', Nonce NB, nb'|}    \
paulson@3464
   517
\       : parts(sees lost Spy evs)                   \
paulson@3464
   518
\ --> Crypt (shrK B) {|Agent A, Nonce NA, Nonce NB|} \
paulson@3464
   519
\       ~: parts(sees lost Spy evs)";
paulson@3121
   520
by analz_mono_parts_induct_tac;
paulson@3121
   521
by (Fake_parts_insert_tac 1);
paulson@3121
   522
by (blast_tac (!claset addDs [Says_imp_sees_Spy' RS analz.Inj]
paulson@3121
   523
                       addSIs [parts_insertI]
paulson@3121
   524
                       addSEs partsEs) 1);
paulson@3464
   525
bind_thm ("no_nonce_YM1_YM2", result() RS mp RSN (2,rev_mp) RSN (2,rev_notE));
paulson@2133
   526
paulson@3464
   527
(*The Server sends YM3 only in response to YM2.*)
paulson@2133
   528
goal thy 
paulson@3466
   529
 "!!evs. [| Says Server A                                                \
paulson@3466
   530
\            {|Crypt (shrK A) {|Agent B, k, na, nb|}, X|} : set evs;     \
paulson@2133
   531
\           evs : yahalom lost |]                                        \
paulson@2133
   532
\        ==> EX B'. Says B' Server                                       \
paulson@2284
   533
\                      {| Agent B, Crypt (shrK B) {|Agent A, na, nb|} |} \
nipkow@3465
   534
\                   : set evs";
paulson@2133
   535
by (etac rev_mp 1);
paulson@2133
   536
by (etac yahalom.induct 1);
paulson@2133
   537
by (ALLGOALS Asm_simp_tac);
paulson@3121
   538
by (ALLGOALS Blast_tac);
paulson@2133
   539
qed "Says_Server_imp_YM2";
paulson@2133
   540
paulson@2133
   541
paulson@3464
   542
(*A vital theorem for B, that nonce NB remains secure from the Spy.
paulson@3444
   543
  Unusually, the Fake case requires Spy:lost.*)
paulson@2133
   544
goal thy 
paulson@2133
   545
 "!!evs. [| A ~: lost;  B ~: lost;  Spy: lost;  evs : yahalom lost |]  \
paulson@2133
   546
\ ==> Says B Server                                                    \
paulson@2284
   547
\          {|Agent B, Crypt (shrK B) {|Agent A, Nonce NA, Nonce NB|}|} \
paulson@3466
   548
\     : set evs -->                                                    \
paulson@3466
   549
\     (ALL k. Says A Spy {|Nonce NA, Nonce NB, k|} ~: set evs) -->     \
paulson@2133
   550
\     Nonce NB ~: analz (sees lost Spy evs)";
paulson@2133
   551
by (etac yahalom.induct 1);
paulson@3121
   552
by analz_sees_tac;
paulson@2133
   553
by (ALLGOALS
paulson@2133
   554
    (asm_simp_tac 
paulson@3444
   555
     (!simpset addsimps ([analz_insert_eq, not_parts_not_analz,
paulson@2516
   556
                          analz_insert_freshK] @ pushes)
paulson@2133
   557
               setloop split_tac [expand_if])));
paulson@3450
   558
(*Prove YM3 by showing that no NB can also be an NA*)
paulson@3450
   559
by (blast_tac (!claset addDs [Says_imp_sees_Spy' RS parts.Inj]
paulson@3450
   560
	               addSEs [MPair_parts]
paulson@3450
   561
		       addDs  [no_nonce_YM1_YM2, Says_unique_NB']) 4
paulson@3450
   562
    THEN flexflex_tac);
paulson@3444
   563
(*YM2: similar freshness reasoning*) 
paulson@3121
   564
by (blast_tac (!claset addSEs partsEs
paulson@3121
   565
		       addDs  [Says_imp_sees_Spy' RS analz.Inj,
paulson@3450
   566
			       impOfSubs analz_subset_parts]) 3);
paulson@3450
   567
(*YM1: NB=NA is impossible anyway, but NA is secret because it is fresh!*)
paulson@3450
   568
by (blast_tac (!claset addSIs [parts_insertI]
paulson@3450
   569
                       addSEs sees_Spy_partsEs) 2);
paulson@2377
   570
(*Fake*)
paulson@2377
   571
by (spy_analz_tac 1);
paulson@3444
   572
(** LEVEL 7: YM4 and Oops remain **)
paulson@3444
   573
(*YM4: key K is visible to Spy, contradicting session key secrecy theorem*) 
paulson@3444
   574
by (REPEAT (Safe_step_tac 1));
paulson@3444
   575
by (not_lost_tac "Aa" 1);
paulson@3121
   576
by (dtac (Says_imp_sees_Spy' RS parts.Inj RS parts.Fst RS A_trusts_YM3) 1);
paulson@2133
   577
by (forward_tac [Says_Server_message_form] 3);
paulson@2133
   578
by (forward_tac [Says_Server_imp_YM2] 4);
paulson@3121
   579
by (REPEAT_FIRST (eresolve_tac [asm_rl, bexE, exE, disjE]));
paulson@3444
   580
(*  use Says_unique_NB' to identify message components: Aa=A, Ba=B, NAa=NA *)
paulson@3444
   581
by (blast_tac (!claset addDs [Says_unique_NB', Spy_not_see_encrypted_key,
paulson@3444
   582
			      impOfSubs Fake_analz_insert]) 1);
paulson@3444
   583
(** LEVEL 14 **)
paulson@3444
   584
(*Oops case: if the nonce is betrayed now, show that the Oops event is 
paulson@3444
   585
  covered by the quantified Oops assumption.*)
paulson@2133
   586
by (full_simp_tac (!simpset addsimps [all_conj_distrib]) 1);
paulson@2133
   587
by (step_tac (!claset delrules [disjE, conjI]) 1);
paulson@2133
   588
by (forward_tac [Says_Server_imp_YM2] 1 THEN assume_tac 1 THEN etac exE 1);
paulson@2133
   589
by (expand_case_tac "NB = NBa" 1);
paulson@3444
   590
(*If NB=NBa then all other components of the Oops message agree*)
paulson@3444
   591
by (blast_tac (!claset addDs [Says_unique_NB']) 1 THEN flexflex_tac);
paulson@3444
   592
(*case NB ~= NBa*)
paulson@3444
   593
by (asm_simp_tac (!simpset addsimps [single_Nonce_secrecy]) 1);
paulson@3444
   594
by (blast_tac (!claset addSEs [MPair_parts]
paulson@3444
   595
		       addDs  [Says_imp_sees_Spy' RS parts.Inj, 
paulson@3444
   596
			       no_nonce_YM1_YM2 (*to prove NB~=NAa*) ]) 1);
paulson@3444
   597
bind_thm ("Spy_not_see_NB", result() RSN(2,rev_mp) RSN(2,rev_mp));
paulson@2133
   598
paulson@2001
   599
paulson@3464
   600
(*B's session key guarantee from YM4.  The two certificates contribute to a
paulson@3464
   601
  single conclusion about the Server's message.  Note that the "Says A Spy"
paulson@3464
   602
  assumption must quantify over ALL POSSIBLE keys instead of our particular K.
paulson@3464
   603
  If this run is broken and the spy substitutes a certificate containing an
paulson@3464
   604
  old key, B has no means of telling.*)
paulson@2001
   605
goal thy 
paulson@3444
   606
 "!!evs. [| Says B Server                                                   \
paulson@3444
   607
\             {|Agent B, Crypt (shrK B) {|Agent A, Nonce NA, Nonce NB|}|}   \
paulson@3466
   608
\             : set evs;                                                    \
paulson@3444
   609
\           Says A' B {|Crypt (shrK B) {|Agent A, Key K|},                  \
paulson@3466
   610
\                       Crypt K (Nonce NB)|} : set evs;                     \
paulson@3466
   611
\           ALL k. Says A Spy {|Nonce NA, Nonce NB, k|} ~: set evs;         \
paulson@3444
   612
\           A ~: lost;  B ~: lost;  Spy: lost;  evs : yahalom lost |]       \
paulson@3444
   613
\         ==> Says Server A                                                 \
paulson@3444
   614
\                     {|Crypt (shrK A) {|Agent B, Key K,                    \
paulson@3444
   615
\                               Nonce NA, Nonce NB|},                       \
paulson@3444
   616
\                       Crypt (shrK B) {|Agent A, Key K|}|}                 \
nipkow@3465
   617
\               : set evs";
paulson@2133
   618
by (forward_tac [Spy_not_see_NB] 1 THEN REPEAT (assume_tac 1));
paulson@3121
   619
by (etac (Says_imp_sees_Spy' RS parts.Inj RS MPair_parts) 1 THEN
paulson@2133
   620
    dtac B_trusts_YM4_shrK 1);
paulson@2170
   621
by (dtac B_trusts_YM4_newK 3);
paulson@2110
   622
by (REPEAT_FIRST (eresolve_tac [asm_rl, exE]));
paulson@2133
   623
by (forward_tac [Says_Server_imp_YM2] 1 THEN assume_tac 1);
paulson@2170
   624
by (dtac unique_session_keys 1 THEN REPEAT (assume_tac 1));
paulson@3121
   625
by (blast_tac (!claset addDs [Says_unique_NB']) 1);
paulson@2322
   626
qed "B_trusts_YM4";
paulson@3444
   627
paulson@3444
   628
paulson@3444
   629
paulson@3444
   630
(*** Authenticating B to A ***)
paulson@3444
   631
paulson@3444
   632
(*The encryption in message YM2 tells us it cannot be faked.*)
paulson@3444
   633
goal thy 
paulson@3444
   634
 "!!evs. evs : yahalom lost                                            \
paulson@3444
   635
\  ==> Crypt (shrK B) {|Agent A, Nonce NA, nb|}                        \
paulson@3444
   636
\        : parts (sees lost Spy evs) -->                               \
paulson@3444
   637
\      B ~: lost -->                                                   \
paulson@3466
   638
\      Says B Server {|Agent B, Crypt (shrK B) {|Agent A, Nonce NA, nb|}|}  \
nipkow@3465
   639
\         : set evs";
paulson@3444
   640
by parts_induct_tac;
paulson@3444
   641
by (Fake_parts_insert_tac 1);
paulson@3444
   642
bind_thm ("B_Said_YM2", result() RSN (2, rev_mp) RS mp);
paulson@3444
   643
paulson@3444
   644
(*If the server sends YM3 then B sent YM2*)
paulson@3444
   645
goal thy 
paulson@3466
   646
 "!!evs. evs : yahalom lost                                                 \
paulson@3444
   647
\  ==> Says Server A {|Crypt (shrK A) {|Agent B, Key K, Nonce NA, nb|}, X|} \
paulson@3466
   648
\         : set evs -->                                                     \
paulson@3466
   649
\      B ~: lost -->                                                        \
paulson@3466
   650
\      Says B Server {|Agent B, Crypt (shrK B) {|Agent A, Nonce NA, nb|}|}  \
nipkow@3465
   651
\                 : set evs";
paulson@3444
   652
by (etac yahalom.induct 1);
paulson@3444
   653
by (ALLGOALS Asm_simp_tac);
paulson@3444
   654
(*YM4*)
paulson@3444
   655
by (Blast_tac 2);
paulson@3444
   656
(*YM3*)
paulson@3444
   657
by (best_tac (!claset addSDs [B_Said_YM2, Says_imp_sees_Spy' RS parts.Inj]
paulson@3444
   658
		      addSEs [MPair_parts]) 1);
paulson@3444
   659
val lemma = result() RSN (2, rev_mp) RS mp |> standard;
paulson@3444
   660
paulson@3444
   661
(*If A receives YM3 then B has used nonce NA (and therefore is alive)*)
paulson@3444
   662
goal thy
paulson@3444
   663
 "!!evs. [| Says S A {|Crypt (shrK A) {|Agent B, Key K, Nonce NA, nb|}, X|} \
paulson@3466
   664
\             : set evs;                                                    \
paulson@3444
   665
\           A ~: lost;  B ~: lost;  evs : yahalom lost |]                   \
paulson@3444
   666
\   ==> Says B Server {|Agent B, Crypt (shrK B) {|Agent A, Nonce NA, nb|}|} \
nipkow@3465
   667
\         : set evs";
paulson@3444
   668
by (blast_tac (!claset addSDs [A_trusts_YM3, lemma]
paulson@3444
   669
		       addEs sees_Spy_partsEs) 1);
paulson@3444
   670
qed "YM3_auth_B_to_A";
paulson@3444
   671
paulson@3444
   672
paulson@3444
   673
(*** Authenticating A to B using the certificate Crypt K (Nonce NB) ***)
paulson@3444
   674
paulson@3444
   675
(*Induction for theorems of the form X ~: analz (sees lost Spy evs) --> ...
paulson@3444
   676
  It simplifies the proof by discarding needless information about
paulson@3444
   677
	analz (insert X (sees lost Spy evs)) 
paulson@3444
   678
*)
paulson@3444
   679
val analz_mono_parts_induct_tac = 
paulson@3444
   680
    etac yahalom.induct 1 
paulson@3444
   681
    THEN 
paulson@3444
   682
    REPEAT_FIRST  
paulson@3444
   683
      (rtac impI THEN' 
paulson@3444
   684
       dtac (sees_subset_sees_Says RS analz_mono RS contra_subsetD) THEN'
paulson@3444
   685
       mp_tac)  
paulson@3444
   686
    THEN  parts_sees_tac;
paulson@3444
   687
paulson@3444
   688
(*Assuming the session key is secure, if both certificates are present then
paulson@3444
   689
  A has said NB.  We can't be sure about the rest of A's message, but only
paulson@3444
   690
  NB matters for freshness.*)  
paulson@3444
   691
goal thy 
paulson@3444
   692
 "!!evs. evs : yahalom lost                                             \
paulson@3444
   693
\        ==> Key K ~: analz (sees lost Spy evs) -->                     \
paulson@3444
   694
\            Crypt K (Nonce NB) : parts (sees lost Spy evs) -->         \
paulson@3444
   695
\            Crypt (shrK B) {|Agent A, Key K|}                          \
paulson@3444
   696
\              : parts (sees lost Spy evs) -->                          \
paulson@3444
   697
\            B ~: lost -->                                              \
nipkow@3465
   698
\             (EX X. Says A B {|X, Crypt K (Nonce NB)|} : set evs)";
paulson@3444
   699
by analz_mono_parts_induct_tac;
paulson@3444
   700
(*Fake*)
paulson@3444
   701
by (Fake_parts_insert_tac 1);
paulson@3444
   702
(*YM3: by new_keys_not_used we note that Crypt K (Nonce NB) could not exist*)
paulson@3444
   703
by (fast_tac (!claset addSDs [Crypt_imp_invKey_keysFor] addss (!simpset)) 1); 
paulson@3444
   704
(*YM4: was Crypt K (Nonce NB) the very last message?  If not, use ind. hyp.*)
paulson@3444
   705
by (asm_simp_tac (!simpset addsimps [ex_disj_distrib]) 1);
paulson@3444
   706
(*yes: apply unicity of session keys*)
paulson@3444
   707
by (not_lost_tac "Aa" 1);
paulson@3444
   708
by (blast_tac (!claset addSEs [MPair_parts]
paulson@3444
   709
                       addSDs [A_trusts_YM3, B_trusts_YM4_shrK]
paulson@3444
   710
		       addDs  [Says_imp_sees_Spy' RS parts.Inj,
paulson@3444
   711
			       unique_session_keys]) 1);
paulson@3444
   712
val lemma = normalize_thm [RSspec, RSmp] (result()) |> standard;
paulson@3444
   713
paulson@3444
   714
(*If B receives YM4 then A has used nonce NB (and therefore is alive).
paulson@3444
   715
  Moreover, A associates K with NB (thus is talking about the same run).
paulson@3444
   716
  Other premises guarantee secrecy of K.*)
paulson@3444
   717
goal thy 
paulson@3444
   718
 "!!evs. [| Says B Server                                                   \
paulson@3444
   719
\             {|Agent B, Crypt (shrK B) {|Agent A, Nonce NA, Nonce NB|}|}   \
paulson@3466
   720
\             : set evs;                                                    \
paulson@3466
   721
\           Says A' B {|Crypt (shrK B) {|Agent A, Key K|},                  \
paulson@3466
   722
\                       Crypt K (Nonce NB)|} : set evs;                     \
paulson@3466
   723
\           (ALL NA k. Says A Spy {|Nonce NA, Nonce NB, k|} ~: set evs);    \
paulson@3444
   724
\           A ~: lost;  B ~: lost;  Spy: lost;  evs : yahalom lost |]       \
nipkow@3465
   725
\        ==> EX X. Says A B {|X, Crypt K (Nonce NB)|} : set evs";
paulson@3444
   726
by (dtac B_trusts_YM4 1);
paulson@3444
   727
by (REPEAT_FIRST (eresolve_tac [asm_rl, spec]));
paulson@3444
   728
by (etac (Says_imp_sees_Spy' RS parts.Inj RS MPair_parts) 1);
paulson@3444
   729
by (rtac lemma 1);
paulson@3444
   730
by (rtac Spy_not_see_encrypted_key 2);
paulson@3444
   731
by (REPEAT_FIRST assume_tac);
paulson@3444
   732
by (blast_tac (!claset addSEs [MPair_parts]
paulson@3444
   733
	       	       addDs [Says_imp_sees_Spy' RS parts.Inj]) 1);
paulson@3444
   734
qed_spec_mp "YM4_imp_A_Said_YM3";