src/HOL/Auth/Yahalom2.ML
author oheimb
Sat Feb 15 17:52:31 1997 +0100 (1997-02-15)
changeset 2637 e9b203f854ae
parent 2516 4d68fbe6378b
child 3121 cbb6c0c1c58a
permissions -rw-r--r--
reflecting my recent changes of the simplifier and classical reasoner
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
oheimb@2637
    20
val op addss = op unsafe_addss;
paulson@2111
    21
paulson@2323
    22
(*A "possibility property": there are traces that reach the end*)
paulson@2111
    23
goal thy 
paulson@2111
    24
 "!!A B. [| A ~= B; A ~= Server; B ~= Server |]   \
paulson@2111
    25
\        ==> EX X NB K. EX evs: yahalom lost.          \
paulson@2284
    26
\               Says A B {|X, Crypt K (Nonce NB)|} : set_of_list evs";
paulson@2111
    27
by (REPEAT (resolve_tac [exI,bexI] 1));
paulson@2516
    28
by (rtac (yahalom.Nil RS yahalom.YM1 RS yahalom.YM2 RS yahalom.YM3 RS 
paulson@2516
    29
          yahalom.YM4) 2);
paulson@2516
    30
by possibility_tac;
paulson@2111
    31
result();
paulson@2111
    32
paulson@2111
    33
paulson@2111
    34
(**** Inductive proofs about yahalom ****)
paulson@2111
    35
paulson@2111
    36
(*Monotonicity*)
paulson@2111
    37
goal thy "!!evs. lost' <= lost ==> yahalom lost' <= yahalom lost";
paulson@2111
    38
by (rtac subsetI 1);
paulson@2111
    39
by (etac yahalom.induct 1);
paulson@2111
    40
by (REPEAT_FIRST
paulson@2111
    41
    (best_tac (!claset addIs (impOfSubs (sees_mono RS analz_mono RS synth_mono)
paulson@2111
    42
                              :: yahalom.intrs))));
paulson@2111
    43
qed "yahalom_mono";
paulson@2111
    44
paulson@2111
    45
paulson@2111
    46
(*Nobody sends themselves messages*)
paulson@2111
    47
goal thy "!!evs. evs: yahalom lost ==> ALL A X. Says A A X ~: set_of_list evs";
paulson@2111
    48
by (etac yahalom.induct 1);
paulson@2111
    49
by (Auto_tac());
paulson@2111
    50
qed_spec_mp "not_Says_to_self";
paulson@2111
    51
Addsimps [not_Says_to_self];
paulson@2111
    52
AddSEs   [not_Says_to_self RSN (2, rev_notE)];
paulson@2111
    53
paulson@2111
    54
paulson@2111
    55
(** For reasoning about the encrypted portion of messages **)
paulson@2111
    56
paulson@2111
    57
(*Lets us treat YM4 using a similar argument as for the Fake case.*)
paulson@2284
    58
goal thy "!!evs. Says S A {|NB, Crypt (shrK A) Y, X|} : set_of_list evs ==> \
paulson@2111
    59
\                X : analz (sees lost Spy evs)";
paulson@2111
    60
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS analz.Inj]) 1);
paulson@2111
    61
qed "YM4_analz_sees_Spy";
paulson@2111
    62
paulson@2111
    63
bind_thm ("YM4_parts_sees_Spy",
paulson@2111
    64
          YM4_analz_sees_Spy RS (impOfSubs analz_subset_parts));
paulson@2111
    65
paulson@2155
    66
(*Relates to both YM4 and Oops*)
paulson@2284
    67
goal thy "!!evs. Says S A {|NB, Crypt (shrK A) {|B, K, NA|}, X|} \
paulson@2111
    68
\                  : set_of_list evs ==> \
paulson@2111
    69
\                K : parts (sees lost Spy evs)";
paulson@2111
    70
by (fast_tac (!claset addSEs partsEs
paulson@2111
    71
                      addSDs [Says_imp_sees_Spy RS parts.Inj]) 1);
paulson@2111
    72
