src/HOL/Auth/OtwayRees_AN.ML
author paulson
Thu Oct 10 18:40:34 1996 +0200 (1996-10-10)
changeset 2090 307ebbbec862
child 2106 1a52e2c5897e
permissions -rw-r--r--
Abadi and Needham's variant of Otway-Rees
paulson@2090
     1
(*  Title:      HOL/Auth/OtwayRees
paulson@2090
     2
    ID:         $Id$
paulson@2090
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@2090
     4
    Copyright   1996  University of Cambridge
paulson@2090
     5
paulson@2090
     6
Inductive relation "otway" for the Otway-Rees protocol.
paulson@2090
     7
paulson@2090
     8
Simplified version with minimal encryption but explicit messages
paulson@2090
     9
paulson@2090
    10
From page 11 of
paulson@2090
    11
  Abadi and Needham.  Prudent Engineering Practice for Cryptographic Protocols.
paulson@2090
    12
  IEEE Trans. SE 22 (1), 1996
paulson@2090
    13
*)
paulson@2090
    14
paulson@2090
    15
open OtwayRees_AN;
paulson@2090
    16
paulson@2090
    17
proof_timing:=true;
paulson@2090
    18
HOL_quantifiers := false;
paulson@2090
    19
paulson@2090
    20
paulson@2090
    21
(*Weak liveness: there are traces that reach the end*)
paulson@2090
    22
goal thy 
paulson@2090
    23
 "!!A B. [| A ~= B; A ~= Server; B ~= Server |]   \
paulson@2090
    24
\        ==> EX K. EX NA. EX evs: otway lost.          \
paulson@2090
    25
\             Says B A (Crypt {|Nonce NA, Agent A, Agent B, Key K|} (shrK A)) \
paulson@2090
    26
\             : set_of_list evs";
paulson@2090
    27
by (REPEAT (resolve_tac [exI,bexI] 1));
paulson@2090
    28
by (rtac (otway.Nil RS otway.OR1 RS otway.OR2 RS otway.OR3 RS otway.OR4) 2);
paulson@2090
    29
by (ALLGOALS (simp_tac (!simpset setsolver safe_solver)));
paulson@2090
    30
by (REPEAT_FIRST (resolve_tac [refl, conjI]));
paulson@2090
    31
by (REPEAT_FIRST (fast_tac (!claset addss (!simpset setsolver safe_solver))));
paulson@2090
    32
result();
paulson@2090
    33
paulson@2090
    34
paulson@2090
    35
(**** Inductive proofs about otway ****)
paulson@2090
    36
paulson@2090
    37
goal thy "!!evs. lost' <= lost ==> otway lost' <= otway lost";
paulson@2090
    38
by (rtac subsetI 1);
paulson@2090
    39
by (etac otway.induct 1);
paulson@2090
    40
by (REPEAT_FIRST
paulson@2090
    41
    (best_tac (!claset addIs (impOfSubs (sees_mono RS analz_mono RS synth_mono)
paulson@2090
    42
                              :: otway.intrs))));
paulson@2090
    43
qed "otway_mono";
paulson@2090
    44
paulson@2090
    45
(*Nobody sends themselves messages*)
paulson@2090
    46
goal thy "!!evs. evs : otway lost ==> ALL A X. Says A A X ~: set_of_list evs";
paulson@2090
    47
by (etac otway.induct 1);
paulson@2090
    48
by (Auto_tac());
paulson@2090
    49
qed_spec_mp "not_Says_to_self";
paulson@2090
    50
Addsimps [not_Says_to_self];
paulson@2090
    51
AddSEs   [not_Says_to_self RSN (2, rev_notE)];
paulson@2090
    52
paulson@2090
    53
paulson@2090
    54
(** For reasoning about the encrypted portion of messages **)
paulson@2090
    55
paulson@2090
    56
goal thy "!!evs. Says S B {|X, X'|} : set_of_list evs ==> \
paulson@2090
    57
\                X : analz (sees lost Spy evs)";
paulson@2090
    58
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS analz.Inj]) 1);
paulson@2090
    59
qed "OR4_analz_sees_Spy";
paulson@2090
    60
paulson@2090
    61
goal thy "!!evs. Says B' A (Crypt {|N,Agent A,B,K|} K') : set_of_list evs ==> \
paulson@2090
    62
\                K : parts (sees lost Spy evs)";
paulson@2090
    63
by (fast_tac (!claset addSEs partsEs
paulson@2090
    64
                      addSDs [Says_imp_sees_Spy RS parts.Inj]) 1);
paulson@2090
    65
qed "Reveal_parts_sees_Spy";
paulson@2090
    66
paulson@2090
    67
(*OR2_analz... and OR4_analz... let us treat those cases using the same 
paulson@2090
    68
  argument as for the Fake case.  This is possible for most, but not all,
paulson@2090
    69
  proofs: Fake does not invent new nonces (as in OR2), and of course Fake
paulson@2090
    70
  messages originate from the Spy. *)
