src/HOL/Auth/OtwayRees.ML
author paulson
Tue Nov 05 11:20:52 1996 +0100 (1996-11-05)
changeset 2160 ad4382e546fc
parent 2135 80477862ab33
child 2166 d276a806cc10
permissions -rw-r--r--
Simplified new_keys_not_seen, etc.: replaced the
union over all
agents by the Spy alone. Proofs run faster and they do not have to be
set up in terms of a previous lemma.
paulson@1941
     1
(*  Title:      HOL/Auth/OtwayRees
paulson@1941
     2
    ID:         $Id$
paulson@1941
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@1941
     4
    Copyright   1996  University of Cambridge
paulson@1941
     5
paulson@1941
     6
Inductive relation "otway" for the Otway-Rees protocol.
paulson@1941
     7
paulson@2014
     8
Version that encrypts Nonce NB
paulson@2014
     9
paulson@1941
    10
From page 244 of
paulson@1941
    11
  Burrows, Abadi and Needham.  A Logic of Authentication.
paulson@1941
    12
  Proc. Royal Soc. 426 (1989)
paulson@1941
    13
*)
paulson@1941
    14
paulson@1941
    15
open OtwayRees;
paulson@1941
    16
paulson@1941
    17
proof_timing:=true;
paulson@1941
    18
HOL_quantifiers := false;
paulson@2135
    19
Pretty.setdepth 15;
paulson@1941
    20
paulson@1996
    21
paulson@2014
    22
(*Weak liveness: there are traces that reach the end*)
paulson@1996
    23
goal thy 
paulson@1996
    24
 "!!A B. [| A ~= B; A ~= Server; B ~= Server |]   \
paulson@2032
    25
\        ==> EX K. EX NA. EX evs: otway lost.          \
paulson@2014
    26
\               Says B A {|Nonce NA, Crypt {|Nonce NA, Key K|} (shrK A)|} \
paulson@2014
    27
\                 : set_of_list evs";
paulson@1996
    28
by (REPEAT (resolve_tac [exI,bexI] 1));
paulson@2032
    29
by (rtac (otway.Nil RS otway.OR1 RS otway.OR2 RS otway.OR3 RS otway.OR4) 2);
paulson@1996
    30
by (ALLGOALS (simp_tac (!simpset setsolver safe_solver)));
paulson@1996
    31
by (REPEAT_FIRST (resolve_tac [refl, conjI]));
paulson@2104
    32
by (REPEAT_FIRST (fast_tac (!claset addss (!simpset setsolver safe_solver))));
paulson@2014
    33
result();
paulson@1996
    34
paulson@1996
    35
paulson@1941
    36
(**** Inductive proofs about otway ****)
paulson@1941
    37
paulson@2104
    38
(*Monotonicity*)
paulson@2032
    39
goal thy "!!evs. lost' <= lost ==> otway lost' <= otway lost";
paulson@2032
    40
by (rtac subsetI 1);
paulson@2032
    41
by (etac otway.induct 1);
paulson@2032
    42
by (REPEAT_FIRST
paulson@2032
    43
    (best_tac (!claset addIs (impOfSubs (sees_mono RS analz_mono RS synth_mono)
paulson@2032
    44
                              :: otway.intrs))));
paulson@2032
    45
qed "otway_mono";
paulson@2032
    46
paulson@1941
    47
(*Nobody sends themselves messages*)
paulson@2032
    48
goal thy "!!evs. evs : otway lost ==> ALL A X. Says A A X ~: set_of_list evs";
paulson@2032
    49
by (etac otway.induct 1);
paulson@1941
    50
by (Auto_tac());
paulson@1941
    51
qed_spec_mp "not_Says_to_self";
paulson@1941
    52
Addsimps [not_Says_to_self];
paulson@1941
    53
AddSEs   [not_Says_to_self RSN (2, rev_notE)];
paulson@1941
    54
paulson@1941
    55
paulson@1941
    56
(** For reasoning about the encrypted portion of messages **)
paulson@1941
    57
paulson@2135
    58
goal thy "!!evs. Says A' B {|N, Agent A, Agent B, X|} : set_of_list evs \
paulson@2135
    59
\                ==> X : analz (sees lost Spy evs)";
paulson@2032
    60
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS analz.Inj]) 1);
paulson@2032
    61
qed "OR2_analz_sees_Spy";
paulson@1941
    62
paulson@2135
    63
goal thy "!!evs. Says S B {|N, X, X'|} : set_of_list evs \
paulson@2135
    64
\                ==> X : analz (sees lost Spy evs)";
paulson@2032
    65
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS analz.Inj]) 1);
paulson@2032
    66
qed "OR4_analz_sees_Spy";
paulson@1941
    67
paulson@2135
    68
goal thy "!!evs. Says Server B {|NA, X, Crypt {|NB,K|} K'|} : set_of_list evs \
paulson@2135
    69
\                 ==> K : parts (sees lost Spy evs)";
paulson@1941
    70
by (fast_tac (!claset addSEs partsEs
paulson@2032
    71
                      addSDs [Says_imp_sees_Spy RS parts.Inj]) 1);
paulson@2135
    72
qed "Oops_parts_sees_Spy";
paulson@1941
    73
paulson@1941
    74
(*OR2_analz... and OR4_analz... let us treat those cases using the same 
paulson@1964
    75
  argument as for the Fake case.  This is possible for most, but not all,
paulson@1964
    76
  proofs: Fake does not invent new nonces (as in OR2), and of course Fake
paulson@2032
    77
  messages originate from the Spy. *)
paulson@1964
    78
paulson@2032
    79
bind_thm ("OR2_parts_sees_Spy",
paulson@2032
    80
          OR2_analz_sees_Spy RS (impOfSubs analz_subset_parts));
paulson@2032
    81