qed "YM4_Key_parts_sees_Spy";
paulson@2111
    73
paulson@2111
    74
(*We instantiate the variable to "lost".  Leaving it as a Var makes proofs
paulson@2111
    75
  harder: the simplifier does less.*)
paulson@2111
    76
val parts_Fake_tac = 
paulson@2111
    77
    forw_inst_tac [("lost","lost")] YM4_parts_sees_Spy 6 THEN
paulson@2111
    78
    forw_inst_tac [("lost","lost")] YM4_Key_parts_sees_Spy 7;
paulson@2111
    79
paulson@2111
    80
(*For proving the easier theorems about X ~: parts (sees lost Spy evs) *)
paulson@2111
    81
fun parts_induct_tac i = SELECT_GOAL
paulson@2111
    82
    (DETERM (etac yahalom.induct 1 THEN parts_Fake_tac THEN
paulson@2170
    83
             (*Fake message*)
paulson@2170
    84
             TRY (best_tac (!claset addDs [impOfSubs analz_subset_parts,
paulson@2170
    85
                                           impOfSubs Fake_parts_insert]
paulson@2111
    86
                                    addss (!simpset)) 2)) THEN
paulson@2111
    87
     (*Base case*)
paulson@2111
    88
     fast_tac (!claset addss (!simpset)) 1 THEN
paulson@2111
    89
     ALLGOALS Asm_simp_tac) i;
paulson@2111
    90
paulson@2111
    91
paulson@2111
    92
(** Theorems of the form X ~: parts (sees lost Spy evs) imply that NOBODY
paulson@2111
    93
    sends messages containing X! **)
paulson@2111
    94
paulson@2516
    95
(*Spy never sees another agent's shared key! (unless it's lost at start)*)
paulson@2111
    96
goal thy 
paulson@2516
    97
 "!!evs. evs : yahalom lost \
paulson@2516
    98
\        ==> (Key (shrK A) : parts (sees lost Spy evs)) = (A : lost)";
paulson@2111
    99
by (parts_induct_tac 1);
paulson@2111
   100
by (Auto_tac());
paulson@2516
   101
qed "Spy_see_shrK";
paulson@2516
   102
Addsimps [Spy_see_shrK];
paulson@2111
   103
paulson@2516
   104
goal thy 
paulson@2516
   105
 "!!evs. evs : yahalom lost \
paulson@2516
   106
\        ==> (Key (shrK A) : analz (sees lost Spy evs)) = (A : lost)";
paulson@2516
   107
by (auto_tac(!claset addDs [impOfSubs analz_subset_parts], !simpset));
paulson@2516
   108
qed "Spy_analz_shrK";
paulson@2516
   109
Addsimps [Spy_analz_shrK];
paulson@2111
   110
paulson@2516
   111
goal thy  "!!A. [| Key (shrK A) : parts (sees lost Spy evs);       \
paulson@2516
   112
\                  evs : yahalom lost |] ==> A:lost";
paulson@2516
   113
by (fast_tac (!claset addDs [Spy_see_shrK]) 1);
paulson@2516
   114
qed "Spy_see_shrK_D";
paulson@2111
   115
paulson@2516
   116
bind_thm ("Spy_analz_shrK_D", analz_subset_parts RS subsetD RS Spy_see_shrK_D);
paulson@2516
   117
AddSDs [Spy_see_shrK_D, Spy_analz_shrK_D];
paulson@2111
   118
paulson@2111
   119
paulson@2516
   120
(*Nobody can have used non-existent keys!*)
paulson@2516
   121
goal thy "!!evs. evs : yahalom lost ==>          \
paulson@2516
   122
\         Key K ~: used evs --> K ~: keysFor (parts (sees lost Spy evs))";
paulson@2111
   123
by (parts_induct_tac 1);
paulson@2516
   124
(*YM4: Key K is not fresh!*)
paulson@2516
   125
by (fast_tac (!claset addSEs sees_Spy_partsEs) 3);
paulson@2516
   126
(*YM3*)
paulson@2516
   127
