src/HOL/Auth/OtwayRees.ML
author paulson
Fri Dec 06 10:36:31 1996 +0100 (1996-12-06)
changeset 2328 e984c12ce5b4
parent 2284 80ebd1a213fd
child 2375 14539397fc04
permissions -rw-r--r--
Minor renamings
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@2328
    22
(*A "possibility property": 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@2284
    26
\               Says B A {|Nonce NA, Crypt (shrK A) {|Nonce NA, Key K|}|} \
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@2284
    68
goal thy "!!evs. Says Server B {|NA, X, Crypt K' {|NB,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@2171
    96
             (*Fake message*)
paulson@2171
    97
             TRY (best_tac (!claset addDs [impOfSubs analz_subset_parts,
paulson@2171
    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@2264
   139
by (REPEAT_FIRST (best_tac (!claset addEs [leD RS notE]
paulson@2284
   140
                                    addDs [impOfSubs analz_subset_parts,
paulson@2032
   141
                                           impOfSubs parts_insert_subset_Un,
paulson@2032
   142
                                           Suc_leD]
paulson@2032
   143
                                    addss (!simpset))));
paulson@2160
   144
qed_spec_mp "new_keys_not_seen";
paulson@1941
   145
Addsimps [new_keys_not_seen];
paulson@1941
   146
paulson@2160
   147
(*Variant: old messages must contain old keys!*)
paulson@1941
   148
goal thy 
paulson@1941
   149
 "!!evs. [| Says A B X : set_of_list evs;  \
paulson@1941
   150
\           Key (newK evt) : parts {X};    \
paulson@2032
   151
\           evs : otway lost                 \
paulson@1941
   152
\        |] ==> length evt < length evs";
paulson@2032
   153
by (rtac ccontr 1);
paulson@2032
   154
by (dtac leI 1);
paulson@2032
   155
by (fast_tac (!claset addSDs [new_keys_not_seen, Says_imp_sees_Spy]
paulson@2014
   156
                      addIs  [impOfSubs parts_mono]) 1);
paulson@1941
   157
qed "Says_imp_old_keys";
paulson@1941
   158
paulson@1941
   159
paulson@2160
   160
(*** Future nonces can't be seen or used! ***)
paulson@2014
   161
paulson@2032
   162
goal thy "!!evs. evs : otway lost ==> \
paulson@2014
   163
\                length evs <= length evt --> \
paulson@2160
   164
\                Nonce (newN evt) ~: parts (sees lost Spy evs)";
paulson@2160
   165
by (parts_induct_tac 1);
paulson@2014
   166
by (REPEAT_FIRST (fast_tac (!claset 
paulson@2032
   167
                              addSEs partsEs
paulson@2032
   168
                              addSDs  [Says_imp_sees_Spy RS parts.Inj]
paulson@2264
   169
                              addEs [leD RS notE]
paulson@2284
   170
                              addDs  [impOfSubs analz_subset_parts,
paulson@2032
   171
                                      impOfSubs parts_insert_subset_Un,
paulson@2032
   172
                                      Suc_leD]
paulson@2032
   173
                              addss (!simpset))));
paulson@2160
   174
qed_spec_mp "new_nonces_not_seen";
paulson@2014
   175
Addsimps [new_nonces_not_seen];
paulson@2014
   176
paulson@2160
   177
(*Variant: old messages must contain old nonces!*)
paulson@2160
   178
goal thy "!!evs. [| Says A B X : set_of_list evs;    \
paulson@2160
   179
\                   Nonce (newN evt) : parts {X};    \
paulson@2160
   180
\                   evs : otway lost                 \
paulson@2160
   181
\                |] ==> length evt < length evs";
paulson@2032
   182
by (rtac ccontr 1);
paulson@2032
   183
by (dtac leI 1);
paulson@2032
   184
by (fast_tac (!claset addSDs [new_nonces_not_seen, Says_imp_sees_Spy]
paulson@2032
   185
                      addIs  [impOfSubs parts_mono]) 1);
paulson@2014
   186
qed "Says_imp_old_nonces";
paulson@2014
   187
paulson@2014
   188
paulson@1941
   189
(*Nobody can have USED keys that will be generated in the future.
paulson@1941
   190
  ...very like new_keys_not_seen*)
paulson@2160
   191
goal thy "!!evs. evs : otway lost ==>          \
paulson@1941
   192
\                length evs <= length evs' --> \
paulson@2160
   193
\                newK evs' ~: keysFor (parts (sees lost Spy evs))";
paulson@2064
   194
by (parts_induct_tac 1);
paulson@1941
   195
(*OR1 and OR3*)
paulson@1941
   196
by (EVERY (map (fast_tac (!claset addDs [Suc_leD] addss (!simpset))) [4,2]));
paulson@1941
   197
(*Fake, OR2, OR4: these messages send unknown (X) components*)
paulson@2104
   198
by (REPEAT
paulson@2104
   199
    (best_tac
paulson@1996
   200
      (!claset addDs [impOfSubs (analz_subset_parts RS keysFor_mono),
paulson@2032
   201
                      impOfSubs (parts_insert_subset_Un RS keysFor_mono),
paulson@2032
   202
                      Suc_leD]
paulson@2032
   203
               addEs [new_keys_not_seen RS not_parts_not_analz RSN(2,rev_notE)]
paulson@2104
   204
               addss (!simpset)) 1));
paulson@2160
   205
qed_spec_mp "new_keys_not_used";
paulson@1941
   206
paulson@1941
   207
bind_thm ("new_keys_not_analzd",
paulson@2032
   208
          [analz_subset_parts RS keysFor_mono,
paulson@2032
   209
           new_keys_not_used] MRS contra_subsetD);
paulson@1941
   210
paulson@1941
   211
Addsimps [new_keys_not_used, new_keys_not_analzd];
paulson@1941
   212
paulson@1941
   213
paulson@2064
   214
paulson@2064
   215
(*** Proofs involving analz ***)
paulson@2064
   216
paulson@2135
   217
(*Describes the form of K and NA when the Server sends this message.  Also
paulson@2135
   218
  for Oops case.*)
paulson@2064
   219
goal thy 
paulson@2135
   220
 "!!evs. [| Says Server B \
paulson@2284
   221
\            {|NA, X, Crypt (shrK B) {|NB, K|}|} : set_of_list evs;  \
paulson@2135
   222
\           evs : otway lost |]                                   \
paulson@2135
   223
\        ==> (EX evt: otway lost. K = Key(newK evt)) &            \
paulson@2135
   224
\            (EX i. NA = Nonce i) & (EX j. NB = Nonce j)";
paulson@2135
   225
by (etac rev_mp 1);
paulson@2135
   226
by (etac otway.induct 1);
paulson@2135
   227
by (ALLGOALS (fast_tac (!claset addss (!simpset))));
paulson@2135
   228
qed "Says_Server_message_form";
paulson@2064
   229
paulson@2064
   230
paulson@2064
   231
(*For proofs involving analz.  We again instantiate the variable to "lost".*)
paulson@2064
   232
val analz_Fake_tac = 
paulson@2064
   233
    dres_inst_tac [("lost","lost")] OR2_analz_sees_Spy 4 THEN 
paulson@2064
   234
    dres_inst_tac [("lost","lost")] OR4_analz_sees_Spy 6 THEN
paulson@2135
   235
    forw_inst_tac [("lost","lost")] Says_Server_message_form 7 THEN
paulson@2135
   236
    assume_tac 7 THEN Full_simp_tac 7 THEN
paulson@2135
   237
    REPEAT ((eresolve_tac [bexE, exE, conjE] ORELSE' hyp_subst_tac) 7);
paulson@1941
   238
paulson@1941
   239
paulson@1941
   240
(****
paulson@1941
   241
 The following is to prove theorems of the form
paulson@1941
   242
paulson@2032
   243
          Key K : analz (insert (Key (newK evt)) (sees lost Spy evs)) ==>
paulson@2032
   244
          Key K : analz (sees lost Spy evs)
paulson@1941
   245
paulson@1941
   246
 A more general formula must be proved inductively.
paulson@1941
   247
****)
paulson@1941
   248
paulson@1941
   249
paulson@1941
   250
(** Session keys are not used to encrypt other session keys **)
paulson@1941
   251
paulson@2014
   252
(*The equality makes the induction hypothesis easier to apply*)
paulson@1941
   253
goal thy  
paulson@2032
   254
 "!!evs. evs : otway lost ==> \
paulson@2032
   255
\  ALL K E. (Key K : analz (Key``(newK``E) Un (sees lost Spy evs))) = \
paulson@2032
   256
\           (K : newK``E | Key K : analz (sees lost Spy evs))";
paulson@2032
   257
by (etac otway.induct 1);
paulson@2064
   258
by analz_Fake_tac;
paulson@2045
   259
by (REPEAT_FIRST (ares_tac [allI, analz_image_newK_lemma]));
paulson@2160
   260
by (ALLGOALS (*Takes 14 secs*)
paulson@1941
   261
    (asm_simp_tac 
paulson@1941
   262
     (!simpset addsimps ([insert_Key_singleton, insert_Key_image, pushKey_newK]
paulson@2032
   263
                         @ pushes)
paulson@1941
   264
               setloop split_tac [expand_if])));
paulson@2135
   265
(*OR4, OR2, Fake*) 
paulson@2135
   266
by (EVERY (map spy_analz_tac [5,3,2]));
paulson@2135
   267
(*Oops, OR3, Base*)
paulson@2064
   268
by (REPEAT (fast_tac (!claset addIs [image_eqI] addss (!simpset)) 1));
paulson@1941
   269
qed_spec_mp "analz_image_newK";
paulson@1941
   270
paulson@1941
   271
paulson@1941
   272
goal thy
paulson@2032
   273
 "!!evs. evs : otway lost ==>                               \
paulson@2032
   274
\        Key K : analz (insert (Key (newK evt)) (sees lost Spy evs)) = \
paulson@2032
   275
\        (K = newK evt | Key K : analz (sees lost Spy evs))";
paulson@1941
   276
by (asm_simp_tac (HOL_ss addsimps [pushKey_newK, analz_image_newK, 
paulson@2032
   277
                                   insert_Key_singleton]) 1);
paulson@1941
   278
by (Fast_tac 1);
paulson@1941
   279
qed "analz_insert_Key_newK";
paulson@1941
   280
paulson@1941
   281
paulson@2026
   282
(*** The Key K uniquely identifies the Server's  message. **)
paulson@2014
   283
paulson@2014
   284
goal thy 
paulson@2135
   285
 "!!evs. evs : otway lost ==>                                                 \
paulson@2135
   286
\   EX B' NA' NB' X'. ALL B NA NB X.                                          \
paulson@2284
   287
\     Says Server B {|NA, X, Crypt (shrK B) {|NB, K|}|} : set_of_list evs --> \
paulson@2135
   288
\     B=B' & NA=NA' & NB=NB' & X=X'";
paulson@2032
   289
by (etac otway.induct 1);
paulson@2014
   290
by (ALLGOALS (asm_simp_tac (!simpset addsimps [all_conj_distrib])));
paulson@2014
   291
by (Step_tac 1);
paulson@2014
   292
(*Remaining cases: OR3 and OR4*)
paulson@2014
   293
by (ex_strip_tac 2);
paulson@2014
   294
by (Fast_tac 2);
paulson@2064
   295
by (expand_case_tac "K = ?y" 1);
paulson@2064
   296
by (REPEAT (ares_tac [refl,exI,impI,conjI] 2));
paulson@2014
   297
(*...we assume X is a very new message, and handle this case by contradiction*)
paulson@2014
   298
by (fast_tac (!claset addEs [Says_imp_old_keys RS less_irrefl]
paulson@2032
   299
                      delrules [conjI]    (*prevent split-up into 4 subgoals*)
paulson@2032
   300
                      addss (!simpset addsimps [parts_insertI])) 1);
paulson@2014
   301
val lemma = result();
paulson@2014
   302
paulson@2014
   303
goal thy 
paulson@2284
   304
 "!!evs. [| Says Server B {|NA, X, Crypt (shrK B) {|NB, K|}|}      \
paulson@2014
   305
\            : set_of_list evs;                                    \ 
paulson@2284
   306
\           Says Server B' {|NA',X',Crypt (shrK B') {|NB',K|}|}    \
paulson@2014
   307
\            : set_of_list evs;                                    \
paulson@2135
   308
\           evs : otway lost |] ==> X=X' & B=B' & NA=NA' & NB=NB'";
paulson@2032
   309
by (dtac lemma 1);
paulson@2014
   310
by (REPEAT (etac exE 1));
paulson@2014
   311
(*Duplicate the assumption*)
paulson@2014
   312
by (forw_inst_tac [("psi", "ALL C.?P(C)")] asm_rl 1);
paulson@2014
   313
by (fast_tac (!claset addSDs [spec]) 1);
paulson@2014
   314
qed "unique_session_keys";
paulson@2014
   315
paulson@2014
   316
paulson@2014
   317
paulson@2048
   318
(**** Authenticity properties relating to NA ****)
paulson@2014
   319
paulson@2014
   320
(*Only OR1 can have caused such a part of a message to appear.*)
paulson@2014
   321
goal thy 
paulson@2064
   322
 "!!evs. [| A ~: lost;  evs : otway lost |]                        \
paulson@2284
   323
\        ==> Crypt (shrK A) {|NA, Agent A, Agent B|}               \
paulson@2064
   324
\             : parts (sees lost Spy evs) -->                      \
paulson@2064
   325
\            Says A B {|NA, Agent A, Agent B,                      \
paulson@2284
   326
\                       Crypt (shrK A) {|NA, Agent A, Agent B|}|}  \
paulson@2014
   327
\             : set_of_list evs";
paulson@2064
   328
by (parts_induct_tac 1);
paulson@2014
   329
qed_spec_mp "Crypt_imp_OR1";
paulson@2014
   330
paulson@2014
   331
paulson@2064
   332
(** The Nonce NA uniquely identifies A's message. **)
paulson@2014
   333
paulson@2014
   334
goal thy 
paulson@2032
   335
 "!!evs. [| evs : otway lost; A ~: lost |]               \
paulson@2014
   336
\ ==> EX B'. ALL B.    \
paulson@2284
   337
\        Crypt (shrK A) {|NA, Agent A, Agent B|} : parts (sees lost Spy evs) \
paulson@2048
   338
\        --> B = B'";
paulson@2064
   339
by (parts_induct_tac 1);
paulson@2064
   340
by (simp_tac (!simpset addsimps [all_conj_distrib]) 1); 
paulson@2026
   341
(*OR1: creation of new Nonce.  Move assertion into global context*)
paulson@2064
   342
by (expand_case_tac "NA = ?y" 1);
paulson@2014
   343
by (best_tac (!claset addSEs partsEs
paulson@2032
   344
                      addEs  [new_nonces_not_seen RSN(2,rev_notE)]) 1);
paulson@2014
   345
val lemma = result();
paulson@2014
   346
paulson@2014
   347
goal thy 
paulson@2284
   348
 "!!evs.[| Crypt (shrK A) {|NA, Agent A, Agent B|}: parts(sees lost Spy evs); \
paulson@2284
   349
\          Crypt (shrK A) {|NA, Agent A, Agent C|}: parts(sees lost Spy evs); \
paulson@2048
   350
\          evs : otway lost;  A ~: lost |]                                    \
paulson@2014
   351
\        ==> B = C";
paulson@2032
   352
by (dtac lemma 1);
paulson@2032
   353
by (assume_tac 1);
paulson@2014
   354
by (etac exE 1);
paulson@2014
   355
(*Duplicate the assumption*)
paulson@2014
   356
by (forw_inst_tac [("psi", "ALL C.?P(C)")] asm_rl 1);
paulson@2014
   357
by (fast_tac (!claset addSDs [spec]) 1);
paulson@2048
   358
qed "unique_NA";
paulson@2014
   359
paulson@2014
   360
paulson@2014
   361
val nonce_not_seen_now = le_refl RSN (2, new_nonces_not_seen) RSN (2,rev_notE);
paulson@2014
   362
paulson@2014
   363
(*It is impossible to re-use a nonce in both OR1 and OR2.  This holds because
paulson@2014
   364
  OR2 encrypts Nonce NB.  It prevents the attack that can occur in the
paulson@2014
   365
  over-simplified version of this protocol: see OtwayRees_Bad.*)
paulson@2014
   366
goal thy 
paulson@2328
   367
 "!!evs. [| A ~: lost;  evs : otway lost |]                      \
paulson@2284
   368
\        ==> Crypt (shrK A) {|NA, Agent A, Agent B|}             \
paulson@2328
   369
\             : parts (sees lost Spy evs) -->                    \
paulson@2284
   370
\            Crypt (shrK A) {|NA', NA, Agent A', Agent A|}       \
paulson@2032
   371
\             ~: parts (sees lost Spy evs)";
paulson@2071
   372
by (parts_induct_tac 1);
paulson@2071
   373
by (REPEAT (fast_tac (!claset addSEs (partsEs@[nonce_not_seen_now])
paulson@2026
   374
                              addSDs  [impOfSubs parts_insert_subset_Un]
paulson@2071
   375
                              addss (!simpset)) 1));
paulson@2014
   376
qed_spec_mp"no_nonce_OR1_OR2";
paulson@2014
   377
paulson@2014
   378
paulson@2053
   379
(*Crucial property: If the encrypted message appears, and A has used NA
paulson@2053
   380
  to start a run, then it originated with the Server!*)
paulson@2014
   381
goal thy 
paulson@2048
   382
 "!!evs. [| A ~: lost;  A ~= Spy;  evs : otway lost |]                 \
paulson@2284
   383
\    ==> Crypt (shrK A) {|NA, Key K|} : parts (sees lost Spy evs)      \
paulson@2048
   384
\        --> Says A B {|NA, Agent A, Agent B,                          \
paulson@2284
   385
\                       Crypt (shrK A) {|NA, Agent A, Agent B|}|}      \
paulson@2048
   386
\             : set_of_list evs -->                                    \
paulson@2048
   387
\            (EX NB. Says Server B                                     \
paulson@2048
   388
\                 {|NA,                                                \
paulson@2284
   389
\                   Crypt (shrK A) {|NA, Key K|},                      \
paulson@2284
   390
\                   Crypt (shrK B) {|NB, Key K|}|}                     \
paulson@2014
   391
\                   : set_of_list evs)";
paulson@2064
   392
by (parts_induct_tac 1);
paulson@2014
   393
(*OR1: it cannot be a new Nonce, contradiction.*)
paulson@2014
   394
by (fast_tac (!claset addSIs [parts_insertI]
paulson@2032
   395
                      addSEs partsEs
paulson@2032
   396
                      addEs [Says_imp_old_nonces RS less_irrefl]
paulson@2032
   397
                      addss (!simpset)) 1);
paulson@2064
   398
(*OR3 and OR4*) 
paulson@2014
   399
(*OR4*)
paulson@2014
   400
by (REPEAT (Safe_step_tac 2));
paulson@2014
   401
by (REPEAT (best_tac (!claset addSDs [parts_cut]) 3));
paulson@2014
   402
by (fast_tac (!claset addSIs [Crypt_imp_OR1]
paulson@2032
   403
                      addEs  partsEs
paulson@2032
   404
                      addDs [Says_imp_sees_Spy RS parts.Inj]) 2);
paulson@2064
   405
(*OR3*)  (** LEVEL 5 **)
paulson@2064
   406
by (asm_simp_tac (!simpset addsimps [ex_disj_distrib]) 1);
paulson@2014
   407
by (step_tac (!claset delrules [disjCI, impCE]) 1);
paulson@2014
   408
by (fast_tac (!claset addSEs [MPair_parts]
paulson@2032
   409
                      addSDs [Says_imp_sees_Spy RS parts.Inj]
paulson@2014
   410
                      addEs  [no_nonce_OR1_OR2 RSN (2, rev_notE)]
paulson@2048
   411
                      delrules [conjI] (*stop split-up into 4 subgoals*)) 2);
paulson@2048
   412
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS parts.Inj]
paulson@2048
   413
                      addSEs [MPair_parts]
paulson@2048
   414
                      addEs  [unique_NA]) 1);
paulson@2048
   415
qed_spec_mp "NA_Crypt_imp_Server_msg";
paulson@2014
   416
paulson@2014
   417
paulson@2053
   418
(*Corollary: if A receives B's OR4 message and the nonce NA agrees
paulson@2014
   419
  then the key really did come from the Server!  CANNOT prove this of the
paulson@2048
   420
  bad form of this protocol, even though we can prove
paulson@2032
   421
  Spy_not_see_encrypted_key*)
paulson@2014
   422
goal thy 
paulson@2284
   423
 "!!evs. [| Says B' A {|NA, Crypt (shrK A) {|NA, Key K|}|}         \
paulson@2053
   424
\            : set_of_list evs;                                    \
paulson@2053
   425
\           Says A B {|NA, Agent A, Agent B,                       \
paulson@2284
   426
\                      Crypt (shrK A) {|NA, Agent A, Agent B|}|}   \
paulson@2053
   427
\            : set_of_list evs;                                    \
paulson@2053
   428
\           A ~: lost;  A ~= Spy;  evs : otway lost |]             \
paulson@2053
   429
