src/HOL/Auth/Yahalom.ML
author paulson
Wed May 07 13:01:43 1997 +0200 (1997-05-07)
changeset 3121 cbb6c0c1c58a
parent 2637 e9b203f854ae
child 3432 04412cfe6861
permissions -rw-r--r--
Conversion to use blast_tac (with other improvements)
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@1985
     6
Inductive relation "otway" 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@2032
    26
\        ==> EX X NB K. EX evs: yahalom lost.          \
paulson@2284
    27
\               Says A B {|X, Crypt K (Nonce NB)|} : set_of_list 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@3121
    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*)
paulson@2051
    48
goal thy "!!evs. evs: yahalom lost ==> ALL A X. Says A A X ~: set_of_list 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.*)
paulson@2284
    59
goal thy "!!evs. Says S A {|Crypt (shrK A) Y, X|} : set_of_list 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@2284
    68
goal thy "!!evs. Says S A {|Crypt (shrK A) {|B, K, NA, NB|}, X|} \
paulson@1995
    69
\                  : set_of_list evs ==> \
paulson@2032
    70
\                K : parts (sees lost Spy evs)";
paulson@3121
    71
by (blast_tac (!claset addSEs partsEs
paulson@3121
    72
                      addSDs [Says_imp_sees_Spy' RS parts.Inj]) 1);
paulson@2110
    73
qed "YM4_Key_parts_sees_Spy";
paulson@2110
    74
paulson@3121
    75
(*For proving the easier theorems about X ~: parts (sees lost Spy evs).
paulson@3121
    76
  We instantiate the variable to "lost" since leaving it as a Var would
paulson@3121
    77
  interfere with simplification.*)
paulson@3121
    78
val parts_sees_tac = 
paulson@3121
    79
    forw_inst_tac [("lost","lost")] YM4_parts_sees_Spy 6     THEN
paulson@3121
    80
    forw_inst_tac [("lost","lost")] YM4_Key_parts_sees_Spy 7 THEN
paulson@3121
    81
    prove_simple_subgoals_tac  1;
paulson@1985
    82
paulson@3121
    83
val parts_induct_tac = 
paulson@3121
    84
    etac yahalom.induct 1 THEN parts_sees_tac;
paulson@1985
    85
paulson@1985
    86
paulson@2032
    87
(** Theorems of the form X ~: parts (sees lost Spy evs) imply that NOBODY
paulson@2013
    88
    sends messages containing X! **)
paulson@1985
    89
paulson@2133
    90
(*Spy never sees another agent's shared key! (unless it's lost at start)*)
paulson@1985
    91
goal thy 
paulson@2133
    92
 "!!evs. evs : yahalom lost \
paulson@2133
    93
\        ==> (Key (shrK A) : parts (sees lost Spy evs)) = (A : lost)";
paulson@3121
    94
by parts_induct_tac;
paulson@3121
    95
by (Fake_parts_insert_tac 1);
paulson@3121
    96
by (Blast_tac 1);
paulson@2133
    97
qed "Spy_see_shrK";
paulson@2133
    98
Addsimps [Spy_see_shrK];
paulson@1985
    99
paulson@2133
   100
goal thy 
paulson@2133
   101
 "!!evs. evs : yahalom lost \
paulson@2133
   102
\        ==> (Key (shrK A) : analz (sees lost Spy evs)) = (A : lost)";
paulson@2133
   103
by (auto_tac(!claset addDs [impOfSubs analz_subset_parts], !simpset));
paulson@2133
   104
qed "Spy_analz_shrK";
paulson@2133
   105
Addsimps [Spy_analz_shrK];
paulson@1985
   106
paulson@2133
   107
goal thy  "!!A. [| Key (shrK A) : parts (sees lost Spy evs);       \
paulson@2133
   108
\                  evs : yahalom lost |] ==> A:lost";
paulson@3121
   109
by (blast_tac (!claset addDs [Spy_see_shrK]) 1);
paulson@2133
   110
qed "Spy_see_shrK_D";
paulson@1985
   111
paulson@2133
   112
bind_thm ("Spy_analz_shrK_D", analz_subset_parts RS subsetD RS Spy_see_shrK_D);
paulson@2133
   113
AddSDs [Spy_see_shrK_D, Spy_analz_shrK_D];
paulson@1985
   114
paulson@1985
   115
paulson@2516
   116
(*Nobody can have used non-existent keys!*)
paulson@2516
   117
goal thy "!!evs. evs : yahalom lost ==>          \
paulson@2516
   118
\         Key K ~: used evs --> K ~: keysFor (parts (sees lost Spy evs))";
paulson@3121
   119
by parts_induct_tac;
paulson@2516
   120
(*YM4: Key K is not fresh!*)
paulson@3121
   121
by (blast_tac (!claset addSEs sees_Spy_partsEs) 3);
paulson@2516
   122
(*YM3*)
paulson@3121
   123
by (Blast_tac 2);
paulson@2516
   124
(*Fake*)
paulson@2516
   125
by (best_tac
paulson@2516
   126
      (!claset addIs [impOfSubs analz_subset_parts]
paulson@2516
   127
               addDs [impOfSubs (analz_subset_parts RS keysFor_mono),
paulson@2516
   128
                      impOfSubs (parts_insert_subset_Un RS keysFor_mono)]
paulson@2516
   129
               addss (!simpset)) 1);
paulson@2160
   130
qed_spec_mp "new_keys_not_used";
paulson@1985
   131
paulson@1985
   132
bind_thm ("new_keys_not_analzd",
paulson@2032
   133
          [analz_subset_parts RS keysFor_mono,
paulson@2032
   134
           new_keys_not_used] MRS contra_subsetD);
paulson@1985
   135
paulson@1985
   136
Addsimps [new_keys_not_used, new_keys_not_analzd];
paulson@1985
   137
paulson@1985
   138
paulson@2133
   139
(*Describes the form of K when the Server sends this message.  Useful for
paulson@2133
   140
  Oops as well as main secrecy property.*)
paulson@2110
   141
goal thy 
paulson@2516
   142
 "!!evs. [| Says Server A {|Crypt (shrK A) {|Agent B, Key K, NA, NB|}, X|} \
paulson@2516
   143
\             : set_of_list evs;                                           \
paulson@2516
   144
\           evs : yahalom lost |]                                          \
paulson@2516
   145