by (fast_tac (!claset addss (!simpset)) 2);
paulson@2516
   128
(*Fake*)
paulson@2516
   129
by (best_tac
paulson@2516
   130
      (!claset addIs [impOfSubs analz_subset_parts]
paulson@2516
   131
               addDs [impOfSubs (analz_subset_parts RS keysFor_mono),
paulson@2516
   132
                      impOfSubs (parts_insert_subset_Un RS keysFor_mono)]
paulson@2516
   133
               addss (!simpset)) 1);
paulson@2160
   134
qed_spec_mp "new_keys_not_used";
paulson@2111
   135
paulson@2111
   136
bind_thm ("new_keys_not_analzd",
paulson@2111
   137
          [analz_subset_parts RS keysFor_mono,
paulson@2111
   138
           new_keys_not_used] MRS contra_subsetD);
paulson@2111
   139
paulson@2111
   140
Addsimps [new_keys_not_used, new_keys_not_analzd];
paulson@2111
   141
paulson@2111
   142
paulson@2155
   143
(*Describes the form of K when the Server sends this message.  Useful for
paulson@2155
   144
  Oops as well as main secrecy property.*)
paulson@2111
   145
goal thy 
paulson@2516
   146
 "!!evs. [| Says Server A {|NB', Crypt (shrK A) {|Agent B, Key K, NA|}, X|} \
paulson@2155
   147
\            : set_of_list evs;                                         \
paulson@2155
   148
\           evs : yahalom lost |]                                       \
paulson@2516
   149
\        ==> K ~: range shrK & A ~= B";
paulson@2155
   150
by (etac rev_mp 1);
paulson@2155
   151
by (etac yahalom.induct 1);
paulson@2155
   152
by (ALLGOALS (fast_tac (!claset addss (!simpset))));
paulson@2155
   153
qed "Says_Server_message_form";
paulson@2111
   154
paulson@2111
   155
paulson@2111
   156
(*For proofs involving analz.  We again instantiate the variable to "lost".*)
paulson@2111
   157
val analz_Fake_tac = 
paulson@2111
   158
    dres_inst_tac [("lost","lost")] YM4_analz_sees_Spy 6 THEN
paulson@2155
   159
    forw_inst_tac [("lost","lost")] Says_Server_message_form 7 THEN
paulson@2516
   160
    assume_tac 7 THEN