\        ==> EX NB. Says Server B                                  \
paulson@2048
   430
\                     {|NA,                                        \
paulson@2284
   431
\                       Crypt (shrK A) {|NA, Key K|},              \
paulson@2284
   432
\                       Crypt (shrK B) {|NB, Key K|}|}             \
paulson@2053
   433
\                       : set_of_list evs";
paulson@2048
   434
by (fast_tac (!claset addSIs [NA_Crypt_imp_Server_msg]
paulson@2032
   435
                      addEs  partsEs
paulson@2032
   436
                      addDs  [Says_imp_sees_Spy RS parts.Inj]) 1);
paulson@2328
   437
qed "A_trusts_OR4";
paulson@2014
   438
paulson@2014
   439
paulson@2048
   440
(** Crucial secrecy property: Spy does not see the keys sent in msg OR3
paulson@2048
   441
    Does not in itself guarantee security: an attack could violate 
paulson@2048
   442
    the premises, e.g. by having A=Spy **)
paulson@2014
   443
paulson@1941
   444
goal thy 
paulson@2166
   445
 "!!evs. [| A ~: lost;  B ~: lost;  evs : otway lost |]                    \
paulson@2048
   446
\        ==> Says Server B                                                 \
paulson@2284
   447
\              {|NA, Crypt (shrK A) {|NA, Key K|},                         \
paulson@2284
   448
\                Crypt (shrK B) {|NB, Key K|}|} : set_of_list evs -->      \
paulson@2135
   449