bind_thm ("OR4_parts_sees_Spy",
paulson@2032
    82
          OR4_analz_sees_Spy RS (impOfSubs analz_subset_parts));
paulson@2032
    83
paulson@2032
    84
(*We instantiate the variable to "lost".  Leaving it as a Var makes proofs
paulson@2032
    85
  harder to complete, since simplification does less for us.*)
paulson@2014
    86
val parts_Fake_tac = 
paulson@2032
    87
    let val tac = forw_inst_tac [("lost","lost")] 
paulson@2032
    88
    in  tac OR2_parts_sees_Spy 4 THEN 
paulson@2032
    89
        tac OR4_parts_sees_Spy 6 THEN
paulson@2135
    90
        tac Oops_parts_sees_Spy 7
paulson@2032
    91
    end;
paulson@1941
    92
paulson@2064
    93
(*For proving the easier theorems about X ~: parts (sees lost Spy evs) *)
paulson@2064
    94
fun parts_induct_tac i = SELECT_GOAL
paulson@2064
    95
    (DETERM (etac otway.induct 1 THEN parts_Fake_tac THEN
paulson@2064
    96
	     (*Fake message*)
paulson@2064
    97
	     TRY (best_tac (!claset addDs [impOfSubs analz_subset_parts,
paulson@2064
    98
					   impOfSubs Fake_parts_insert]
paulson@2064
    99
                                    addss (!simpset)) 2)) THEN
paulson@2064
   100
     (*Base case*)
paulson@2064
   101
     fast_tac (!claset addss (!simpset)) 1 THEN
paulson@2064
   102
     ALLGOALS Asm_simp_tac) i;
paulson@1941
   103
paulson@2032
   104
(** Theorems of the form X ~: parts (sees lost Spy evs) imply that NOBODY
paulson@2014
   105
    sends messages containing X! **)
paulson@1941
   106
paulson@2064
   107
(*Spy never sees another agent's shared key! (unless it's lost at start)*)
paulson@1941
   108
goal thy 
paulson@2135
   109
 "!!evs. evs : otway lost \
paulson@2135
   110
\        ==> (Key (shrK A) : parts (sees lost Spy evs)) = (A : lost)";
paulson@2064
   111
by (parts_induct_tac 1);
paulson@1941
   112
by (Auto_tac());
paulson@2135
   113
qed "Spy_see_shrK";
paulson@2135
   114
Addsimps [Spy_see_shrK];
paulson@1941
   115
paulson@2135
   116
goal thy 
paulson@2135
   117
 "!!evs. evs : otway lost \
paulson@2135
   118
\        ==> (Key (shrK A) : analz (sees lost Spy evs)) = (A : lost)";
paulson@2135
   119
by (auto_tac(!claset addDs [impOfSubs analz_subset_parts], !simpset));
paulson@2135
   120
qed "Spy_analz_shrK";
paulson@2135
   121
Addsimps [Spy_analz_shrK];
paulson@1941
   122
paulson@2135
   123
goal thy  "!!A. [| Key (shrK A) : parts (sees lost Spy evs);       \
paulson@2135
   124
\                  evs : otway lost |] ==> A:lost";
paulson@2135
   125
by (fast_tac (!claset addDs [Spy_see_shrK]) 1);
paulson@2135
   126
qed "Spy_see_shrK_D";
paulson@1941
   127
paulson@2135
   128
bind_thm ("Spy_analz_shrK_D", analz_subset_parts RS subsetD RS Spy_see_shrK_D);
paulson@2135
   129
AddSDs [Spy_see_shrK_D, Spy_analz_shrK_D];
paulson@1941
   130
paulson@1941
   131
paulson@1941
   132