paulson@2090
    71
paulson@2090
    72
bind_thm ("OR4_parts_sees_Spy",
paulson@2090
    73
          OR4_analz_sees_Spy RS (impOfSubs analz_subset_parts));
paulson@2090
    74
paulson@2090
    75
(*We instantiate the variable to "lost".  Leaving it as a Var makes proofs
paulson@2090
    76
  harder to complete, since simplification does less for us.*)
paulson@2090
    77
val parts_Fake_tac = 
paulson@2090
    78
    forw_inst_tac [("lost","lost")] OR4_parts_sees_Spy 6 THEN
paulson@2090
    79
    forw_inst_tac [("lost","lost")] Reveal_parts_sees_Spy 7;
paulson@2090
    80
paulson@2090
    81
(*For proving the easier theorems about X ~: parts (sees lost Spy evs) *)
paulson@2090
    82
fun parts_induct_tac i = SELECT_GOAL
paulson@2090
    83
    (DETERM (etac otway.induct 1 THEN parts_Fake_tac THEN
paulson@2090
    84
	     (*Fake message*)
paulson@2090
    85
	     TRY (best_tac (!claset addDs [impOfSubs analz_subset_parts,
paulson@2090
    86
					   impOfSubs Fake_parts_insert]
paulson@2090
    87
                                    addss (!simpset)) 2)) THEN
paulson@2090
    88
     (*Base case*)
paulson@2090
    89
     fast_tac (!claset addss (!simpset)) 1 THEN
paulson@2090
    90
     ALLGOALS Asm_simp_tac) i;
paulson@2090
    91
paulson@2090
    92
(** Theorems of the form X ~: parts (sees lost Spy evs) imply that NOBODY
paulson@2090
    93
    sends messages containing X! **)
paulson@2090
    94
paulson@2090
    95
(*Spy never sees another agent's shared key! (unless it's lost at start)*)
paulson@2090
    96
goal thy 
paulson@2090
    97
 "!!evs. [| evs : otway lost;  A ~: lost |]    \
paulson@2090
    98
\        ==> Key (shrK A) ~: parts (sees lost Spy evs)";
paulson@2090
    99
by (parts_induct_tac 1);
paulson@2090
   100
by (Auto_tac());
paulson@2090
   101
qed "Spy_not_see_shrK";
paulson@2090
   102
paulson@2090
   103
bind_thm ("Spy_not_analz_shrK",
paulson@2090
   104
          [analz_subset_parts, Spy_not_see_shrK] MRS contra_subsetD);
paulson@2090
   105
paulson@2090
   106
Addsimps [Spy_not_see_shrK, Spy_not_analz_shrK];
paulson@2090
   107
paulson@2090
   108
(*We go to some trouble to preserve R in the 3rd and 4th subgoals
paulson@2090
   109
  As usual fast_tac cannot be used because it uses the equalities too soon*)
paulson@2090
   110
val major::prems = 
paulson@2090
   111
goal thy  "[| Key (shrK A) : parts (sees lost Spy evs);       \
paulson@2090
   112
\             evs : otway lost;                                 \
paulson@2090
   113
\             A:lost ==> R                                  \
paulson@2090
   114
\           |] ==> R";
paulson@2090
   115
by (rtac ccontr 1);
paulson@2090
   116
by (rtac ([major, Spy_not_see_shrK] MRS rev_notE) 1);
paulson@2090
   117
by (swap_res_tac prems 2);
paulson@2090
   118
by (ALLGOALS (fast_tac (!claset addIs prems)));
paulson@2090
   119
qed "Spy_see_shrK_E";
paulson@2090
   120
paulson@2090
   121
bind_thm ("Spy_analz_shrK_E", 
paulson@2090
   122
          analz_subset_parts RS subsetD RS Spy_see_shrK_E);
paulson@2090
   123
paulson@2090
   124
AddSEs [Spy_see_shrK_E, Spy_analz_shrK_E];
paulson@2090
   125
paulson@2090
   126
paulson@2090
   127