\            Says B Spy {|NA, NB, Key K|} ~: set_of_list evs -->           \
paulson@2048
   450
\            Key K ~: analz (sees lost Spy evs)";
paulson@2032
   451
by (etac otway.induct 1);
paulson@2064
   452
by analz_Fake_tac;
paulson@1964
   453
by (ALLGOALS
paulson@1941
   454
    (asm_full_simp_tac 
paulson@1941
   455
     (!simpset addsimps ([analz_subset_parts RS contra_subsetD,
paulson@2032
   456
                          analz_insert_Key_newK] @ pushes)
paulson@1941
   457
               setloop split_tac [expand_if])));
paulson@1941
   458
(*OR3*)
paulson@2166
   459
by (fast_tac (!claset addEs [Says_imp_old_keys RS less_irrefl]
paulson@2048
   460
                      addss (!simpset addsimps [parts_insert2])) 3);
paulson@2135
   461
(*OR4, OR2, Fake*) 
paulson@2032
   462
by (REPEAT_FIRST (resolve_tac [conjI, impI] ORELSE' spy_analz_tac));
paulson@2135
   463
(*Oops*) (** LEVEL 5 **)
paulson@2135
   464
by (fast_tac (!claset delrules [disjE]
paulson@2171
   465
                      addDs [unique_session_keys] addss (!simpset)) 1);
paulson@2014
   466
val lemma = result() RS mp RS mp RSN(2,rev_notE);
paulson@2014
   467
paulson@2014
   468
goal thy 
paulson@2014
   469
 "!!evs. [| Says Server B \
paulson@2284
   470
\            {|NA, Crypt (shrK A) {|NA, K|},                             \
paulson@2284
   471
\                  Crypt (shrK B) {|NB, K|}|} : set_of_list evs;         \
paulson@2135
   472
\           Says B Spy {|NA, NB, K|} ~: set_of_list evs;                 \
paulson@2032
   473
\           A ~: lost;  B ~: lost;  evs : otway lost |]                  \
paulson@2032
   474
\        ==> K ~: analz (sees lost Spy evs)";
paulson@2014
   475
by (forward_tac [Says_Server_message_form] 1 THEN assume_tac 1);
paulson@2014
   476
by (fast_tac (!claset addSEs [lemma]) 1);
paulson@2032
   477
qed "Spy_not_see_encrypted_key";
paulson@2032
   478
paulson@1945
   479
paulson@2032
   480
goal thy 
paulson@2048
   481
 "!!evs. [| C ~: {A,B,Server};                                           \
paulson@2048
   482
\           Says Server B                                                \
paulson@2284
   483
\            {|NA, Crypt (shrK A) {|NA, K|},                             \
paulson@2284
   484
\                  Crypt (shrK B) {|NB, K|}|} : set_of_list evs;         \
paulson@2135
   485
\           Says B Spy {|NA, NB, K|} ~: set_of_list evs;                 \
paulson@2032
   486
\           A ~: lost;  B ~: lost;  evs : otway lost |]                  \
paulson@2032
   487