(*** Future keys can't be seen or used! ***)
paulson@1941
   133
paulson@2160
   134
(*Nobody can have SEEN keys that will be generated in the future. *)
paulson@2032
   135
goal thy "!!evs. evs : otway lost ==> \
paulson@1941
   136
\                length evs <= length evs' --> \
paulson@2160
   137
\                Key (newK evs') ~: parts (sees lost Spy evs)";
paulson@2064
   138
by (parts_induct_tac 1);
paulson@1941
   139
by (REPEAT_FIRST (best_tac (!claset addDs [impOfSubs analz_subset_parts,
paulson@2032
   140
                                           impOfSubs parts_insert_subset_Un,
paulson@2032
   141
                                           Suc_leD]
paulson@2032
   142
                                    addss (!simpset))));
paulson@2160
   143
qed_spec_mp "new_keys_not_seen";
paulson@1941
   144
Addsimps [new_keys_not_seen];
paulson@1941
   145
paulson@2160
   146
(*Variant: old messages must contain old keys!*)
paulson@1941
   147
goal thy 
paulson@1941
   148
 "!!evs. [| Says A B X : set_of_list evs;  \
paulson@1941
   149
\           Key (newK evt) : parts {X};    \
paulson@2032
   150
\           evs : otway lost                 \
paulson@1941
   151
\        |] ==> length evt < length evs";
paulson@2032
   152
by (rtac ccontr 1);
paulson@2032
   153
by (dtac leI 1);
paulson@2032
   154
by (fast_tac (!claset addSDs [new_keys_not_seen, Says_imp_sees_Spy]
paulson@2014
   155
                      addIs  [impOfSubs parts_mono]) 1);
paulson@1941
   156
qed "Says_imp_old_keys";
paulson@1941
   157
paulson@1941
   158
paulson@2160
   159
(*** Future nonces can't be seen or used! ***)
paulson@2014
   160
paulson@2032
   161
goal thy "!!evs. evs : otway lost ==> \
paulson@2014
   162
\                length evs <= length evt --> \
paulson@2160
   163
\                Nonce (newN evt) ~: parts (sees lost Spy evs)";
paulson@2160
   164
by (parts_induct_tac 1);
paulson@2014
   165
by (REPEAT_FIRST (fast_tac (!claset 
paulson@2032
   166
                              addSEs partsEs
paulson@2032
   167
                              addSDs  [Says_imp_sees_Spy RS parts.Inj]
paulson@2032
   168
                              addDs  [impOfSubs analz_subset_parts,
paulson@2032
   169
                                      impOfSubs parts_insert_subset_Un,
paulson@2032
   170
                                      Suc_leD]
paulson@2032
   171
                              addss (!simpset))));
paulson@2160
   172
qed_spec_mp "new_nonces_not_seen";
paulson@2014
   173
Addsimps [new_nonces_not_seen];
paulson@2014
   174
paulson@2160
   175
(*Variant: old messages must contain old nonces!*)
paulson@2160
   176
goal thy "!!evs. [| Says A B X : set_of_list evs;    \
paulson@2160
   177
\                   Nonce (newN evt) : parts {X};    \
paulson@2160
   178
\                   evs : otway lost                 \
paulson@2160
   179
\                |] ==> length evt < length evs";
paulson@2032
   180
by (rtac ccontr 1);
paulson@2032
   181
by (dtac leI 1);
paulson@2032
   182
by (fast_tac (!claset addSDs [new_nonces_not_seen, Says_imp_sees_Spy]
paulson@2032
   183
                      addIs  [impOfSubs parts_mono]) 1);
paulson@2014
   184
qed "Says_imp_old_nonces";
paulson@2014
   185
paulson@2014
   186
paulson@1941
   187
(*Nobody can have USED keys that will be generated in the future.
paulson@1941
   188
  ...very like new_keys_not_seen*)
paulson@2160
   189
goal thy "!!evs. evs : otway lost ==>          \
paulson@1941
   190
\                length evs <= length evs' --> \
paulson@2160
   191
\                newK evs' ~: keysFor (parts (sees lost Spy evs))";
paulson@2064
   192
by (parts_induct_tac 1);
paulson@1941
   193
(*OR1 and OR3*)
paulson@1941
   194
by (EVERY (map (fast_tac (!claset addDs [Suc_leD] addss (!simpset))) [4,2]));
paulson@1941
   195
(*Fake, OR2, OR4: these messages send unknown (X) components*)
paulson@2104
   196
by (REPEAT
paulson@2104
   197
    (best_tac
paulson@1996
   198
      (!claset addDs [impOfSubs (analz_subset_parts RS keysFor_mono),
paulson@2032
   199
                      impOfSubs (parts_insert_subset_Un RS keysFor_mono),
paulson@2032
   200
                      Suc_leD]
paulson@2032
   201
               addEs [new_keys_not_seen RS not_parts_not_analz RSN(2,rev_notE)]
paulson@2104
   202
               addss (!simpset)) 1));
paulson@2160
   203
qed_spec_mp "new_keys_not_used";
paulson@1941
   204
paulson@1941
   205
bind_thm ("new_keys_not_analzd",
paulson@2032
   206
          [analz_subset_parts RS keysFor_mono,
paulson@2032
   207
           new_keys_not_used] MRS contra_subsetD);
paulson@1941
   208
paulson@1941
   209
Addsimps [new_keys_not_used, new_keys_not_analzd];
paulson@1941
   210
paulson@1941
   211
paulson@2064
   212
paulson@2064
   213
(*** Proofs involving analz ***)
paulson@2064
   214
paulson@2135
   215
(*Describes the form of K and NA when the Server sends this message.  Also
paulson@2135
   216
  for Oops case.*)
paulson@2064
   217
goal thy 
paulson@2135
   218
 "!!evs. [| Says Server B \
paulson@2135
   219
\            {|NA, X, Crypt {|NB, K|} (shrK B)|} : set_of_list evs;  \
paulson@2135
   220
\           evs : otway lost |]                                   \
paulson@2135
   221
\        ==> (EX evt: otway lost. K = Key(newK evt)) &            \
paulson@2135
   222
\            (EX i. NA = Nonce i) & (EX j. NB = Nonce j)";
paulson@2135
   223
by (etac rev_mp 1);
paulson@2135
   224
by (etac otway.induct 1);
paulson@2135
   225
by (ALLGOALS (fast_tac (!claset addss (!simpset))));
paulson@2135
   226
qed "Says_Server_message_form";
paulson@2064
   227
paulson@2064
   228
paulson@2064
   229
(*For proofs involving analz.  We again instantiate the variable to "lost".*)
paulson@2064
   230
val analz_Fake_tac = 
paulson@2064
   231
    dres_inst_tac [("lost","lost")] OR2_analz_sees_Spy 4 THEN 
paulson@2064
   232
    dres_inst_tac [("lost","lost")] OR4_analz_sees_Spy 6 THEN
paulson@2135
   233
    forw_inst_tac [("lost","lost")] Says_Server_message_form 7 THEN
paulson@2135
   234
    assume_tac 7 THEN Full_simp_tac 7 THEN