(*** Future keys can't be seen or used! ***)
paulson@2090
   128
paulson@2090
   129
(*Nobody can have SEEN keys that will be generated in the future.
paulson@2090
   130
  This has to be proved anew for each protocol description,
paulson@2090
   131
  but should go by similar reasoning every time.  Hardest case is the
paulson@2090
   132
  standard Fake rule.  
paulson@2090
   133
      The Union over C is essential for the induction! *)
paulson@2090
   134
goal thy "!!evs. evs : otway lost ==> \
paulson@2090
   135
\                length evs <= length evs' --> \
paulson@2090
   136
\                          Key (newK evs') ~: (UN C. parts (sees lost C evs))";
paulson@2090
   137
by (parts_induct_tac 1);
paulson@2090
   138
by (REPEAT_FIRST (best_tac (!claset addDs [impOfSubs analz_subset_parts,
paulson@2090
   139
                                           impOfSubs parts_insert_subset_Un,
paulson@2090
   140
                                           Suc_leD]
paulson@2090
   141
                                    addss (!simpset))));
paulson@2090
   142
val lemma = result();
paulson@2090
   143
paulson@2090
   144
(*Variant needed for the main theorem below*)
paulson@2090
   145
goal thy 
paulson@2090
   146
 "!!evs. [| evs : otway lost;  length evs <= length evs' |]    \
paulson@2090
   147
\        ==> Key (newK evs') ~: parts (sees lost C evs)";
paulson@2090
   148
by (fast_tac (!claset addDs [lemma]) 1);
paulson@2090
   149
qed "new_keys_not_seen";
paulson@2090
   150
Addsimps [new_keys_not_seen];
paulson@2090
   151
paulson@2090
   152
(*Another variant: old messages must contain old keys!*)
paulson@2090
   153
goal thy 
paulson@2090
   154
 "!!evs. [| Says A B X : set_of_list evs;  \
paulson@2090
   155
\           Key (newK evt) : parts {X};    \
paulson@2090
   156
\           evs : otway lost                 \
paulson@2090
   157
\        |] ==> length evt < length evs";
paulson@2090
   158
by (rtac ccontr 1);
paulson@2090
   159
by (dtac leI 1);
paulson@2090
   160
by (fast_tac (!claset addSDs [new_keys_not_seen, Says_imp_sees_Spy]
paulson@2090
   161
                      addIs  [impOfSubs parts_mono]) 1);
paulson@2090
   162
qed "Says_imp_old_keys";
paulson@2090
   163
paulson@2090
   164
paulson@2090
   165
(*** Future nonces can't be seen or used! [proofs resemble those above] ***)
paulson@2090
   166
paulson@2090
   167
goal thy "!!evs. evs : otway lost ==> \
paulson@2090
   168
\                length evs <= length evt --> \
paulson@2090
   169
\                Nonce (newN evt) ~: (UN C. parts (sees lost C evs))";
paulson@2090
   170
by (etac otway.induct 1);
paulson@2090
   171
(*auto_tac does not work here, as it performs safe_tac first*)
paulson@2090
   172
by (ALLGOALS (asm_simp_tac (!simpset addsimps [parts_insert2]
paulson@2090
   173
                                     addcongs [disj_cong])));
paulson@2090
   174
by (REPEAT_FIRST (fast_tac (!claset 
paulson@2090
   175
                              addSEs partsEs
paulson@2090
   176
                              addSDs  [Says_imp_sees_Spy RS parts.Inj]
paulson@2090
   177
                              addDs  [impOfSubs analz_subset_parts,
paulson@2090
   178
                                      impOfSubs parts_insert_subset_Un,
paulson@2090
   179
                                      Suc_leD]
paulson@2090
   180
                              addss (!simpset))));
paulson@2090
   181
val lemma = result();
paulson@2090
   182
paulson@2090
   183
(*Variant needed for the main theorem below*)
paulson@2090
   184
goal thy 
paulson@2090
   185
 "!!evs. [| evs : otway lost;  length evs <= length evs' |]    \
paulson@2090
   186
\        ==> Nonce (newN evs') ~: parts (sees lost C evs)";
paulson@2090
   187
by (fast_tac (!claset addDs [lemma]) 1);
paulson@2090
   188
qed "new_nonces_not_seen";
paulson@2090
   189
Addsimps [new_nonces_not_seen];
paulson@2090
   190
paulson@2090
   191
(*Another variant: old messages must contain old nonces!*)
paulson@2090
   192
goal thy 
paulson@2090
   193
 "!!evs. [| Says A B X : set_of_list evs;  \
paulson@2090
   194
\           Nonce (newN evt) : parts {X};    \
paulson@2090
   195
\           evs : otway lost                 \
paulson@2090
   196
\        |] ==> length evt < length evs";
paulson@2090
   197
by (rtac ccontr 1);
paulson@2090
   198
by (dtac leI 1);
paulson@2090
   199
by (fast_tac (!claset addSDs [new_nonces_not_seen, Says_imp_sees_Spy]
paulson@2090
   200
                      addIs  [impOfSubs parts_mono]) 1);
paulson@2090
   201
qed "Says_imp_old_nonces";
paulson@2090
   202
paulson@2090
   203
paulson@2090
   204
(*Nobody can have USED keys that will be generated in the future.
paulson@2090
   205
  ...very like new_keys_not_seen*)
paulson@2090
   206
goal thy "!!evs. evs : otway lost ==> \
paulson@2090
   207
\                length evs <= length evs' --> \
paulson@2090
   208
\                newK evs' ~: keysFor (UN C. parts (sees lost C evs))";
paulson@2090
   209
by (parts_induct_tac 1);
paulson@2090
   210
(*OR1 and OR3*)
paulson@2090
   211
by (EVERY (map (fast_tac (!claset addDs [Suc_leD] addss (!simpset))) [4,2]));
paulson@2090
   212
(*Fake, OR2, OR4: these messages send unknown (X) components*)
paulson@2090
   213
by (EVERY 
paulson@2090
   214
    (map
paulson@2090
   215
     (best_tac
paulson@2090
   216
      (!claset addDs [impOfSubs (analz_subset_parts RS keysFor_mono),
paulson@2090
   217
                      impOfSubs (parts_insert_subset_Un RS keysFor_mono),
paulson@2090
   218
                      Suc_leD]
paulson@2090
   219
               addEs [new_keys_not_seen RS not_parts_not_analz RSN(2,rev_notE)]
paulson@2090
   220
               addss (!simpset)))
paulson@2090
   221
     [3,2,1]));
paulson@2090
   222
(*Reveal: dummy message*)
paulson@2090
   223
by (best_tac (!claset addEs  [new_keys_not_seen RSN(2,rev_notE)]
paulson@2090
   224
                      addIs  [less_SucI, impOfSubs keysFor_mono]
paulson@2090
   225
                      addss (!simpset addsimps [le_def])) 1);
paulson@2090
   226
val lemma = result();
paulson@2090
   227
paulson@2090
   228
goal thy 
paulson@2090
   229
 "!!evs. [| evs : otway lost;  length evs <= length evs' |]    \
paulson@2090
   230
\        ==> newK evs' ~: keysFor (parts (sees lost C evs))";
paulson@2090
   231
by (fast_tac (!claset addSDs [lemma] addss (!simpset)) 1);
paulson@2090
   232
qed "new_keys_not_used";
paulson@2090
   233
paulson@2090
   234
bind_thm ("new_keys_not_analzd",
paulson@2090
   235
          [analz_subset_parts RS keysFor_mono,
paulson@2090
   236
           new_keys_not_used] MRS contra_subsetD);
paulson@2090
   237
paulson@2090
   238
Addsimps [new_keys_not_used, new_keys_not_analzd];
paulson@2090
   239
paulson@2090
   240
paulson@2090
   241
paulson@2090
   242
(*** Proofs involving analz ***)
paulson@2090
   243
paulson@2090
   244
(*Describes the form of Key K when the following message is sent.  The use of
paulson@2090
   245
  "parts" strengthens the induction hyp for proving the Fake case.  The
paulson@2090
   246
  assumption A ~: lost prevents its being a Faked message.  (Based
paulson@2090
   247
  on NS_Shared/Says_S_message_form) *)
paulson@2090
   248
goal thy
paulson@2090
   249
 "!!evs. evs: otway lost ==>                                           \
paulson@2090
   250
\        Crypt {|N, Agent A, B, Key K|} (shrK A) : parts (sees lost Spy evs)  \
paulson@2090
   251
\        --> A ~: lost --> (EX evt: otway lost. K = newK evt)";
paulson@2090
   252
by (parts_induct_tac 1);
paulson@2090
   253
by (Auto_tac());
paulson@2090
   254
qed_spec_mp "Reveal_message_lemma";
paulson@2090
   255
paulson@2090
   256
(*EITHER describes the form of Key K when the following message is sent, 
paulson@2090
   257
  OR     reduces it to the Fake case.*)
paulson@2090
   258
paulson@2090
   259
goal thy 
paulson@2090
   260
 "!!evs. [| Says B' A (Crypt {|N, Agent A, B, Key K|} (shrK A)) \
paulson@2090
   261
\            : set_of_list evs;                                 \
paulson@2090
   262
\           evs : otway lost |]                                 \
paulson@2090
   263
\        ==> (EX evt: otway lost. K = newK evt)                 \
paulson@2090
   264
\          | Key K : analz (sees lost Spy evs)";
paulson@2090
   265
br (Reveal_message_lemma RS disjCI) 1;
paulson@2090
   266
ba 1;
paulson@2090
   267
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS analz.Inj]
paulson@2090
   268
                      addDs [impOfSubs analz_subset_parts]) 1);