\        ==> K ~: analz (sees lost C evs)";
paulson@2032
   488
by (rtac (subset_insertI RS sees_mono RS analz_mono RS contra_subsetD) 1);
paulson@2032
   489
by (rtac (sees_lost_agent_subset_sees_Spy RS analz_mono RS contra_subsetD) 1);
paulson@2032
   490
by (FIRSTGOAL (rtac Spy_not_see_encrypted_key));
paulson@2032
   491
by (REPEAT_FIRST (fast_tac (!claset addIs [otway_mono RS subsetD])));
paulson@2032
   492
qed "Agent_not_see_encrypted_key";
paulson@1945
   493
paulson@1945
   494
paulson@2048
   495
(**** Authenticity properties relating to NB ****)
paulson@2048
   496
paulson@2048
   497
(*Only OR2 can have caused such a part of a message to appear.  We do not
paulson@2194
   498
  know anything about X: it does NOT have to have the right form.*)
paulson@2048
   499
goal thy 
paulson@2048
   500
 "!!evs. [| B ~: lost;  evs : otway lost |]                    \
paulson@2284
   501
\        ==> Crypt (shrK B) {|NA, NB, Agent A, Agent B|}       \
paulson@2048
   502
\             : parts (sees lost Spy evs) -->                  \
paulson@2194
   503