\        ==> K ~: range shrK";
paulson@2133
   146
by (etac rev_mp 1);
paulson@2133
   147
by (etac yahalom.induct 1);
paulson@3121
   148
by (ALLGOALS Asm_simp_tac);
paulson@3121
   149
by (Blast_tac 1);
paulson@2133
   150
qed "Says_Server_message_form";
paulson@2110
   151
paulson@2110
   152
paulson@2110
   153
(*For proofs involving analz.  We again instantiate the variable to "lost".*)
paulson@3121
   154
val analz_sees_tac = 
paulson@2133
   155
    forw_inst_tac [("lost","lost")] YM4_analz_sees_Spy 6 THEN
paulson@2133
   156
    forw_inst_tac [("lost","lost")] Says_Server_message_form 7 THEN
paulson@2516
   157
    assume_tac 7 THEN REPEAT ((etac exE ORELSE' hyp_subst_tac) 7);
paulson@1985
   158
paulson@1985
   159
paulson@1985
   160
(****
paulson@1985
   161
 The following is to prove theorems of the form
paulson@1985
   162
paulson@2516
   163
  Key K : analz (insert (Key KAB) (sees lost Spy evs)) ==>
paulson@2451
   164
  Key K : analz (sees lost Spy evs)
paulson@1985
   165
paulson@1985
   166
 A more general formula must be proved inductively.
paulson@1985
   167
****)
paulson@1985
   168
paulson@1985
   169
(** Session keys are not used to encrypt other session keys **)
paulson@1985
   170
paulson@1985
   171
goal thy  
paulson@2032
   172
 "!!evs. evs : yahalom lost ==> \
paulson@2516
   173
\  ALL K KK. KK <= Compl (range shrK) -->                      \
paulson@2516
   174
\            (Key K : analz (Key``KK Un (sees lost Spy evs))) = \
paulson@2516
   175
\            (K : KK | Key K : analz (sees lost Spy evs))";
paulson@2032
   176
by (etac yahalom.induct 1);
paulson@3121
   177
by analz_sees_tac;
paulson@2516
   178
by (REPEAT_FIRST (resolve_tac [allI, impI]));
paulson@2516
   179
by (REPEAT_FIRST (rtac analz_image_freshK_lemma ));
paulson@2516
   180
by (ALLGOALS (asm_simp_tac analz_image_freshK_ss));
paulson@2516
   181
(*Base*)
paulson@3121
   182
by (Blast_tac 1);
paulson@2133
   183
(*YM4, Fake*) 
paulson@2516
   184
by (REPEAT (spy_analz_tac 1));
paulson@2516
   185
qed_spec_mp "analz_image_freshK";
paulson@1985
   186
paulson@1985
   187
goal thy
paulson@2516
   188
 "!!evs. [| evs : yahalom lost;  KAB ~: range shrK |] ==>             \
paulson@2516
   189
\        Key K : analz (insert (Key KAB) (sees lost Spy evs)) = \
paulson@2516
   190
\        (K = KAB | Key K : analz (sees lost Spy evs))";
paulson@2516
   191
by (asm_simp_tac (analz_image_freshK_ss addsimps [analz_image_freshK]) 1);
paulson@2516
   192
qed "analz_insert_freshK";
paulson@1985
   193
paulson@1985
   194
paulson@2110
   195
(*** The Key K uniquely identifies the Server's  message. **)
paulson@2110
   196
paulson@2110
   197
goal thy 
paulson@2110
   198
 "!!evs. evs : yahalom lost ==>                                     \
paulson@2133
   199
\      EX A' B' NA' NB' X'. ALL A B NA NB X.                             \
paulson@2110
   200
\          Says Server A                                            \
paulson@2284
   201
\           {|Crypt (shrK A) {|Agent B, Key K, NA, NB|}, X|}        \
paulson@2133
   202
\          : set_of_list evs --> A=A' & B=B' & NA=NA' & NB=NB' & X=X'";
paulson@2110
   203
by (etac yahalom.induct 1);
paulson@2110
   204
by (ALLGOALS (asm_simp_tac (!simpset addsimps [all_conj_distrib])));
paulson@2110
   205
by (Step_tac 1);
paulson@2133
   206
by (ex_strip_tac 2);
paulson@3121
   207
by (Blast_tac 2);
paulson@2110
   208
(*Remaining case: YM3*)
paulson@2110
   209
by (expand_case_tac "K = ?y" 1);
paulson@2110
   210
by (REPEAT (ares_tac [refl,exI,impI,conjI] 2));
paulson@2516
   211
(*...we assume X is a recent message and handle this case by contradiction*)
paulson@3121
   212
by (blast_tac (!claset addSEs sees_Spy_partsEs
paulson@3121
   213
                      delrules [conjI]    (*no split-up to 4 subgoals*)) 1);
paulson@2110
   214
val lemma = result();
paulson@2110
   215
paulson@2110
   216
goal thy 
paulson@2110
   217
"!!evs. [| Says Server A                                            \
paulson@2284
   218
\           {|Crypt (shrK A) {|Agent B, Key K, NA, NB|}, X|}        \
paulson@2110
   219
\           : set_of_list evs;                                      \
paulson@2110
   220
\          Says Server A'                                           \
paulson@2284
   221
\           {|Crypt (shrK A') {|Agent B', Key K, NA', NB'|}, X'|}   \
paulson@2110
   222
\           : set_of_list evs;                                      \
paulson@2110
   223
\          evs : yahalom lost |]                                    \
paulson@2110
   224
\       ==> A=A' & B=B' & NA=NA' & NB=NB'";
paulson@2451
   225
by (prove_unique_tac lemma 1);
paulson@2110
   226
qed "unique_session_keys";
paulson@2110
   227
paulson@2110
   228
paulson@2110
   229
(*If the encrypted message appears then it originated with the Server*)
paulson@2110
   230
goal thy
paulson@2284
   231
 "!!evs. [| Crypt (shrK A) {|Agent B, Key K, NA, NB|}                  \
paulson@2110
   232
\            : parts (sees lost Spy evs);                              \
paulson@2110
   233
\           A ~: lost;  evs : yahalom lost |]                          \
paulson@2110
   234
\         ==> Says Server A                                            \
paulson@2284
   235
\              {|Crypt (shrK A) {|Agent B, Key K, NA, NB|},            \
paulson@2284
   236
\                Crypt (shrK B) {|Agent A, Key K|}|}                   \
paulson@2110
   237
\             : set_of_list evs";
paulson@2110
   238
by (etac rev_mp 1);
paulson@3121
   239
by parts_induct_tac;
paulson@3121
   240
by (Fake_parts_insert_tac 1);
paulson@2322
   241
qed "A_trusts_YM3";
paulson@2110
   242
paulson@2110
   243
paulson@2110
   244
(** Crucial secrecy property: Spy does not see the keys sent in msg YM3 **)
paulson@2013
   245
paulson@2013
   246
goal thy 
paulson@2133
   247
 "!!evs. [| A ~: lost;  B ~: lost;  evs : yahalom lost |]         \
paulson@2051
   248
\        ==> Says Server A                                        \
paulson@2284
   249
\              {|Crypt (shrK A) {|Agent B, Key K, NA, NB|},       \
paulson@2284
   250
\                Crypt (shrK B) {|Agent A, Key K|}|}              \
paulson@2110
   251
\             : set_of_list evs -->                               \
paulson@2110
   252
\            Says A Spy {|NA, NB, Key K|} ~: set_of_list evs -->  \
paulson@2051
   253
\            Key K ~: analz (sees lost Spy evs)";
paulson@2032
   254
by (etac yahalom.induct 1);
paulson@3121
   255
by analz_sees_tac;
paulson@2013
   256
by (ALLGOALS
paulson@2013
   257
    (asm_simp_tac 
paulson@2516
   258
     (!simpset addsimps [not_parts_not_analz, analz_insert_freshK]
paulson@2013
   259
               setloop split_tac [expand_if])));
paulson@2013
   260
(*YM3*)
paulson@3121
   261
by (blast_tac (!claset delrules [impCE]
paulson@3121
   262
                       addSEs sees_Spy_partsEs
paulson@3121
   263
                       addIs [impOfSubs analz_subset_parts]) 2);
paulson@2133
   264
(*OR4, Fake*) 
paulson@2377
   265
by (REPEAT_FIRST spy_analz_tac);
paulson@2451
   266
(*Oops*)
paulson@3121
   267
by (blast_tac (!claset addDs [unique_session_keys]) 1);
paulson@2110
   268
val lemma = result() RS mp RS mp RSN(2,rev_notE);
paulson@2013
   269
paulson@2013
   270
paulson@2013
   271
(*Final version: Server's message in the most abstract form*)
paulson@1985
   272
goal thy 
paulson@2516
   273
 "!!evs. [| Says Server A                                         \
paulson@2516
   274
\              {|Crypt (shrK A) {|Agent B, Key K, NA, NB|},       \
paulson@2516
   275
\                Crypt (shrK B) {|Agent A, Key K|}|}              \
paulson@2516
   276
\             : set_of_list evs;                                  \
paulson@2516
   277
\           Says A Spy {|NA, NB, Key K|} ~: set_of_list evs;      \
paulson@2516
   278
\           A ~: lost;  B ~: lost;  evs : yahalom lost |]         \
paulson@2516
   279
\        ==> Key K ~: analz (sees lost Spy evs)";
paulson@2013
   280
by (forward_tac [Says_Server_message_form] 1 THEN assume_tac 1);
paulson@3121
   281
by (blast_tac (!claset addSEs [lemma]) 1);
paulson@2032
   282
qed "Spy_not_see_encrypted_key";
paulson@2001
   283
paulson@2001
   284
paulson@2045
   285
goal thy 
paulson@2516
   286
 "!!evs. [| C ~: {A,B,Server};                                    \
paulson@2516
   287
\           Says Server A                                         \
paulson@2516
   288
\              {|Crypt (shrK A) {|Agent B, Key K, NA, NB|},       \
paulson@2516
   289
\                Crypt (shrK B) {|Agent A, Key K|}|}              \
paulson@2516
   290
\             : set_of_list evs;                                  \
paulson@2516
   291
\           Says A Spy {|NA, NB, Key K|} ~: set_of_list evs;      \
paulson@2516
   292
\           A ~: lost;  B ~: lost;  evs : yahalom lost |]         \
paulson@2516
   293
\        ==> Key K ~: analz (sees lost C evs)";
paulson@2045
   294
by (rtac (subset_insertI RS sees_mono RS analz_mono RS contra_subsetD) 1);
paulson@2045
   295
by (rtac (sees_lost_agent_subset_sees_Spy RS analz_mono RS contra_subsetD) 1);
paulson@2045
   296
by (FIRSTGOAL (rtac Spy_not_see_encrypted_key));
paulson@3121
   297
by (REPEAT_FIRST (blast_tac (!claset addIs [yahalom_mono RS subsetD])));
paulson@2045
   298
qed "Agent_not_see_encrypted_key";
paulson@2045
   299
paulson@2045
   300
paulson@2110
   301
(*** Security Guarantee for B upon receiving YM4 ***)
paulson@2013
   302
paulson@2110
   303
(*B knows, by the first part of A's message, that the Server distributed 
paulson@2110
   304
  the key for A and B.  But this part says nothing about nonces.*)
paulson@2001
   305
goal thy 
paulson@2284
   306
 "!!evs. [| Crypt (shrK B) {|Agent A, Key K|} : parts (sees lost Spy evs); \
paulson@2051
   307
\           B ~: lost;  evs : yahalom lost |]                           \
paulson@2001
   308