paulson@2090
   269
by (fast_tac (!claset addSDs [Says_Crypt_lost]) 1);
paulson@2090
   270
qed "Reveal_message_form";
paulson@2090
   271
paulson@2090
   272
paulson@2090
   273
(*For proofs involving analz.  We again instantiate the variable to "lost".*)
paulson@2090
   274
val analz_Fake_tac = 
paulson@2090
   275
    dres_inst_tac [("lost","lost")] OR4_analz_sees_Spy 6 THEN
paulson@2090
   276
    forw_inst_tac [("lost","lost")] Reveal_message_form 7;
paulson@2090
   277
paulson@2090
   278
paulson@2090
   279
(****
paulson@2090
   280
 The following is to prove theorems of the form
paulson@2090
   281
paulson@2090
   282
          Key K : analz (insert (Key (newK evt)) (sees lost Spy evs)) ==>
paulson@2090
   283
          Key K : analz (sees lost Spy evs)
paulson@2090
   284
paulson@2090
   285
 A more general formula must be proved inductively.
paulson@2090
   286
paulson@2090
   287
****)
paulson@2090
   288
paulson@2090
   289
paulson@2090
   290
(*NOT useful in this form, but it says that session keys are not used
paulson@2090
   291
  to encrypt messages containing other keys, in the actual protocol.
paulson@2090
   292
  We require that agents should behave like this subsequently also.*)