paulson@2135
   235
    REPEAT ((eresolve_tac [bexE, exE, conjE] ORELSE' hyp_subst_tac) 7);
paulson@1941
   236
paulson@1941
   237
paulson@1941
   238
(****
paulson@1941
   239
 The following is to prove theorems of the form
paulson@1941
   240
paulson@2032
   241
          Key K : analz (insert (Key (newK evt)) (sees lost Spy evs)) ==>
paulson@2032
   242
          Key K : analz (sees lost Spy evs)
paulson@1941
   243
paulson@1941
   244
 A more general formula must be proved inductively.
paulson@1941
   245
****)
paulson@1941
   246
paulson@1941
   247
paulson@1941
   248
(** Session keys are not used to encrypt other session keys **)
paulson@1941
   249
paulson@2014
   250
(*The equality makes the induction hypothesis easier to apply*)
paulson@1941
   251
goal thy  
paulson@2032
   252
 "!!evs. evs : otway lost ==> \
paulson@2032
   253
\  ALL K E. (Key K : analz (Key``(newK``E) Un (sees lost Spy evs))) = \
paulson@2032
   254
\           (K : newK``E | Key K : analz (sees lost Spy evs))";
paulson@2032
   255
by (etac otway.induct 1);
paulson@2064
   256
by analz_Fake_tac;
paulson@2045
   257
by (REPEAT_FIRST (ares_tac [allI, analz_image_newK_lemma]));
paulson@2160
   258
by (ALLGOALS (*Takes 14 secs*)
paulson@1941
   259
    (asm_simp_tac 
paulson@1941
   260
     (!simpset addsimps ([insert_Key_singleton, insert_Key_image, pushKey_newK]
paulson@2032
   261
                         @ pushes)
paulson@1941
   262
               setloop split_tac [expand_if])));
paulson@2135
   263
(*OR4, OR2, Fake*) 
paulson@2135
   264
by (EVERY (map spy_analz_tac [5,3,2]));
paulson@2135
   265
(*Oops, OR3, Base*)
paulson@2064
   266
by (REPEAT (fast_tac (!claset addIs [image_eqI] addss (!simpset)) 1));
paulson@1941
   267
qed_spec_mp "analz_image_newK";
paulson@1941
   268
paulson@1941
   269
paulson@1941
   270
goal thy
paulson@2032
   271
 "!!evs. evs : otway lost ==>                               \
paulson@2032
   272
\        Key K : analz (insert (Key (newK evt)) (sees lost Spy evs)) = \
paulson@2032
   273
\        (K = newK evt | Key K : analz (sees lost Spy evs))";
paulson@1941
   274
by (asm_simp_tac (HOL_ss addsimps [pushKey_newK, analz_image_newK, 
paulson@2032
   275
                                   insert_Key_singleton]) 1);
paulson@1941
   276
by (Fast_tac 1);
paulson@1941
   277
qed "analz_insert_Key_newK";
paulson@1941
   278
paulson@1941
   279
paulson@2026
   280
(*** The Key K uniquely identifies the Server's  message. **)
paulson@2014
   281
paulson@2014
   282
goal thy 
paulson@2135
   283
 "!!evs. evs : otway lost ==>                                                 \
paulson@2135
   284
\   EX B' NA' NB' X'. ALL B NA NB X.                                          \
paulson@2135
   285
\     Says Server B {|NA, X, Crypt {|NB, K|} (shrK B)|} : set_of_list evs --> \
paulson@2135
   286
\     B=B' & NA=NA' & NB=NB' & X=X'";
paulson@2032
   287
by (etac otway.induct 1);
paulson@2014
   288
by (ALLGOALS (asm_simp_tac (!simpset addsimps [all_conj_distrib])));
paulson@2014
   289
by (Step_tac 1);
paulson@2014
   290
(*Remaining cases: OR3 and OR4*)
paulson@2014
   291
by (ex_strip_tac 2);
paulson@2014
   292
by (Fast_tac 2);
paulson@2064
   293
by (expand_case_tac "K = ?y" 1);
paulson@2064
   294
by (REPEAT (ares_tac [refl,exI,impI,conjI] 2));
paulson@2014
   295
(*...we assume X is a very new message, and handle this case by contradiction*)
paulson@2014
   296
by (fast_tac (!claset addEs [Says_imp_old_keys RS less_irrefl]
paulson@2032
   297
                      delrules [conjI]    (*prevent split-up into 4 subgoals*)
paulson@2032
   298
                      addss (!simpset addsimps [parts_insertI])) 1);
paulson@2014
   299
val lemma = result();
paulson@2014
   300
paulson@2014
   301
goal thy 
paulson@2135
   302
 "!!evs. [| Says Server B {|NA, X, Crypt {|NB, K|} (shrK B)|}      \
paulson@2014
   303
\            : set_of_list evs;                                    \ 
paulson@2135
   304
\           Says Server B' {|NA',X',Crypt {|NB',K|} (shrK B')|}    \
paulson@2014
   305
\            : set_of_list evs;                                    \
paulson@2135
   306
\           evs : otway lost |] ==> X=X' & B=B' & NA=NA' & NB=NB'";
paulson@2032
   307
by (dtac lemma 1);
paulson@2014
   308
by (REPEAT (etac exE 1));
paulson@2014
   309
(*Duplicate the assumption*)
paulson@2014
   310
by (forw_inst_tac [("psi", "ALL C.?P(C)")] asm_rl 1);
paulson@2014
   311
by (fast_tac (!claset addSDs [spec]) 1);
paulson@2014
   312
qed "unique_session_keys";
paulson@2014
   313
paulson@2014
   314
paulson@2014
   315
paulson@2048
   316
(**** Authenticity properties relating to NA ****)
paulson@2014
   317
paulson@2014
   318
(*Only OR1 can have caused such a part of a message to appear.*)
paulson@2014
   319
goal thy 
paulson@2064
   320
 "!!evs. [| A ~: lost;  evs : otway lost |]                        \
paulson@2064
   321
\        ==> Crypt {|NA, Agent A, Agent B|} (shrK A)               \
paulson@2064
   322
\             : parts (sees lost Spy evs) -->                      \
paulson@2064
   323
\            Says A B {|NA, Agent A, Agent B,                      \
paulson@2014
   324
\                       Crypt {|NA, Agent A, Agent B|} (shrK A)|}  \
paulson@2014
   325
\             : set_of_list evs";
paulson@2064
   326
by (parts_induct_tac 1);
paulson@2014
   327
qed_spec_mp "Crypt_imp_OR1";
paulson@2014
   328
paulson@2014
   329
paulson@2064
   330
(** The Nonce NA uniquely identifies A's message. **)
paulson@2014
   331
paulson@2014
   332
goal thy 
paulson@2032
   333
 "!!evs. [| evs : otway lost; A ~: lost |]               \
paulson@2014
   334
\ ==> EX B'. ALL B.    \
paulson@2048
   335
\        Crypt {|NA, Agent A, Agent B|} (shrK A) : parts (sees lost Spy evs) \
paulson@2048
   336
\        --> B = B'";
paulson@2064
   337
by (parts_induct_tac 1);
paulson@2064
   338
by (simp_tac (!simpset addsimps [all_conj_distrib]) 1); 
paulson@2026
   339
(*OR1: creation of new Nonce.  Move assertion into global context*)
paulson@2064
   340
by (expand_case_tac "NA = ?y" 1);
paulson@2014
   341
by (best_tac (!claset addSEs partsEs
paulson@2032
   342
                      addEs  [new_nonces_not_seen RSN(2,rev_notE)]) 1);
paulson@2014
   343
val lemma = result();
paulson@2014
   344
paulson@2014
   345
goal thy 
paulson@2048
   346
 "!!evs.[| Crypt {|NA, Agent A, Agent B|} (shrK A): parts(sees lost Spy evs); \
paulson@2048
   347
\          Crypt {|NA, Agent A, Agent C|} (shrK A): parts(sees lost Spy evs); \
paulson@2048
   348
\          evs : otway lost;  A ~: lost |]                                    \
paulson@2014
   349
\        ==> B = C";
paulson@2032
   350
by (dtac lemma 1);
paulson@2032
   351
by (assume_tac 1);
paulson@2014
   352
by (etac exE 1);
paulson@2014
   353
(*Duplicate the assumption*)
paulson@2014
   354
by (forw_inst_tac [("psi", "ALL C.?P(C)")] asm_rl 1);
paulson@2014
   355
by (fast_tac (!claset addSDs [spec]) 1);
paulson@2048
   356
qed "unique_NA";
paulson@2014
   357
paulson@2014
   358
paulson@2014
   359
val nonce_not_seen_now = le_refl RSN (2, new_nonces_not_seen) RSN (2,rev_notE);
paulson@2014
   360
paulson@2014
   361
(*It is impossible to re-use a nonce in both OR1 and OR2.  This holds because
paulson@2014
   362
  OR2 encrypts Nonce NB.  It prevents the attack that can occur in the
paulson@2014
   363
  over-simplified version of this protocol: see OtwayRees_Bad.*)
paulson@2014
   364
goal thy 
paulson@2032
   365
 "!!evs. [| A ~: lost;  evs : otway lost |]                            \
paulson@2014
   366
\        ==> Crypt {|NA, Agent A, Agent B|} (shrK A)             \
paulson@2032
   367
\             : parts (sees lost Spy evs) -->                       \
paulson@2014
   368
\            Crypt {|NA', NA, Agent A', Agent A|} (shrK A)       \
paulson@2032
   369
\             ~: parts (sees lost Spy evs)";
paulson@2071
   370
by (parts_induct_tac 1);
paulson@2071
   371
by (REPEAT (fast_tac (!claset addSEs (partsEs@[nonce_not_seen_now])
paulson@2026
   372
                              addSDs  [impOfSubs parts_insert_subset_Un]
paulson@2071
   373
                              addss (!simpset)) 1));
paulson@2014
   374
qed_spec_mp"no_nonce_OR1_OR2";
paulson@2014
   375
paulson@2014
   376
paulson@2053
   377
(*Crucial property: If the encrypted message appears, and A has used NA
paulson@2053
   378
  to start a run, then it originated with the Server!*)
paulson@2014
   379
goal thy 
paulson@2048
   380
 "!!evs. [| A ~: lost;  A ~= Spy;  evs : otway lost |]                 \
paulson@2048
   381
\    ==> Crypt {|NA, Key K|} (shrK A) : parts (sees lost Spy evs)      \
paulson@2048
   382
\        --> Says A B {|NA, Agent A, Agent B,                          \
paulson@2048
   383
\                       Crypt {|NA, Agent A, Agent B|} (shrK A)|}      \
paulson@2048
   384
\             : set_of_list evs -->                                    \
paulson@2048
   385
\            (EX NB. Says Server B                                     \
paulson@2048
   386
\                 {|NA,                                                \
paulson@2048
   387
\                   Crypt {|NA, Key K|} (shrK A),                      \
paulson@2048
   388
\                   Crypt {|NB, Key K|} (shrK B)|}                     \
paulson@2014
   389
\                   : set_of_list evs)";
paulson@2064
   390
by (parts_induct_tac 1);
paulson@2014
   391
(*OR1: it cannot be a new Nonce, contradiction.*)
paulson@2014
   392
by (fast_tac (!claset addSIs [parts_insertI]
paulson@2032
   393
                      addSEs partsEs
paulson@2032
   394
                      addEs [Says_imp_old_nonces RS less_irrefl]
paulson@2032
   395
                      addss (!simpset)) 1);
paulson@2064
   396
(*OR3 and OR4*) 
paulson@2014
   397
(*OR4*)
paulson@2014
   398
by (REPEAT (Safe_step_tac 2));
paulson@2014
   399
by (REPEAT (best_tac (!claset addSDs [parts_cut]) 3));
paulson@2014
   400
by (fast_tac (!claset addSIs [Crypt_imp_OR1]
paulson@2032
   401
                      addEs  partsEs
paulson@2032
   402
                      addDs [Says_imp_sees_Spy RS parts.Inj]) 2);
paulson@2064
   403
(*OR3*)  (** LEVEL 5 **)
paulson@2064
   404
by (asm_simp_tac (!simpset addsimps [ex_disj_distrib]) 1);
paulson@2014
   405
by (step_tac (!claset delrules [disjCI, impCE]) 1);
paulson@2014
   406
by (fast_tac (!claset addSEs [MPair_parts]
paulson@2032
   407
                      addSDs [Says_imp_sees_Spy RS parts.Inj]
paulson@2014
   408
                      addEs  [no_nonce_OR1_OR2 RSN (2, rev_notE)]
paulson@2048
   409
                      delrules [conjI] (*stop split-up into 4 subgoals*)) 2);
paulson@2048
   410
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS parts.Inj]
paulson@2048
   411
                      addSEs [MPair_parts]
paulson@2048
   412
                      addEs  [unique_NA]) 1);