paulson@2516
   161
    REPEAT ((etac conjE ORELSE' hyp_subst_tac) 7);
paulson@2111
   162
paulson@2111
   163
paulson@2111
   164
(****
paulson@2111
   165
 The following is to prove theorems of the form
paulson@2111
   166
paulson@2516
   167
          Key K : analz (insert (Key KAB) (sees lost Spy evs)) ==>
paulson@2111
   168
          Key K : analz (sees lost Spy evs)
paulson@2111
   169
paulson@2111
   170
 A more general formula must be proved inductively.
paulson@2111
   171
paulson@2111
   172
****)
paulson@2111
   173
paulson@2111
   174
(** Session keys are not used to encrypt other session keys **)
paulson@2111
   175
paulson@2111
   176
goal thy  
paulson@2111
   177
 "!!evs. evs : yahalom lost ==> \
paulson@2516
   178
\  ALL K KK. KK <= Compl (range shrK) -->                      \
paulson@2516
   179
\            (Key K : analz (Key``KK Un (sees lost Spy evs))) = \
paulson@2516
   180
\            (K : KK | Key K : analz (sees lost Spy evs))";
paulson@2111
   181
by (etac yahalom.induct 1);
paulson@2111
   182
by analz_Fake_tac;
paulson@2516
   183
by (REPEAT_FIRST (resolve_tac [allI, impI]));
paulson@2516
   184
by (REPEAT_FIRST (rtac analz_image_freshK_lemma ));
paulson@2516
   185
by (ALLGOALS (asm_simp_tac analz_image_freshK_ss));
paulson@2516
   186
(*Base*)
paulson@2516
   187
by (fast_tac (!claset addIs [image_eqI] addss (!simpset)) 1);
paulson@2155
   188
(*YM4, Fake*) 
paulson@2516
   189
by (REPEAT (spy_analz_tac 1));
paulson@2516
   190
qed_spec_mp "analz_image_freshK";
paulson@2111
   191
paulson@2111
   192
goal thy
paulson@2516
   193
 "!!evs. [| evs : yahalom lost;  KAB ~: range shrK |] ==>             \
paulson@2516
   194
\        Key K : analz (insert (Key KAB) (sees lost Spy evs)) = \
paulson@2516
   195
\        (K = KAB | Key K : analz (sees lost Spy evs))";
paulson@2516
   196
by (asm_simp_tac (analz_image_freshK_ss addsimps [analz_image_freshK]) 1);
paulson@2516
   197
qed "analz_insert_freshK";
paulson@2111
   198
paulson@2111
   199
paulson@2111
   200
(*** The Key K uniquely identifies the Server's  message. **)
paulson@2111
   201
paulson@2111
   202
goal thy 
paulson@2111
   203
 "!!evs. evs : yahalom lost ==>                                     \
paulson@2155
   204
\      EX A' B' NA' NB' X'. ALL A B NA NB X.                        \
paulson@2111
   205
\          Says Server A                                            \
paulson@2284
   206
\           {|NB, Crypt (shrK A) {|Agent B, Key K, NA|}, X|}        \
paulson@2155
   207
\          : set_of_list evs --> A=A' & B=B' & NA=NA' & NB=NB' & X=X'";
paulson@2111
   208
by (etac yahalom.induct 1);
paulson@2111
   209
by (ALLGOALS (asm_simp_tac (!simpset addsimps [all_conj_distrib])));
paulson@2111
   210
by (Step_tac 1);
paulson@2111
   211
(*Remaining case: YM3*)
paulson@2111
   212
by (expand_case_tac "K = ?y" 1);
paulson@2111
   213
by (REPEAT (ares_tac [refl,exI,impI,conjI] 2));
paulson@2516
   214
(*...we assume X is a recent message and handle this case by contradiction*)
paulson@2516
   215
by (fast_tac (!claset addSEs sees_Spy_partsEs
paulson@2111
   216
                      delrules [conjI]    (*prevent split-up into 4 subgoals*)
paulson@2111
   217
                      addss (!simpset addsimps [parts_insertI])) 1);
paulson@2111
   218
val lemma = result();
paulson@2111
   219
paulson@2111
   220
goal thy 
paulson@2111
   221
"!!evs. [| Says Server A                                            \
paulson@2284
   222
\           {|NB, Crypt (shrK A) {|Agent B, Key K, NA|}, X|}        \
paulson@2111
   223
\           : set_of_list evs;                                      \
paulson@2111
   224
\          Says Server A'                                           \
paulson@2284
   225
\           {|NB', Crypt (shrK A') {|Agent B', Key K, NA'|}, X'|}   \
paulson@2111
   226
\           : set_of_list evs;                                      \
paulson@2111
   227
\          evs : yahalom lost |]                                    \
paulson@2111
   228
\       ==> A=A' & B=B' & NA=NA' & NB=NB'";
paulson@2451
   229
by (prove_unique_tac lemma 1);
paulson@2111
   230
qed "unique_session_keys";
paulson@2111
   231
paulson@2111
   232
paulson@2111
   233
(** Crucial secrecy property: Spy does not see the keys sent in msg YM3 **)
paulson@2111
   234
paulson@2111
   235
goal thy 
paulson@2155
   236
 "!!evs. [| A ~: lost;  B ~: lost;  A ~= B;                          \
paulson@2155
   237
\           evs : yahalom lost |]            \
paulson@2111
   238
\        ==> Says Server A                                           \
paulson@2284
   239
\              {|NB, Crypt (shrK A) {|Agent B, Key K, NA|},           \
paulson@2284
   240
\                    Crypt (shrK B) {|NB, Key K, Agent A|}|}          \
paulson@2111
   241
\             : set_of_list evs -->                               \
paulson@2155
   242
\            Says A Spy {|NA, NB, Key K|} ~: set_of_list evs -->  \
paulson@2111
   243
\            Key K ~: analz (sees lost Spy evs)";
paulson@2111
   244
by (etac yahalom.induct 1);
paulson@2111
   245
by analz_Fake_tac;
paulson@2111
   246
by (ALLGOALS
paulson@2111
   247
    (asm_simp_tac 
paulson@2516
   248
     (!simpset addsimps [not_parts_not_analz, analz_insert_freshK]
paulson@2111
   249
               setloop split_tac [expand_if])));
paulson@2111
   250
(*YM3*)
paulson@2516
   251
by (fast_tac (!claset delrules [impCE]
paulson@2516
   252
                      addSEs sees_Spy_partsEs
paulson@2516
   253
                      addIs [impOfSubs analz_subset_parts]
paulson@2516
   254
                      addss (!simpset addsimps [parts_insert2])) 2);
paulson@2155
   255
(*OR4, Fake*) 
paulson@2377
   256
by (REPEAT_FIRST spy_analz_tac);
paulson@2155
   257
(*Oops*)
paulson@2111
   258
by (fast_tac (!claset delrules [disjE] 
paulson@2170
   259
                      addDs [unique_session_keys]
paulson@2170
   260
                      addss (!simpset)) 1);
paulson@2111
   261
val lemma = result() RS mp RS mp RSN(2,rev_notE);
paulson@2111
   262
paulson@2111
   263
paulson@2111
   264
(*Final version: Server's message in the most abstract form*)
paulson@2111
   265
goal thy 
paulson@2111
   266
 "!!evs. [| Says Server A                                         \
paulson@2516
   267
\              {|NB, Crypt (shrK A) {|Agent B, Key K, NA|},       \
paulson@2516
   268
\                    Crypt (shrK B) {|NB, Key K, Agent A|}|}      \
paulson@2111
   269
\           : set_of_list evs;                                    \
paulson@2516
   270
\           Says A Spy {|NA, NB, Key K|} ~: set_of_list evs;      \
paulson@2155
   271
\           A ~: lost;  B ~: lost;  evs : yahalom lost |]         \
paulson@2516
   272
\        ==> Key K ~: analz (sees lost Spy evs)";
paulson@2111
   273
by (forward_tac [Says_Server_message_form] 1 THEN assume_tac 1);
paulson@2111
   274
by (fast_tac (!claset addSEs [lemma]) 1);
paulson@2111
   275
qed "Spy_not_see_encrypted_key";
paulson@2111
   276
paulson@2111
   277
paulson@2111
   278
goal thy 
paulson@2155
   279
 "!!evs. [| C ~: {A,B,Server};                                    \
paulson@2111
   280
\           Says Server A                                         \
paulson@2516
   281
\              {|NB, Crypt (shrK A) {|Agent B, Key K, NA|},       \
paulson@2516
   282
\                    Crypt (shrK B) {|NB, Key K, Agent A|}|}      \
paulson@2111
   283
\           : set_of_list evs;                                    \
paulson@2516
   284
\           Says A Spy {|NA, NB, Key K|} ~: set_of_list evs;      \
paulson@2155
   285
\           A ~: lost;  B ~: lost;  evs : yahalom lost |]         \
paulson@2516
   286