paulson@2090
   293
goal thy 
paulson@2090
   294
 "!!evs. evs : otway lost ==> \
paulson@2090
   295
\        (Crypt X (newK evt)) : parts (sees lost Spy evs) & \
paulson@2090
   296
\        Key K : parts {X} --> Key K : parts (sees lost Spy evs)";
paulson@2090
   297
by (etac otway.induct 1);
paulson@2090
   298
by parts_Fake_tac;
paulson@2090
   299
by (ALLGOALS Asm_simp_tac);
paulson@2090
   300
(*Deals with Faked messages*)
paulson@2090
   301
by (best_tac (!claset addSEs partsEs
paulson@2090
   302
                      addDs [impOfSubs parts_insert_subset_Un]
paulson@2090
   303
                      addss (!simpset)) 2);
paulson@2090
   304
(*Base case and Reveal*)
paulson@2090
   305
by (Auto_tac());
paulson@2090
   306
result();
paulson@2090
   307
paulson@2090
   308
paulson@2090
   309
(** Session keys are not used to encrypt other session keys **)
paulson@2090
   310
paulson@2090
   311
(*The equality makes the induction hypothesis easier to apply*)
paulson@2090
   312
goal thy  
paulson@2090
   313
 "!!evs. evs : otway lost ==> \
paulson@2090
   314
\  ALL K E. (Key K : analz (Key``(newK``E) Un (sees lost Spy evs))) = \
paulson@2090
   315
\           (K : newK``E | Key K : analz (sees lost Spy evs))";
paulson@2090
   316
by (etac otway.induct 1);
paulson@2090
   317
by analz_Fake_tac;
paulson@2090
   318
by (REPEAT_FIRST (ares_tac [allI, analz_image_newK_lemma]));
paulson@2090
   319