paulson@2048
   413
qed_spec_mp "NA_Crypt_imp_Server_msg";
paulson@2014
   414
paulson@2014
   415
paulson@2053
   416
(*Corollary: if A receives B's OR4 message and the nonce NA agrees
paulson@2014
   417
  then the key really did come from the Server!  CANNOT prove this of the
paulson@2048
   418
  bad form of this protocol, even though we can prove
paulson@2032
   419
  Spy_not_see_encrypted_key*)
paulson@2014
   420
goal thy 
paulson@2053
   421
 "!!evs. [| Says B' A {|NA, Crypt {|NA, Key K|} (shrK A)|}         \
paulson@2053
   422
\            : set_of_list evs;                                    \
paulson@2053
   423
\           Says A B {|NA, Agent A, Agent B,                       \
paulson@2053
   424
\                      Crypt {|NA, Agent A, Agent B|} (shrK A)|}   \
paulson@2053
   425
\            : set_of_list evs;                                    \
paulson@2053
   426
\           A ~: lost;  A ~= Spy;  evs : otway lost |]             \
paulson@2053
   427
\        ==> EX NB. Says Server B                                  \
paulson@2048
   428
\                     {|NA,                                        \
paulson@2048
   429
\                       Crypt {|NA, Key K|} (shrK A),              \
paulson@2048
   430
\                       Crypt {|NB, Key K|} (shrK B)|}             \
paulson@2053
   431