\            (EX X. Says B Server                              \
paulson@2194
   504
\             {|NA, Agent A, Agent B, X,                       \
paulson@2284
   505
\               Crypt (shrK B) {|NA, NB, Agent A, Agent B|}|}  \
paulson@2048
   506
\             : set_of_list evs)";
paulson@2064
   507
by (parts_induct_tac 1);
paulson@2064
   508
by (auto_tac (!claset, !simpset addcongs [conj_cong]));
paulson@2194
   509
bind_thm ("Crypt_imp_OR2", result() RSN (2,rev_mp) RS exE);
paulson@2048
   510
paulson@2048
   511
paulson@2048
   512
(** The Nonce NB uniquely identifies B's  message. **)
paulson@2048
   513
paulson@2048
   514
goal thy 
paulson@2048
   515
 "!!evs. [| evs : otway lost; B ~: lost |]               \
paulson@2064
   516
\ ==> EX NA' A'. ALL NA A.                               \
paulson@2284
   517
\      Crypt (shrK B) {|NA, NB, Agent A, Agent B|} : parts(sees lost Spy evs) \
paulson@2048
   518
\      --> NA = NA' & A = A'";
paulson@2064
   519
by (parts_induct_tac 1);
paulson@2064
   520
by (simp_tac (!simpset addsimps [all_conj_distrib]) 1); 
paulson@2048
   521
(*OR2: creation of new Nonce.  Move assertion into global context*)
paulson@2064
   522
by (expand_case_tac "NB = ?y" 1);
paulson@2048
   523
by (fast_tac (!claset addSEs (nonce_not_seen_now::partsEs)) 1);
paulson@2048
   524
val lemma = result();
paulson@2048
   525
paulson@2048
   526
goal thy 
paulson@2284
   527
 "!!evs.[| Crypt (shrK B) {|NA, NB, Agent A, Agent B|} \
paulson@2048
   528
\                  : parts(sees lost Spy evs);         \
paulson@2284
   529
\          Crypt (shrK B) {|NC, NB, Agent C, Agent B|} \
paulson@2048
   530
\                  : parts(sees lost Spy evs);         \
paulson@2048
   531
\          evs : otway lost;  B ~: lost |]             \
paulson@2048
   532