\        ==> EX NA NB. Says Server A                                    \
paulson@2451
   309
\                        {|Crypt (shrK A) {|Agent B, Key K,             \
paulson@2516
   310
\                                           Nonce NA, Nonce NB|},       \
paulson@2284
   311
\                          Crypt (shrK B) {|Agent A, Key K|}|}          \
paulson@2013
   312
\                       : set_of_list evs";
paulson@2032
   313
by (etac rev_mp 1);
paulson@3121
   314
by parts_induct_tac;
paulson@3121
   315
by (Fake_parts_insert_tac 1);
paulson@2110
   316
(*YM3*)
paulson@3121
   317
by (Blast_tac 1);
paulson@2110
   318
qed "B_trusts_YM4_shrK";
paulson@2110
   319
paulson@2133
   320
paulson@2133
   321
(** The Nonce NB uniquely identifies B's message. **)
paulson@2133
   322
paulson@2133
   323
goal thy 
paulson@2451
   324
 "!!evs. evs : yahalom lost ==> \
paulson@2451
   325
\   EX NA' A' B'. ALL NA A B. \
paulson@2284
   326
\      Crypt (shrK B) {|Agent A, Nonce NA, NB|} : parts(sees lost Spy evs) \
paulson@2133
   327
\      --> B ~: lost --> NA = NA' & A = A' & B = B'";
paulson@3121
   328
by parts_induct_tac;
paulson@3121
   329
(*Fake*)
paulson@3121
   330
by (REPEAT (etac (exI RSN (2,exE)) 1)   (*stripping EXs makes proof faster*)
paulson@3121
   331
    THEN Fake_parts_insert_tac 1);
paulson@3121
   332
by (asm_simp_tac (!simpset addsimps [all_conj_distrib]) 1); 
paulson@2133
   333
(*YM2: creation of new Nonce.  Move assertion into global context*)
paulson@2133
   334
by (expand_case_tac "NB = ?y" 1);
paulson@2516
   335
by (REPEAT (resolve_tac [exI, conjI, impI, refl] 1));
paulson@3121
   336
by (blast_tac (!claset addSEs sees_Spy_partsEs) 1);
paulson@2133
   337
val lemma = result();
paulson@2133
   338
paulson@2110
   339
goal thy 
paulson@2284
   340
 "!!evs.[| Crypt (shrK B) {|Agent A, Nonce NA, NB|} \
paulson@2133
   341
\                  : parts (sees lost Spy evs);         \
paulson@2284
   342
\          Crypt (shrK B') {|Agent A', Nonce NA', NB|} \
paulson@2133
   343
\                  : parts (sees lost Spy evs);         \
paulson@2133
   344
\          evs : yahalom lost;  B ~: lost;  B' ~: lost |]  \
paulson@2133
   345
\        ==> NA' = NA & A' = A & B' = B";
paulson@2451
   346
by (prove_unique_tac lemma 1);
paulson@2133
   347
qed "unique_NB";
paulson@2133
   348
paulson@2133
   349
fun lost_tac s =
paulson@2133
   350
    case_tac ("(" ^ s ^ ") : lost") THEN'
paulson@2133
   351
    SELECT_GOAL 
paulson@3121
   352
      (REPEAT_DETERM (dtac (Says_imp_sees_Spy' RS analz.Inj) 1) THEN
paulson@2133
   353
       REPEAT_DETERM (etac MPair_analz 1) THEN
paulson@2133
   354
       THEN_BEST_FIRST 
paulson@2133
   355
         (dres_inst_tac [("A", s)] Crypt_Spy_analz_lost 1 THEN assume_tac 1)
paulson@2170
   356
         (has_fewer_prems 1, size_of_thm)
paulson@2170
   357
         (Step_tac 1));
paulson@2133
   358
paulson@2133
   359
paulson@2133
   360
(*Variant useful for proving secrecy of NB*)
paulson@2133
   361
goal thy 
paulson@2284
   362
 "!!evs.[| Says C D   {|X,  Crypt (shrK B) {|Agent A, Nonce NA, NB|}|} \
paulson@2133
   363
\          : set_of_list evs;  B ~: lost;         \
paulson@2284
   364
\          Says C' D' {|X', Crypt (shrK B') {|Agent A', Nonce NA', NB|}|} \
paulson@2133
   365
\          : set_of_list evs;                           \
paulson@2133
   366
\          NB ~: analz (sees lost Spy evs);             \
paulson@2133
   367
\          evs : yahalom lost |]  \
paulson@2133
   368
\        ==> NA' = NA & A' = A & B' = B";
paulson@2133
   369
by (lost_tac "B'" 1);
paulson@3121
   370
by (blast_tac (!claset addSDs [Says_imp_sees_Spy' RS parts.Inj]
paulson@3121
   371
                       addSEs [MPair_parts]
paulson@3121
   372
                       addDs  [unique_NB]) 1);
paulson@2133
   373
qed "Says_unique_NB";
paulson@2133
   374
paulson@3121
   375
(*Induction for theorems of the form X ~: analz (sees lost Spy evs) --> ...
paulson@3121
   376
  It simplifies the proof by discarding needless information about
paulson@3121
   377
	analz (insert X (sees lost Spy evs)) 
paulson@3121
   378
*)
paulson@3121
   379
val analz_mono_parts_induct_tac = 
paulson@3121
   380
    etac yahalom.induct 1 
paulson@3121
   381
    THEN 
paulson@3121
   382
    REPEAT_FIRST  
paulson@3121
   383
      (rtac impI THEN' 
paulson@3121
   384
       dtac (sees_subset_sees_Says RS analz_mono RS contra_subsetD) THEN'
paulson@3121
   385
       mp_tac)  
paulson@3121
   386
    THEN  parts_sees_tac;
paulson@3121
   387
paulson@2133
   388
goal thy 
paulson@2133
   389
 "!!evs. [| B ~: lost;  evs : yahalom lost  |]               \
paulson@3121
   390
\ ==> Nonce NB ~: analz (sees lost Spy evs) -->  \
paulson@3121
   391
\     Crypt (shrK B) {|Agent A, Nonce NA, Nonce NB|}: parts(sees lost Spy evs)\
paulson@3121
   392
\ --> Crypt (shrK B') {|Agent A', Nonce NB, NB'|} ~: parts(sees lost Spy evs)";
paulson@3121
   393
by analz_mono_parts_induct_tac;
paulson@3121
   394
by (Fake_parts_insert_tac 1);
paulson@3121
   395
by (blast_tac (!claset addDs [Says_imp_sees_Spy' RS analz.Inj]
paulson@3121
   396
                       addSIs [parts_insertI]
paulson@3121
   397
                       addSEs partsEs) 1);
paulson@2133
   398
val no_nonce_YM1_YM2 = standard (result() RS mp RSN (2, rev_mp) RS notE);
paulson@2133
   399
paulson@2133
   400
paulson@2133
   401
paulson@2133
   402
(**** Towards proving secrecy of Nonce NB ****)
paulson@2133
   403
paulson@2133
   404
(*B knows, by the second part of A's message, that the Server distributed 
paulson@2133
   405
  the key quoting nonce NB.  This part says nothing about agent names. 
paulson@2133
   406
  Secrecy of NB is crucial.*)
paulson@2133
   407
goal thy 
paulson@2133
   408
 "!!evs. evs : yahalom lost                                             \
paulson@2133
   409
\        ==> Nonce NB ~: analz (sees lost Spy evs) -->                  \
paulson@2284
   410
\            Crypt K (Nonce NB) : parts (sees lost Spy evs) -->         \
paulson@2133
   411
\            (EX A B NA. Says Server A                                  \
paulson@2516
   412
\                        {|Crypt (shrK A) {|Agent B, Key K,             \
paulson@2516
   413
\                                  Nonce NA, Nonce NB|},                \
paulson@2284
   414
\                          Crypt (shrK B) {|Agent A, Key K|}|}          \
paulson@2133
   415
\                       : set_of_list evs)";
paulson@3121
   416
by analz_mono_parts_induct_tac;
paulson@3121
   417
(*YM4 & Fake*)
paulson@3121
   418
by (Blast_tac 2);
paulson@3121
   419
by (Fake_parts_insert_tac 1);
paulson@3121
   420
(*YM3*)
paulson@2133
   421
by (Step_tac 1);
paulson@2133
   422
by (lost_tac "A" 1);
paulson@3121
   423
by (blast_tac (!claset addDs [Says_imp_sees_Spy' RS parts.Inj RS parts.Fst RS
paulson@3121
   424
			      A_trusts_YM3]) 1);
paulson@2133
   425
val B_trusts_YM4_newK = result() RS mp RSN (2, rev_mp);
paulson@2133
   426
paulson@2133
   427
paulson@2133
   428
(*This is the original version of the result above.  But it is of little
paulson@2133
   429
  value because it assumes secrecy of K, which we cannot be assured of
paulson@2133
   430
  until we know that K is fresh -- which we do not know at the point this
paulson@2133
   431
  result is applied.*)
paulson@2133
   432
goal thy 
paulson@2133
   433
 "!!evs. evs : yahalom lost                                             \
paulson@2133
   434
\        ==> Key K ~: analz (sees lost Spy evs) -->                     \
paulson@2284
   435
\            Crypt K (Nonce NB) : parts (sees lost Spy evs) -->         \
paulson@2110
   436
\            (EX A B NA. Says Server A                                  \
paulson@3121
   437
\                        {|Crypt (shrK A) {|Agent B, Key K,             \
paulson@3121
   438
\                                  Nonce NA, Nonce NB|},                \
paulson@2284
   439
\                          Crypt (shrK B) {|Agent A, Key K|}|}          \
paulson@2110
   440
\                       : set_of_list evs)";
paulson@3121
   441
by analz_mono_parts_induct_tac;
paulson@3121
   442
(*YM4 & Fake*)
paulson@3121
   443
by (Blast_tac 2);
paulson@3121
   444
by (Fake_parts_insert_tac 1);
paulson@3121
   445
(*YM3*)
paulson@2110
   446
by (Step_tac 1);
paulson@2133
   447
by (lost_tac "A" 1);
paulson@3121
   448
by (blast_tac (!claset addDs [Says_imp_sees_Spy' RS parts.Inj RS parts.Fst RS
paulson@3121
   449
			      A_trusts_YM3]) 1);
paulson@2133
   450
result() RS mp RSN (2, rev_mp);
paulson@2133
   451
paulson@2133
   452
paulson@2133
   453
(*YM3 can only be triggered by YM2*)
paulson@2133
   454
goal thy 
paulson@2133
   455
 "!!evs. [| Says Server A                                           \
paulson@2284
   456
\            {|Crypt (shrK A) {|Agent B, k, na, nb|}, X|} : set_of_list evs; \
paulson@2133
   457
\           evs : yahalom lost |]                                        \
paulson@2133
   458
\        ==> EX B'. Says B' Server                                       \
paulson@2284
   459
\                      {| Agent B, Crypt (shrK B) {|Agent A, na, nb|} |} \
paulson@2133
   460
\                   : set_of_list evs";
paulson@2133
   461
by (etac rev_mp 1);
paulson@2133
   462
by (etac yahalom.induct 1);
paulson@2133
   463
by (ALLGOALS Asm_simp_tac);
paulson@3121
   464
by (ALLGOALS Blast_tac);
paulson@2133
   465
qed "Says_Server_imp_YM2";
paulson@2133
   466
paulson@2133
   467
paulson@2133
   468
(** Dedicated tactics for the nonce secrecy proofs **)
paulson@2133
   469
paulson@2133
   470
val no_nonce_tac = SELECT_GOAL
paulson@2133
   471
   (REPEAT (resolve_tac [impI, notI] 1) THEN
paulson@2133
   472
    REPEAT (hyp_subst_tac 1) THEN
paulson@3121
   473
    etac (Says_imp_sees_Spy' RS parts.Inj RS parts.Snd RS no_nonce_YM1_YM2) 1
paulson@2133
   474
    THEN
paulson@3121
   475
    etac (Says_imp_sees_Spy' RS parts.Inj RS parts.Snd) 4
paulson@2133
   476
    THEN 
paulson@2133
   477
    REPEAT_FIRST assume_tac);
paulson@2133
   478
paulson@2133
   479
val not_analz_insert = subset_insertI RS analz_mono RS contra_subsetD;
paulson@2133
   480
paulson@2133
   481
paulson@2133
   482
(*The only nonces that can be found with the help of session keys are
paulson@2133
   483
  those distributed as nonce NB by the Server.  The form of the theorem
paulson@2516
   484
  recalls analz_image_freshK, but it is much more complicated.*)
paulson@2516
   485
paulson@2516
   486
(*As with analz_image_freshK, we take some pains to express the property
paulson@2516
   487
  as a logical equivalence so that the simplifier can apply it.*)
paulson@2516
   488
goal thy  
paulson@2516
   489
 "!!evs. P --> (X : analz (G Un H)) --> (X : analz H)  ==> \
paulson@2516
   490
\        P --> (X : analz (G Un H)) = (X : analz H)";
paulson@3121
   491
by (blast_tac (!claset addIs [impOfSubs analz_mono]) 1);
paulson@2516
   492
qed "Nonce_secrecy_lemma";
paulson@2516
   493
paulson@2133
   494
goal thy 
paulson@3121
   495
 "!!evs. evs : yahalom lost ==>                                              \
paulson@2516
   496
\        (ALL KK. KK <= Compl (range shrK) -->                               \
paulson@3121
   497
\             (ALL K: KK. ALL A B na X.                                      \
paulson@2516
   498
\                 Says Server A                                              \
paulson@2516
   499
\                     {|Crypt (shrK A) {|Agent B, Key K, na, Nonce NB|}, X|} \
paulson@3121
   500
\                 ~: set_of_list evs)   -->                                  \
paulson@3121
   501
\             (Nonce NB : analz (Key``KK Un (sees lost Spy evs))) =          \
paulson@2516
   502
\             (Nonce NB : analz (sees lost Spy evs)))";
paulson@2133
   503
by (etac yahalom.induct 1);
paulson@3121
   504
by analz_sees_tac;
paulson@2516
   505
by (REPEAT_FIRST (resolve_tac [impI RS allI]));
paulson@2516
   506
by (REPEAT_FIRST (rtac Nonce_secrecy_lemma ));
paulson@2516
   507
by (rtac ccontr 7);
paulson@3121
   508
by (subgoal_tac "ALL A B na X.                                               \
paulson@2516
   509
\                 Says Server A                                              \
paulson@2516
   510
\                     {|Crypt (shrK A) {|Agent B, Key K, na, Nonce NB|}, X|} \
paulson@2516
   511
\                 ~: set_of_list evsa" 7);
paulson@2516
   512
by (eres_inst_tac [("P","?PP-->?QQ")] notE 7);
paulson@3121
   513
by (subgoal_tac "ALL A B na X.                                                \
paulson@3121
   514
\                 Says Server A                                               \
paulson@2516
   515
\                    {|Crypt (shrK A) {|Agent B, Key KAB, na, Nonce NB|}, X|} \
paulson@2516
   516
\                 ~: set_of_list evsa" 5);
paulson@2451
   517
by (ALLGOALS  (*22 seconds*)
paulson@2133
   518
    (asm_simp_tac 
paulson@2516
   519
     (analz_image_freshK_ss  addsimps
paulson@2516
   520
             ([all_conj_distrib, 
paulson@2516
   521
               not_parts_not_analz, analz_image_freshK]
paulson@2516
   522
              @ pushes @ ball_simps))));
paulson@2133
   523
(*Base*)
paulson@3121
   524
by (Blast_tac 1);
paulson@2516
   525
(*Fake*) (** LEVEL 10 **)
paulson@2133
   526
by (spy_analz_tac 1);
paulson@2516
   527
(*YM3*)
paulson@3121
   528
by (blast_tac (!claset addSEs sees_Spy_partsEs) 1);
paulson@2133
   529
(*Oops*)
paulson@3121
   530
by (Asm_full_simp_tac 2); 
paulson@3121
   531
by (blast_tac (!claset addDs [unique_session_keys]) 2);
paulson@2133
   532
(*YM4*)
paulson@2516
   533
(** LEVEL 13 **)
paulson@2516
   534
by (REPEAT (resolve_tac [impI, allI] 1));
paulson@2377
   535
by (dtac (impOfSubs Fake_analz_insert) 1 THEN etac synth.Inj 1);
paulson@2516
   536
by (stac insert_commute 1);
paulson@2133
   537
by (eres_inst_tac [("P","Nonce NB : ?HH")] rev_mp 1);
paulson@2516
   538
by (asm_simp_tac (analz_image_freshK_ss 
paulson@2516
   539
                  addsimps [analz_insertI, analz_image_freshK]) 1);
paulson@2516
   540
by (step_tac (!claset addSDs [not_analz_insert]) 1);
paulson@2133
   541
by (lost_tac "A" 1);
paulson@2516
   542
(** LEVEL 20 **)
paulson@3121
   543
by (dtac (Says_imp_sees_Spy' RS parts.Inj RS parts.Fst RS A_trusts_YM3) 1
paulson@2133
   544
    THEN REPEAT (assume_tac 1));
paulson@2516
   545
by (thin_tac "All ?PP" 1);
paulson@3121
   546
by (Blast_tac 1);
paulson@2516
   547
qed_spec_mp "Nonce_secrecy";
paulson@2133
   548
paulson@2133
   549
paulson@2133
   550
(*Version required below: if NB can be decrypted using a session key then it
paulson@2133
   551
  was distributed with that key.  The more general form above is required
paulson@2133
   552
  for the induction to carry through.*)
paulson@2133
   553
goal thy 
paulson@2516
   554
 "!!evs. [| Says Server A                                              \
paulson@2516
   555
\            {|Crypt (shrK A) {|Agent B, Key KAB, na, Nonce NB'|}, X|} \
paulson@2516
   556
\           : set_of_list evs;                                         \
paulson@2516
   557
\           Nonce NB : analz (insert (Key KAB) (sees lost Spy evs));   \
paulson@2516
   558
\           Nonce NB ~: analz (sees lost Spy evs);                     \
paulson@2516
   559
\           KAB ~: range shrK;  evs : yahalom lost |]                  \
paulson@2516
   560
\        ==>  NB = NB'";
paulson@2516
   561
by (rtac ccontr 1);
paulson@3121
   562
by (subgoal_tac "ALL A B na X.                                                \
paulson@3121
   563
\                 Says Server A                                               \
paulson@2516
   564
\                    {|Crypt (shrK A) {|Agent B, Key KAB, na, Nonce NB|}, X|} \
paulson@2516
   565
\                 ~: set_of_list evs" 1);
paulson@2516
   566
by (eres_inst_tac [("P","Nonce NB : ?HH")] rev_mp 1);
paulson@2516
   567
by (asm_simp_tac (analz_image_freshK_ss 
paulson@2516
   568
                  addsimps ([Nonce_secrecy] @ ball_simps)) 1);
paulson@2516
   569
by (auto_tac (!claset addDs [unique_session_keys], (!simpset)));
paulson@2516
   570
qed "single_Nonce_secrecy";
paulson@2133
   571
paulson@2133
   572
paulson@3121
   573
val Says_unique_NB' = read_instantiate [("lost","lost")] Says_unique_NB;
paulson@3121
   574
paulson@2133
   575
goal thy 
paulson@2133
   576
 "!!evs. [| A ~: lost;  B ~: lost;  Spy: lost;  evs : yahalom lost |]  \
paulson@2133
   577
\ ==> Says B Server                                                    \
paulson@2284
   578
\          {|Agent B, Crypt (shrK B) {|Agent A, Nonce NA, Nonce NB|}|} \
paulson@2133
   579
\     : set_of_list evs -->                               \
paulson@2133
   580
\     (ALL k. Says A Spy {|Nonce NA, Nonce NB, k|} ~: set_of_list evs) -->  \
paulson@2133
   581
\     Nonce NB ~: analz (sees lost Spy evs)";
paulson@2133
   582
by (etac yahalom.induct 1);
paulson@3121
   583
by analz_sees_tac;
paulson@2133
   584
by (ALLGOALS
paulson@2133
   585
    (asm_simp_tac 
paulson@2377
   586
     (!simpset addsimps ([not_parts_not_analz,
paulson@2516
   587
                          analz_insert_freshK] @ pushes)
paulson@2133
   588
               setloop split_tac [expand_if])));
paulson@3121
   589
by (blast_tac (!claset addSIs [parts_insertI]
paulson@3121
   590
                       addSEs sees_Spy_partsEs) 2);
paulson@2377
   591
(*Proof of YM2*) (** LEVEL 4 **)
paulson@3121
   592
by (blast_tac (!claset addSEs partsEs
paulson@3121
   593
		       addDs  [Says_imp_sees_Spy' RS analz.Inj,
paulson@3121
   594
			       impOfSubs analz_subset_parts]) 2);
paulson@2133
   595
(*Prove YM3 by showing that no NB can also be an NA*)
paulson@2133
   596
by (REPEAT (Safe_step_tac 2 ORELSE no_nonce_tac 2));
paulson@3121
   597
by (blast_tac (!claset addDs [Says_unique_NB']) 2 THEN flexflex_tac);
paulson@2377
   598
(*Fake*)
paulson@2377
   599
by (spy_analz_tac 1);
paulson@2516
   600
(*YM4*) (** LEVEL 8 **)
paulson@2133
   601
by (res_inst_tac [("x1","X")] (insert_commute RS ssubst) 1);
paulson@2133
   602
by (simp_tac (!simpset setloop split_tac [expand_if]) 1);
paulson@3121
   603
(*  SLOW: 13s*)
paulson@2377
   604
by (SELECT_GOAL (REPEAT_FIRST (spy_analz_tac ORELSE' Safe_step_tac)) 1);
paulson@2133
   605
by (lost_tac "Aa" 1);
paulson@3121
   606
by (dtac (Says_imp_sees_Spy' RS parts.Inj RS parts.Fst RS A_trusts_YM3) 1);
paulson@2133
   607
by (forward_tac [Says_Server_message_form] 3);
paulson@2133
   608
by (forward_tac [Says_Server_imp_YM2] 4);
paulson@3121
   609
by (REPEAT_FIRST (eresolve_tac [asm_rl, bexE, exE, disjE]));
paulson@3121
   610
(** LEVEL 16 **)
paulson@3121
   611
(*  use unique_NB to identify message components  *)
paulson@2133
   612
by (lost_tac "Ba" 1);
paulson@3121
   613
by (subgoal_tac "Aa=A & Ba=B & NAa=NA" 1);
paulson@3121
   614
by (blast_tac (!claset addSDs [Says_imp_sees_Spy' RS parts.Inj]
paulson@3121
   615
                       addSEs [MPair_parts] addDs [unique_NB]) 2);
paulson@3121
   616
by (blast_tac (!claset addDs [Spy_not_see_encrypted_key,
paulson@3121
   617
			      impOfSubs Fake_analz_insert]
paulson@3121
   618
		       addIs [impOfSubs analz_mono]) 1);
paulson@2516
   619
(** LEVEL 20 **)
paulson@3121
   620
(*Oops case*)
paulson@2133
   621
by (full_simp_tac (!simpset addsimps [all_conj_distrib]) 1);
paulson@2133
   622
by (step_tac (!claset delrules [disjE, conjI]) 1);
paulson@2133
   623
by (forward_tac [Says_Server_imp_YM2] 1 THEN assume_tac 1 THEN etac exE 1);
paulson@2133
   624
by (expand_case_tac "NB = NBa" 1);
paulson@3121
   625
by (blast_tac (!claset addDs [Says_unique_NB']) 1);
paulson@2170
   626
by (rtac conjI 1);
paulson@2133
   627
by (no_nonce_tac 1);
paulson@2516
   628
(** LEVEL 30 **)
paulson@3121
   629
by (blast_tac (!claset addSDs [single_Nonce_secrecy]) 1);
paulson@2133
   630
val Spy_not_see_NB = result() RSN(2,rev_mp) RSN(2,rev_mp) |> standard;
paulson@2133
   631
paulson@2001
   632
paulson@2110
   633
(*What can B deduce from receipt of YM4?  Note how the two components of
paulson@2110
   634
  the message contribute to a single conclusion about the Server's message.
paulson@2110
   635
  It's annoying that the "Says A Spy" assumption must quantify over 
paulson@2133
   636
  ALL POSSIBLE keys instead of our particular K (though at least the
paulson@2133
   637
  nonces are forced to agree with NA and NB). *)
paulson@2001
   638
goal thy 
paulson@2516
   639
 "!!evs. [| Says B Server                                               \
paulson@2284
   640
\            {|Agent B, Crypt (shrK B) {|Agent A, Nonce NA, Nonce NB|}|}  \
paulson@2133
   641
\           : set_of_list evs;       \
paulson@2284
   642
\           Says A' B {|Crypt (shrK B) {|Agent A, Key K|},              \
paulson@2284
   643
\                       Crypt K (Nonce NB)|} : set_of_list evs;         \
paulson@2133
   644
\           ALL k. Says A Spy {|Nonce NA, Nonce NB, k|} ~: set_of_list evs; \
paulson@2133
   645
\           A ~: lost;  B ~: lost;  Spy: lost;  evs : yahalom lost |]   \
paulson@2516
   646
\         ==> Says Server A                                             \
paulson@2516
   647
\                     {|Crypt (shrK A) {|Agent B, Key K,                \
paulson@2516
   648
\                               Nonce NA, Nonce NB|},                   \
paulson@2284
   649
\                       Crypt (shrK B) {|Agent A, Key K|}|}             \
paulson@2001
   650
\                   : set_of_list evs";
paulson@2133
   651
by (forward_tac [Spy_not_see_NB] 1 THEN REPEAT (assume_tac 1));
paulson@3121
   652
by (etac (Says_imp_sees_Spy' RS parts.Inj RS MPair_parts) 1 THEN
paulson@2133
   653
    dtac B_trusts_YM4_shrK 1);
paulson@2170
   654
by (dtac B_trusts_YM4_newK 3);
paulson@2110
   655
by (REPEAT_FIRST (eresolve_tac [asm_rl, exE]));
paulson@2133
   656
by (forward_tac [Says_Server_imp_YM2] 1 THEN assume_tac 1);
paulson@2170
   657
by (dtac unique_session_keys 1 THEN REPEAT (assume_tac 1));
paulson@3121
   658
by (blast_tac (!claset addDs [Says_unique_NB']) 1);
paulson@2322
   659
qed "B_trusts_YM4";