\        ==> Key K ~: analz (sees lost C evs)";
paulson@2111
   287
by (rtac (subset_insertI RS sees_mono RS analz_mono RS contra_subsetD) 1);
paulson@2111
   288
by (rtac (sees_lost_agent_subset_sees_Spy RS analz_mono RS contra_subsetD) 1);
paulson@2111
   289
by (FIRSTGOAL (rtac Spy_not_see_encrypted_key));
paulson@2111
   290
by (REPEAT_FIRST (fast_tac (!claset addIs [yahalom_mono RS subsetD])));
paulson@2111
   291
qed "Agent_not_see_encrypted_key";
paulson@2111
   292
paulson@2111
   293
paulson@2155
   294
(*** Security Guarantees for A and B ***)
paulson@2155
   295
paulson@2155
   296
(*If the encrypted message appears then it originated with the Server.*)
paulson@2155
   297
goal thy
paulson@2284
   298
 "!!evs. [| Crypt (shrK A) {|Agent B, Key K, NA|}                \
paulson@2155
   299
\            : parts (sees lost Spy evs);                              \
paulson@2155
   300
\           A ~: lost;  evs : yahalom lost |]                          \
paulson@2155
   301
\         ==> EX NB. Says Server A                                     \
paulson@2284
   302
\                      {|NB, Crypt (shrK A) {|Agent B, Key K, NA|},    \
paulson@2284
   303
\                            Crypt (shrK B) {|NB, Key K, Agent A|}|}   \
paulson@2155
   304