\        ==> NC = NA & C = A";
paulson@2048
   533
by (dtac lemma 1);
paulson@2048
   534
by (assume_tac 1);
paulson@2048
   535
by (REPEAT (etac exE 1));
paulson@2048
   536
(*Duplicate the assumption*)
paulson@2048
   537
by (forw_inst_tac [("psi", "ALL C.?P(C)")] asm_rl 1);
paulson@2048
   538
by (fast_tac (!claset addSDs [spec]) 1);
paulson@2048
   539
qed "unique_NB";
paulson@2048
   540
paulson@2048
   541
paulson@2048
   542
(*If the encrypted message appears, and B has used Nonce NB,
paulson@2048
   543
  then it originated with the Server!*)
paulson@2048
   544
goal thy 
paulson@2048
   545
 "!!evs. [| B ~: lost;  B ~= Spy;  evs : otway lost |]                   \
paulson@2284
   546
\    ==> Crypt (shrK B) {|NB, Key K|} : parts (sees lost Spy evs)        \
paulson@2048
   547
\        --> (ALL X'. Says B Server                                      \
paulson@2048
   548
\                       {|NA, Agent A, Agent B, X',                      \
paulson@2284
   549
\                         Crypt (shrK B) {|NA, NB, Agent A, Agent B|}|}  \
paulson@2048
   550
\             : set_of_list evs                                          \
paulson@2048
   551
\             --> Says Server B                                          \
paulson@2284
   552
\                  {|NA, Crypt (shrK A) {|NA, Key K|},                   \
paulson@2284
   553
\                        Crypt (shrK B) {|NB, Key K|}|}                  \
paulson@2048
   554
\                   : set_of_list evs)";
paulson@2064
   555