\                       : set_of_list evs";
paulson@2048
   432
by (fast_tac (!claset addSIs [NA_Crypt_imp_Server_msg]
paulson@2032
   433
                      addEs  partsEs
paulson@2032
   434
                      addDs  [Says_imp_sees_Spy RS parts.Inj]) 1);
paulson@2064
   435
qed "A_trust_OR4";
paulson@2014
   436
paulson@2014
   437
paulson@2048
   438
(** Crucial secrecy property: Spy does not see the keys sent in msg OR3
paulson@2048
   439
    Does not in itself guarantee security: an attack could violate 
paulson@2048
   440
    the premises, e.g. by having A=Spy **)
paulson@2014
   441
paulson@1941
   442
goal thy 
paulson@2032
   443
 "!!evs. [| A ~: lost;  B ~: lost;  evs : otway lost;  evt : otway lost |] \
paulson@2048
   444
\        ==> Says Server B                                                 \
paulson@2048
   445
\              {|NA, Crypt {|NA, Key K|} (shrK A),                         \
paulson@2048
   446
\                Crypt {|NB, Key K|} (shrK B)|} : set_of_list evs -->      \
paulson@2135
   447
\            Says B Spy {|NA, NB, Key K|} ~: set_of_list evs -->           \
paulson@2048
   448
\            Key K ~: analz (sees lost Spy evs)";
paulson@2032
   449
by (etac otway.induct 1);
paulson@2064
   450
by analz_Fake_tac;
paulson@1964
   451
by (ALLGOALS
paulson@1941
   452
    (asm_full_simp_tac 
paulson@1941
   453
     (!simpset addsimps ([analz_subset_parts RS contra_subsetD,
paulson@2032
   454
                          analz_insert_Key_newK] @ pushes)
paulson@1941
   455
               setloop split_tac [expand_if])));
paulson@1941
   456
(*OR3*)
paulson@2014
   457
by (fast_tac (!claset addSIs [parts_insertI]
paulson@2032
   458
                      addEs [Says_imp_old_keys RS less_irrefl]
paulson@2048
   459
                      addss (!simpset addsimps [parts_insert2])) 3);
paulson@2135
   460
(*OR4, OR2, Fake*) 
paulson@2032
   461
by (REPEAT_FIRST (resolve_tac [conjI, impI] ORELSE' spy_analz_tac));
paulson@2135
   462
(*Oops*) (** LEVEL 5 **)
paulson@2135
   463
by (fast_tac (!claset delrules [disjE]
paulson@2135
   464
		      addDs [unique_session_keys] addss (!simpset)) 1);
paulson@2014
   465
val lemma = result() RS mp RS mp RSN(2,rev_notE);
paulson@2014
   466
paulson@2014
   467
goal thy 
paulson@2014
   468
 "!!evs. [| Says Server B \
paulson@2048
   469
\            {|NA, Crypt {|NA, K|} (shrK A),                             \
paulson@2048
   470
\                  Crypt {|NB, K|} (shrK B)|} : set_of_list evs;         \
paulson@2135
   471
\           Says B Spy {|NA, NB, K|} ~: set_of_list evs;                 \
paulson@2032
   472
\           A ~: lost;  B ~: lost;  evs : otway lost |]                  \
paulson@2032
   473
\        ==> K ~: analz (sees lost Spy evs)";
paulson@2014
   474
by (forward_tac [Says_Server_message_form] 1 THEN assume_tac 1);
paulson@2014
   475
by (fast_tac (!claset addSEs [lemma]) 1);
paulson@2032
   476
qed "Spy_not_see_encrypted_key";
paulson@2032
   477
paulson@1945
   478
paulson@2032
   479
goal thy 
paulson@2048
   480
 "!!evs. [| C ~: {A,B,Server};                                           \
paulson@2048
   481
\           Says Server B                                                \
paulson@2048
   482
\            {|NA, Crypt {|NA, K|} (shrK A),                             \
paulson@2048
   483
\                  Crypt {|NB, K|} (shrK B)|} : set_of_list evs;         \
paulson@2135
   484
\           Says B Spy {|NA, NB, K|} ~: set_of_list evs;                 \
paulson@2032
   485
\           A ~: lost;  B ~: lost;  evs : otway lost |]                  \
paulson@2032
   486