\                    : set_of_list evs";
paulson@2155
   305
by (etac rev_mp 1);
paulson@2155
   306
by (parts_induct_tac 1);
paulson@2155
   307
(*The nested conjunctions are entirely useless*)
paulson@2155
   308
by (REPEAT_FIRST (rtac conjI ORELSE' fast_tac (!claset delrules [conjI])));
paulson@2323
   309
qed "A_trusts_YM3";
paulson@2155
   310
paulson@2111
   311
paulson@2111
   312
(*B knows, by the first part of A's message, that the Server distributed 
paulson@2155
   313
  the key for A and B. *)
paulson@2111
   314
goal thy 
paulson@2284
   315
 "!!evs. [| Crypt (shrK B) {|Nonce NB, Key K, Agent A|}              \
paulson@2155
   316
\            : parts (sees lost Spy evs);                            \
paulson@2155
   317
\           B ~: lost;  evs : yahalom lost |]                        \
paulson@2111
   318
\        ==> EX NA. Says Server A                                    \
paulson@2155
   319
\                    {|Nonce NB,                                     \
paulson@2284
   320
\                      Crypt (shrK A) {|Agent B, Key K, Nonce NA|},  \
paulson@2284
   321
\                      Crypt (shrK B) {|Nonce NB, Key K, Agent A|}|} \
paulson@2111
   322
\                       : set_of_list evs";
paulson@2111
   323
by (etac rev_mp 1);
paulson@2111
   324
by (parts_induct_tac 1);
paulson@2111
   325
(*YM3*)
paulson@2111
   326
by (Fast_tac 1);
paulson@2111
   327
qed "B_trusts_YM4_shrK";
paulson@2111
   328
paulson@2111
   329
(*With this variant we don't bother to use the 2nd part of YM4 at all, since
paulson@2111
   330
  Nonce NB is available in the first part.  However the 2nd part does assure B
paulson@2111
   331
  of A's existence.*)
paulson@2111
   332
paulson@2155
   333
(*What can B deduce from receipt of YM4?  Stronger and simpler than Yahalom
paulson@2155
   334
  because we do not have to show that NB is secret. *)
paulson@2111
   335
goal thy 
paulson@2284
   336
 "!!evs. [| Says A' B {|Crypt (shrK B) {|Nonce NB, Key K, Agent A|},    \
paulson@2284
   337
\                       Crypt K (Nonce NB)|} : set_of_list evs;         \
paulson@2111
   338
\           A ~: lost;  B ~: lost;  evs : yahalom lost |]               \
paulson@2111
   339
\        ==> EX NA. Says Server A                                       \
paulson@2155
   340
\                    {|Nonce NB,                                        \
paulson@2284
   341
\                      Crypt (shrK A) {|Agent B, Key K, Nonce NA|},     \
paulson@2284
   342
\                      Crypt (shrK B) {|Nonce NB, Key K, Agent A|}|}    \
paulson@2111
   343
\                   : set_of_list evs";
paulson@2170
   344
by (etac (Says_imp_sees_Spy RS parts.Inj RS MPair_parts) 1);
paulson@2111
   345
by (fast_tac (!claset addSDs [B_trusts_YM4_shrK]) 1);
paulson@2323
   346
qed "B_trusts_YM4";