by (parts_induct_tac 1);
paulson@2048
   556
(*OR1: it cannot be a new Nonce, contradiction.*)
paulson@2048
   557
by (fast_tac (!claset addSIs [parts_insertI]
paulson@2048
   558
                      addSEs partsEs
paulson@2048
   559
                      addEs [Says_imp_old_nonces RS less_irrefl]
paulson@2048
   560
                      addss (!simpset)) 1);
paulson@2048
   561
(*OR4*)
paulson@2194
   562
by (fast_tac (!claset addSEs [MPair_parts, Crypt_imp_OR2]) 2);
paulson@2194
   563
(*OR3*)
paulson@2048
   564
by (step_tac (!claset delrules [disjCI, impCE]) 1);
paulson@2048
   565
by (fast_tac (!claset delrules [conjI] (*stop split-up*)) 3); 
paulson@2048
   566
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS parts.Inj]
paulson@2048
   567
                      addSEs [MPair_parts]
paulson@2048
   568
                      addDs  [unique_NB]) 2);
paulson@2048
   569
by (fast_tac (!claset addSEs [MPair_parts]
paulson@2048
   570
                      addSDs [Says_imp_sees_Spy RS parts.Inj]
paulson@2048
   571
                      addSEs  [no_nonce_OR1_OR2 RSN (2, rev_notE)]
paulson@2048
   572
                      delrules [conjI, impCE] (*stop split-up*)) 1);