\        ==> K ~: analz (sees lost C evs)";
paulson@2032
   487
by (rtac (subset_insertI RS sees_mono RS analz_mono RS contra_subsetD) 1);
paulson@2032
   488
by (rtac (sees_lost_agent_subset_sees_Spy RS analz_mono RS contra_subsetD) 1);
paulson@2032
   489
by (FIRSTGOAL (rtac Spy_not_see_encrypted_key));
paulson@2032
   490
by (REPEAT_FIRST (fast_tac (!claset addIs [otway_mono RS subsetD])));
paulson@2032
   491
qed "Agent_not_see_encrypted_key";
paulson@1945
   492
paulson@1945
   493
paulson@2048
   494
(**** Authenticity properties relating to NB ****)
paulson@2048
   495
paulson@2048
   496
(*Only OR2 can have caused such a part of a message to appear.  We do not
paulson@2048
   497
  know anything about X'.*)
paulson@2048
   498
goal thy 
paulson@2048
   499
 "!!evs. [| B ~: lost;  evs : otway lost |]                    \
paulson@2048
   500
\        ==> Crypt {|NA, NB, Agent A, Agent B|} (shrK B)       \
paulson@2048
   501
\             : parts (sees lost Spy evs) -->                  \
paulson@2048
   502
\            (EX X'. Says B Server                             \
paulson@2048
   503
\             {|NA, Agent A, Agent B, X',                      \
paulson@2048
   504
\               Crypt {|NA, NB, Agent A, Agent B|} (shrK B)|}  \
paulson@2048
   505
\             : set_of_list evs)";
paulson@2064
   506
by (parts_induct_tac 1);
paulson@2064
   507
by (auto_tac (!claset, !simpset addcongs [conj_cong]));
paulson@2048
   508
qed_spec_mp "Crypt_imp_OR2";
paulson@2048
   509
paulson@2048
   510
paulson@2048
   511
(** The Nonce NB uniquely identifies B's  message. **)
paulson@2048
   512
paulson@2048
   513
goal thy 
paulson@2048
   514
 "!!evs. [| evs : otway lost; B ~: lost |]               \
paulson@2064
   515
\ ==> EX NA' A'. ALL NA A.                               \
paulson@2048
   516
\      Crypt {|NA, NB, Agent A, Agent B|} (shrK B) : parts(sees lost Spy evs) \
paulson@2048
   517
\      --> NA = NA' & A = A'";
paulson@2064
   518
by (parts_induct_tac 1);
paulson@2064
   519
by (simp_tac (!simpset addsimps [all_conj_distrib]) 1); 
paulson@2048
   520
(*OR2: creation of new Nonce.  Move assertion into global context*)
paulson@2064
   521
by (expand_case_tac "NB = ?y" 1);
paulson@2048
   522
by (fast_tac (!claset addSEs (nonce_not_seen_now::partsEs)) 1);
paulson@2048
   523
val lemma = result();
paulson@2048
   524
paulson@2048
   525
goal thy 
paulson@2048
   526
 "!!evs.[| Crypt {|NA, NB, Agent A, Agent B|} (shrK B) \
paulson@2048
   527
\                  : parts(sees lost Spy evs);         \
paulson@2048
   528
\          Crypt {|NC, NB, Agent C, Agent B|} (shrK B) \
paulson@2048
   529
\                  : parts(sees lost Spy evs);         \
paulson@2048
   530
\          evs : otway lost;  B ~: lost |]             \
paulson@2048
   531
\        ==> NC = NA & C = A";
paulson@2048
   532
by (dtac lemma 1);
paulson@2048
   533
by (assume_tac 1);
paulson@2048
   534
by (REPEAT (etac exE 1));
paulson@2048
   535
(*Duplicate the assumption*)
paulson@2048
   536
by (forw_inst_tac [("psi", "ALL C.?P(C)")] asm_rl 1);
paulson@2048
   537
by (fast_tac (!claset addSDs [spec]) 1);
paulson@2048
   538
qed "unique_NB";
paulson@2048
   539
paulson@2048
   540
paulson@2048
   541
(*If the encrypted message appears, and B has used Nonce NB,
paulson@2048
   542
  then it originated with the Server!*)
paulson@2048
   543
goal thy 
paulson@2048
   544
 "!!evs. [| B ~: lost;  B ~= Spy;  evs : otway lost |]                   \
paulson@2048
   545
\    ==> Crypt {|NB, Key K|} (shrK B) : parts (sees lost Spy evs)        \
paulson@2048
   546
\        --> (ALL X'. Says B Server                                      \
paulson@2048
   547
\                       {|NA, Agent A, Agent B, X',                      \
paulson@2048
   548
\                         Crypt {|NA, NB, Agent A, Agent B|} (shrK B)|}  \
paulson@2048
   549
\             : set_of_list evs                                          \
paulson@2048
   550
\             --> Says Server B                                          \
paulson@2048
   551
\                  {|NA, Crypt {|NA, Key K|} (shrK A),                   \
paulson@2048
   552
\                        Crypt {|NB, Key K|} (shrK B)|}                  \
paulson@2048
   553
\                   : set_of_list evs)";
paulson@2064
   554
by (parts_induct_tac 1);
paulson@2048
   555
(*OR1: it cannot be a new Nonce, contradiction.*)
paulson@2048
   556
by (fast_tac (!claset addSIs [parts_insertI]
paulson@2048
   557
                      addSEs partsEs
paulson@2048
   558
                      addEs [Says_imp_old_nonces RS less_irrefl]
paulson@2048
   559
                      addss (!simpset)) 1);
paulson@2048
   560
(*OR3 and OR4*)  (** LEVEL 5 **)
paulson@2048
   561
(*OR4*)
paulson@2048
   562
by (REPEAT (Safe_step_tac 2));
paulson@2048
   563
br (Crypt_imp_OR2 RS exE) 2;
paulson@2048
   564
by (REPEAT (fast_tac (!claset addEs partsEs) 2));
paulson@2048
   565
(*OR3*)  (** LEVEL 8 **)
paulson@2048
   566
by (step_tac (!claset delrules [disjCI, impCE]) 1);
paulson@2048
   567
by (fast_tac (!claset delrules [conjI] (*stop split-up*)) 3); 
paulson@2048
   568
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS parts.Inj]
paulson@2048
   569
                      addSEs [MPair_parts]