by (REPEAT ((eresolve_tac [bexE, disjE] ORELSE' hyp_subst_tac) 7));
paulson@2090
   320
by (ALLGOALS (*Takes 28 secs*)
paulson@2090
   321
    (asm_simp_tac 
paulson@2090
   322
     (!simpset addsimps ([insert_Key_singleton, insert_Key_image, pushKey_newK]
paulson@2090
   323
                         @ pushes)
paulson@2090
   324
               setloop split_tac [expand_if])));
paulson@2090
   325
(** LEVEL 5 **)
paulson@2090
   326
(*Reveal case 2, OR4, OR2, Fake*) 
paulson@2090
   327
by (EVERY (map spy_analz_tac [6, 4, 2]));
paulson@2090
   328
(*Reveal case 1, OR3, Base*)
paulson@2090
   329
by (REPEAT (fast_tac (!claset addIs [image_eqI] addss (!simpset)) 1));
paulson@2090
   330
qed_spec_mp "analz_image_newK";
paulson@2090
   331
paulson@2090
   332
paulson@2090
   333
goal thy
paulson@2090
   334
 "!!evs. evs : otway lost ==>                               \
paulson@2090
   335
\        Key K : analz (insert (Key (newK evt)) (sees lost Spy evs)) = \
paulson@2090
   336
\        (K = newK evt | Key K : analz (sees lost Spy evs))";
paulson@2090
   337
by (asm_simp_tac (HOL_ss addsimps [pushKey_newK, analz_image_newK, 
paulson@2090
   338
                                   insert_Key_singleton]) 1);
paulson@2090
   339
by (Fast_tac 1);
paulson@2090
   340
qed "analz_insert_Key_newK";
paulson@2090
   341
paulson@2090
   342
paulson@2090
   343
(*** The Key K uniquely identifies the Server's  message. **)
paulson@2090
   344
paulson@2090
   345
fun ex_strip_tac i = REPEAT (ares_tac [exI, conjI] i) THEN assume_tac (i+1);
paulson@2090
   346
paulson@2090
   347
goal thy 
paulson@2090
   348
 "!!evs. evs : otway lost ==>                      \
paulson@2090
   349
\      EX A' B' NA' NB'. ALL A B NA NB.                    \
paulson@2090
   350
\       Says Server B \
paulson@2090
   351
\         {|Crypt {|NA, Agent A, Agent B, K|} (shrK A),                    \
paulson@2090
   352
\           Crypt {|NB, Agent A, Agent B, K|} (shrK B)|} : set_of_list evs  \
paulson@2090
   353
\       --> A=A' & B=B' & NA=NA' & NB=NB'";
paulson@2090
   354
by (etac otway.induct 1);
paulson@2090
   355
by (ALLGOALS (asm_simp_tac (!simpset addsimps [all_conj_distrib])));
paulson@2090
   356
by (Step_tac 1);
paulson@2090
   357
(*Remaining cases: OR3 and OR4*)
paulson@2090
   358
by (ex_strip_tac 2);
paulson@2090
   359
by (Fast_tac 2);
paulson@2090
   360
by (expand_case_tac "K = ?y" 1);
paulson@2090
   361
by (REPEAT (ares_tac [refl,exI,impI,conjI] 2));
paulson@2090
   362
(*...we assume X is a very new message, and handle this case by contradiction*)
paulson@2090
   363
by (fast_tac (!claset addEs [Says_imp_old_keys RS less_irrefl]
paulson@2090
   364
                      delrules [conjI]    (*prevent split-up into 4 subgoals*)
paulson@2090
   365
                      addss (!simpset addsimps [parts_insertI])) 1);
paulson@2090
   366
val lemma = result();
paulson@2090
   367
paulson@2090
   368
paulson@2090
   369
goal thy 
paulson@2090
   370
"!!evs. [| Says Server B                                           \
paulson@2090
   371
\            {|Crypt {|NA, Agent A, Agent B, K|} (shrK A),         \
paulson@2090
   372
\              Crypt {|NB, Agent A, Agent B, K|} (shrK B)|}        \
paulson@2090
   373
\           : set_of_list evs;                                     \
paulson@2090
   374
\          Says Server B'                                          \
paulson@2090
   375
\            {|Crypt {|NA', Agent A', Agent B', K|} (shrK A'),     \
paulson@2090
   376
\              Crypt {|NB', Agent A', Agent B', K|} (shrK B')|}    \
paulson@2090
   377
\           : set_of_list evs;                                     \
paulson@2090
   378
\          evs : otway lost |]                                     \
paulson@2090
   379
\       ==> A=A' & B=B' & NA=NA' & NB=NB'";
paulson@2090
   380
by (dtac lemma 1);
paulson@2090
   381
by (REPEAT (etac exE 1));
paulson@2090
   382
(*Duplicate the assumption*)
paulson@2090
   383
by (forw_inst_tac [("psi", "ALL C.?P(C)")] asm_rl 1);
paulson@2090
   384
by (fast_tac (!claset addSDs [spec]) 1);
paulson@2090
   385
qed "unique_session_keys";
paulson@2090
   386
paulson@2090
   387
paulson@2090
   388
paulson@2090
   389
(**** Authenticity properties relating to NA ****)
paulson@2090
   390
paulson@2090
   391
(*If the encrypted message appears then it originated with the Server!*)
paulson@2090
   392
goal thy 
paulson@2090
   393
 "!!evs. [| A ~: lost;  evs : otway lost |]                 \
paulson@2090
   394
\ ==> Crypt {|NA, Agent A, Agent B, Key K|} (shrK A)        \
paulson@2090
   395
\      : parts (sees lost Spy evs)                          \
paulson@2090
   396
\     --> (EX NB. Says Server B                                     \
paulson@2090
   397
\                  {|Crypt {|NA, Agent A, Agent B, Key K|} (shrK A),     \
paulson@2090
   398
\                    Crypt {|NB, Agent A, Agent B, Key K|} (shrK B)|}    \
paulson@2090
   399
\                  : set_of_list evs)";
paulson@2090
   400
by (parts_induct_tac 1);
paulson@2090
   401
by (ALLGOALS (asm_simp_tac (!simpset addsimps [ex_disj_distrib])));
paulson@2090
   402
(*OR3*)
paulson@2090
   403
by (Fast_tac 1);
paulson@2090
   404
qed_spec_mp "NA_Crypt_imp_Server_msg";
paulson@2090
   405
paulson@2090
   406
paulson@2090
   407
(*Corollary: if A receives B's OR4 message and the nonce NA agrees
paulson@2090
   408
  then the key really did come from the Server!  CANNOT prove this of the
paulson@2090
   409
  bad form of this protocol, even though we can prove
paulson@2090
   410
  Spy_not_see_encrypted_key*)
paulson@2090
   411
goal thy 
paulson@2090
   412
 "!!evs. [| Says B' A (Crypt {|NA, Agent A, Agent B, Key K|} (shrK A))  \
paulson@2090
   413
\            : set_of_list evs;                                         \
paulson@2090
   414
\           A ~: lost;  evs : otway lost |]                             \
paulson@2090
   415
\        ==> EX NB. Says Server B                                       \
paulson@2090
   416
\                    {|Crypt {|NA, Agent A, Agent B, Key K|} (shrK A),  \
paulson@2090
   417
\                      Crypt {|NB, Agent A, Agent B, Key K|} (shrK B)|} \
paulson@2090
   418
\                   : set_of_list evs";
paulson@2090
   419
by (fast_tac (!claset addSIs [NA_Crypt_imp_Server_msg]
paulson@2090
   420
                      addEs  partsEs
paulson@2090
   421
                      addDs  [Says_imp_sees_Spy RS parts.Inj]) 1);
paulson@2090
   422
qed "A_trust_OR4";
paulson@2090
   423
paulson@2090
   424
paulson@2090
   425
(*Describes the form of K and NA when the Server sends this message.*)
paulson@2090
   426
goal thy 
paulson@2090
   427
 "!!evs. [| Says Server B \
paulson@2090
   428
\           {|Crypt {|NA, Agent A, Agent B, K|} (shrK A),                    \
paulson@2090
   429
\             Crypt {|NB, Agent A, Agent B, K|} (shrK B)|} : set_of_list evs; \
paulson@2090
   430
\           evs : otway lost |]                                        \
paulson@2090
   431
\        ==> (EX evt: otway lost. K = Key(newK evt)) &                  \
paulson@2090
   432
\            (EX i. NA = Nonce i) &                  \
paulson@2090
   433
\            (EX j. NB = Nonce j)";
paulson@2090
   434
by (etac rev_mp 1);
paulson@2090
   435
by (etac otway.induct 1);
paulson@2090
   436
by (ALLGOALS (fast_tac (!claset addss (!simpset))));
paulson@2090
   437
qed "Says_Server_message_form";
paulson@2090
   438
paulson@2090
   439
paulson@2090
   440
(** Crucial secrecy property: Spy does not see the keys sent in msg OR3
paulson@2090
   441
    Does not in itself guarantee security: an attack could violate 
paulson@2090
   442
    the premises, e.g. by having A=Spy **)
paulson@2090
   443
paulson@2090
   444
goal thy 
paulson@2090
   445
 "!!evs. [| A ~: lost;  B ~: lost;  evs : otway lost;  evt : otway lost |] \
paulson@2090
   446
\        ==> Says Server B                                                 \
paulson@2090
   447
\             {|Crypt {|NA, Agent A, Agent B, Key K|} (shrK A),            \
paulson@2090
   448
\               Crypt {|NB, Agent A, Agent B, Key K|} (shrK B)|}           \
paulson@2090
   449
\            : set_of_list evs -->                                         \
paulson@2090
   450
\            Says A Spy {|NA, Key K|} ~: set_of_list evs -->               \
paulson@2090
   451
\            Key K ~: analz (sees lost Spy evs)";
paulson@2090
   452
by (etac otway.induct 1);
paulson@2090
   453
by analz_Fake_tac;
paulson@2090
   454
by (REPEAT_FIRST (eresolve_tac [asm_rl, bexE, disjE] ORELSE' hyp_subst_tac));
paulson@2090
   455
by (ALLGOALS
paulson@2090
   456
    (asm_full_simp_tac 
paulson@2090
   457
     (!simpset addsimps ([analz_subset_parts RS contra_subsetD,
paulson@2090
   458
                          analz_insert_Key_newK] @ pushes)
paulson@2090
   459
               setloop split_tac [expand_if])));
paulson@2090
   460
(** LEVEL 4 **)
paulson@2090
   461
(*OR3*)
paulson@2090
   462
by (fast_tac (!claset addSIs [parts_insertI]
paulson@2090
   463
                      addEs [Says_imp_old_keys RS less_irrefl]
paulson@2090
   464
                      addss (!simpset addsimps [parts_insert2])) 2);
paulson@2090
   465
(*Reveal case 2, OR4, Fake*) 
paulson@2090
   466
by (REPEAT_FIRST (resolve_tac [conjI, impI] ORELSE' spy_analz_tac));
paulson@2090
   467
(*Reveal case 1*) (** LEVEL 6 **)
paulson@2090
   468
by (excluded_middle_tac "Aa : lost" 1);
paulson@2090
   469
(*But this contradicts Key K ~: analz (sees lost Spy evsa) *)
paulson@2090
   470
by (dtac (Says_imp_sees_Spy RS analz.Inj) 2);
paulson@2090
   471
by (fast_tac (!claset addSDs [analz.Decrypt] addss (!simpset)) 2);
paulson@2090
   472
(*So now we have  Aa ~: lost *)
paulson@2090
   473
by (dtac A_trust_OR4 1);
paulson@2090
   474
by (REPEAT (assume_tac 1));
paulson@2090
   475
by (fast_tac (!claset addDs [unique_session_keys] addss (!simpset)) 1);
paulson@2090
   476
val lemma = result() RS mp RS mp RSN(2,rev_notE);
paulson@2090
   477
paulson@2090
   478
goal thy 
paulson@2090
   479
 "!!evs. [| Says Server B \
paulson@2090
   480
\           {|Crypt {|NA, Agent A, Agent B, K|} (shrK A),                    \
paulson@2090
   481
\             Crypt {|NB, Agent A, Agent B, K|} (shrK B)|} : set_of_list evs; \
paulson@2090
   482
\           Says A Spy {|NA, K|} ~: set_of_list evs;                     \
paulson@2090
   483
\           A ~: lost;  B ~: lost;  evs : otway lost |]                  \
paulson@2090
   484
\        ==> K ~: analz (sees lost Spy evs)";
paulson@2090
   485
by (forward_tac [Says_Server_message_form] 1 THEN assume_tac 1);
paulson@2090
   486
by (fast_tac (!claset addSEs [lemma]) 1);
paulson@2090
   487
qed "Spy_not_see_encrypted_key";
paulson@2090
   488
paulson@2090
   489
paulson@2090
   490
goal thy 
paulson@2090
   491
 "!!evs. [| C ~: {A,B,Server};                                           \
paulson@2090
   492
\           Says Server B \
paulson@2090
   493
\           {|Crypt {|NA, Agent A, Agent B, K|} (shrK A),                    \
paulson@2090
   494
\             Crypt {|NB, Agent A, Agent B, K|} (shrK B)|} : set_of_list evs; \
paulson@2090
   495
\           Says A Spy {|NA, K|} ~: set_of_list evs;                     \
paulson@2090
   496
\           A ~: lost;  B ~: lost;  evs : otway lost |]                  \
paulson@2090
   497
\        ==> K ~: analz (sees lost C evs)";
paulson@2090
   498
by (rtac (subset_insertI RS sees_mono RS analz_mono RS contra_subsetD) 1);
paulson@2090
   499
by (rtac (sees_lost_agent_subset_sees_Spy RS analz_mono RS contra_subsetD) 1);
paulson@2090
   500
by (FIRSTGOAL (rtac Spy_not_see_encrypted_key));
paulson@2090
   501
by (REPEAT_FIRST (fast_tac (!claset addIs [otway_mono RS subsetD])));
paulson@2090
   502
qed "Agent_not_see_encrypted_key";
paulson@2090
   503
paulson@2090
   504
paulson@2090
   505
(**** Authenticity properties relating to NB ****)
paulson@2090
   506
paulson@2090
   507
(*If the encrypted message appears then it originated with the Server!*)
paulson@2090
   508
goal thy 
paulson@2090
   509
 "!!evs. [| B ~: lost;  evs : otway lost |]                   \
paulson@2090
   510
\    ==> Crypt {|NB, Agent A, Agent B, Key K|} (shrK B)       \
paulson@2090
   511
\         : parts (sees lost Spy evs)                         \
paulson@2090
   512
\        --> (EX NA. Says Server B                                          \
paulson@2090
   513
\                     {|Crypt {|NA, Agent A, Agent B, Key K|} (shrK A),     \
paulson@2090
   514
\                       Crypt {|NB, Agent A, Agent B, Key K|} (shrK B)|}    \
paulson@2090
   515
\                     : set_of_list evs)";
paulson@2090
   516
by (parts_induct_tac 1);
paulson@2090
   517
by (ALLGOALS (asm_simp_tac (!simpset addsimps [ex_disj_distrib])));
paulson@2090
   518
(*OR3*)
paulson@2090
   519
by (Fast_tac 1);
paulson@2090
   520
qed_spec_mp "NB_Crypt_imp_Server_msg";
paulson@2090
   521
paulson@2090
   522
paulson@2090
   523
(*Guarantee for B: if it gets a message with matching NB then the Server
paulson@2090
   524
  has sent the correct message.*)
paulson@2090
   525
goal thy 
paulson@2090
   526
 "!!evs. [| B ~: lost;  evs : otway lost;               \
paulson@2090
   527
\           Says S B {|X, Crypt {|NB, Agent A, Agent B, Key K|} (shrK B)|} \
paulson@2090
   528
\            : set_of_list evs |]                                  \
paulson@2090
   529
\        ==> EX NA. Says Server B                                          \
paulson@2090
   530
\                     {|Crypt {|NA, Agent A, Agent B, Key K|} (shrK A),     \
paulson@2090
   531
\                       Crypt {|NB, Agent A, Agent B, Key K|} (shrK B)|}    \
paulson@2090
   532
\                     : set_of_list evs";
paulson@2090
   533
by (fast_tac (!claset addSIs [NB_Crypt_imp_Server_msg]
paulson@2090
   534
                      addEs  partsEs
paulson@2090
   535
                      addDs  [Says_imp_sees_Spy RS parts.Inj]) 1);
paulson@2090
   536
qed "B_trust_OR3";