paulson@2048
   573
qed_spec_mp "NB_Crypt_imp_Server_msg";
paulson@2048
   574
paulson@2048
   575
paulson@2048
   576
(*Guarantee for B: if it gets a message with matching NB then the Server
paulson@2048
   577
  has sent the correct message.*)
paulson@2048
   578
goal thy 
paulson@2048
   579
 "!!evs. [| B ~: lost;  B ~= Spy;  evs : otway lost;               \
paulson@2284
   580
\           Says S B {|NA, X, Crypt (shrK B) {|NB, Key K|}|}       \
paulson@2048
   581
\            : set_of_list evs;                                    \
paulson@2048
   582
\           Says B Server {|NA, Agent A, Agent B, X',              \
paulson@2284
   583
\                           Crypt (shrK B) {|NA, NB, Agent A, Agent B|} |} \
paulson@2048
   584
\            : set_of_list evs |]                                  \
paulson@2048
   585
\        ==> Says Server B                                         \
paulson@2048
   586
\                 {|NA,                                            \
paulson@2284
   587
\                   Crypt (shrK A) {|NA, Key K|},                  \
paulson@2284
   588
\                   Crypt (shrK B) {|NB, Key K|}|}                 \
paulson@2048
   589
\                   : set_of_list evs";
paulson@2048
   590
by (fast_tac (!claset addSIs [NB_Crypt_imp_Server_msg]
paulson@2048
   591
                      addEs  partsEs
paulson@2048
   592
                      addDs  [Says_imp_sees_Spy RS parts.Inj]) 1);
paulson@2328
   593
qed "B_trusts_OR3";
paulson@2048
   594
paulson@2048
   595
paulson@2328
   596
B_trusts_OR3 RS Spy_not_see_encrypted_key;
paulson@2048
   597
paulson@2048
   598
paulson@1945
   599
goal thy 
paulson@2214
   600
 "!!evs. [| B ~: lost;  evs : otway lost |]                           \
paulson@2214
   601
\        ==> Says Server B                                            \
paulson@2284
   602
\              {|NA, Crypt (shrK A) {|NA, Key K|},                    \
paulson@2284
   603
\                Crypt (shrK B) {|NB, Key K|}|} : set_of_list evs --> \
paulson@2214
   604
\            (EX X. Says B Server {|NA, Agent A, Agent B, X,          \
paulson@2284
   605
\                            Crypt (shrK B) {|NA, NB, Agent A, Agent B|} |} \
paulson@2194
   606
\            : set_of_list evs)";
paulson@2032
   607
by (etac otway.induct 1);
paulson@2194
   608
by (Auto_tac());
paulson@2284
   609
by (dtac (Says_imp_sees_Spy RS parts.Inj) 1);
paulson@2194
   610
by (fast_tac (!claset addSEs [MPair_parts, Crypt_imp_OR2]) 1);
paulson@2194
   611
bind_thm ("OR3_imp_OR2", result() RSN (2,rev_mp) RS exE);
paulson@2194
   612
paulson@2194
   613
paulson@2194
   614
(*After getting and checking OR4, agent A can trust that B has been active.
paulson@2194
   615
  We could probably prove that X has the expected form, but that is not
paulson@2194
   616
  strictly necessary for authentication.*)
paulson@2194
   617
goal thy 
paulson@2284
   618
 "!!evs. [| Says B' A {|NA, Crypt (shrK A) {|NA, Key K|}|}         \
paulson@2194
   619
\            : set_of_list evs;                                    \
paulson@2194
   620
\           Says A B {|NA, Agent A, Agent B,                       \
paulson@2284
   621
\                      Crypt (shrK A) {|NA, Agent A, Agent B|}|}   \
paulson@2194
   622
\            : set_of_list evs;                                    \
paulson@2194
   623
\           A ~: lost;  A ~= Spy;  B ~: lost;  evs : otway lost |] \
paulson@2194
   624
\        ==> EX NB X. Says B Server {|NA, Agent A, Agent B, X,     \
paulson@2284
   625
\                              Crypt (shrK B)  {|NA, NB, Agent A, Agent B|} |}\
paulson@2194
   626
\            : set_of_list evs";
paulson@2328
   627
by (fast_tac (!claset addSDs  [A_trusts_OR4]
paulson@2284
   628
                      addSEs [OR3_imp_OR2]) 1);
paulson@2194
   629
qed "A_auths_B";