paulson@2048
   570
                      addDs  [unique_NB]) 2);
paulson@2048
   571
by (fast_tac (!claset addSEs [MPair_parts]
paulson@2048
   572
                      addSDs [Says_imp_sees_Spy RS parts.Inj]
paulson@2048
   573
                      addSEs  [no_nonce_OR1_OR2 RSN (2, rev_notE)]
paulson@2048
   574
                      delrules [conjI, impCE] (*stop split-up*)) 1);
paulson@2048
   575
qed_spec_mp "NB_Crypt_imp_Server_msg";
paulson@2048
   576
paulson@2048
   577
paulson@2048
   578
(*Guarantee for B: if it gets a message with matching NB then the Server
paulson@2048
   579
  has sent the correct message.*)
paulson@2048
   580
goal thy 
paulson@2048
   581
 "!!evs. [| B ~: lost;  B ~= Spy;  evs : otway lost;               \
paulson@2048
   582
\           Says S B {|NA, X, Crypt {|NB, Key K|} (shrK B)|}       \
paulson@2048
   583
\            : set_of_list evs;                                    \
paulson@2048
   584
\           Says B Server {|NA, Agent A, Agent B, X',              \
paulson@2048
   585
\                           Crypt {|NA, NB, Agent A, Agent B|}     \
paulson@2048
   586
\                                 (shrK B)|}                       \
paulson@2048
   587
\            : set_of_list evs |]                                  \
paulson@2048
   588
\        ==> Says Server B                                         \
paulson@2048
   589
\                 {|NA,                                            \
paulson@2048
   590
\                   Crypt {|NA, Key K|} (shrK A),                  \
paulson@2048
   591
\                   Crypt {|NB, Key K|} (shrK B)|}                 \
paulson@2048
   592
\                   : set_of_list evs";
paulson@2048
   593
by (fast_tac (!claset addSIs [NB_Crypt_imp_Server_msg]
paulson@2048
   594
                      addEs  partsEs
paulson@2048
   595
                      addDs  [Says_imp_sees_Spy RS parts.Inj]) 1);
paulson@2064
   596
qed "B_trust_OR3";
paulson@2048
   597
paulson@2048
   598
paulson@2064
   599
B_trust_OR3 RS Spy_not_see_encrypted_key;
paulson@2048
   600
paulson@2048
   601
paulson@2026
   602
(** A session key uniquely identifies a pair of senders in the message
paulson@2048
   603
    encrypted by a good agent C.  NEEDED?  INTERESTING?**)
paulson@1945
   604
goal thy 
paulson@2032
   605
 "!!evs. evs : otway lost ==>                                           \
paulson@2135
   606
\      EX A B. ALL C N.                                                 \
paulson@2135
   607
\         C ~: lost -->                                                 \
paulson@2135
   608
\         Crypt {|N, Key K|} (shrK C) : parts (sees lost Spy evs) -->   \
paulson@2026
   609
\         C=A | C=B";
paulson@2032
   610
by (Simp_tac 1);        (*Miniscoping*)
paulson@2032
   611
by (etac otway.induct 1);
paulson@2064
   612
by analz_Fake_tac;
paulson@2032
   613
(*spy_analz_tac just does not work here: it is an entirely different proof!*)
paulson@1945
   614
by (ALLGOALS 
paulson@2026
   615
    (asm_simp_tac (!simpset addsimps [all_conj_distrib, ex_disj_distrib,
nipkow@2134
   616
                                      imp_conjR, parts_insert_sees,
paulson@2032
   617
                                      parts_insert2])));
paulson@1945
   618
by (REPEAT_FIRST (etac exE));
paulson@2026
   619
(*OR3: extraction of K = newK evsa to global context...*) (** LEVEL 6 **)
paulson@2064
   620
by (expand_case_tac "K = ?y" 4);
paulson@2064
   621
by (REPEAT (ares_tac [exI] 5));
paulson@1945
   622
(*...we prove this case by contradiction: the key is too new!*)
paulson@2026
   623
by (fast_tac (!claset addSEs partsEs
paulson@2032
   624
                      addEs [Says_imp_old_keys RS less_irrefl]
paulson@2032
   625
                      addss (!simpset)) 4);
paulson@2026
   626
(*Base, Fake, OR2, OR4*)
paulson@2026
   627
by (REPEAT_FIRST ex_strip_tac);
paulson@2032
   628
by (dtac synth.Inj 4);
paulson@2032
   629
by (dtac synth.Inj 3);
paulson@2026
   630
(*Now in effect there are three Fake cases*)
paulson@2026
   631
by (REPEAT_FIRST (best_tac (!claset addDs [impOfSubs Fake_parts_insert]
paulson@2032
   632
                                    delrules [disjCI, disjE]
paulson@2032
   633
                                    addss (!simpset))));
paulson@2014
   634
qed "key_identifies_senders";