src/HOL/Auth/OtwayRees.ML
author paulson
Mon Nov 18 16:34:37 1996 +0100 (1996-11-18)
changeset 2194 63a68a3a8a76
parent 2171 91b4161a28e5
child 2214 f869dc885841
permissions -rw-r--r--
Removal of an obsolete result, and authentication of
B to A
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@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@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@2166
   443
 "!!evs. [| A ~: lost;  B ~: lost;  evs : 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@2166
   457
by (fast_tac (!claset addEs [Says_imp_old_keys RS less_irrefl]
paulson@2048
   458
                      addss (!simpset addsimps [parts_insert2])) 3);
paulson@2135
   459
(*OR4, OR2, Fake*) 
paulson@2032
   460
by (REPEAT_FIRST (resolve_tac [conjI, impI] ORELSE' spy_analz_tac));
paulson@2135
   461
(*Oops*) (** LEVEL 5 **)
paulson@2135
   462
by (fast_tac (!claset delrules [disjE]
paulson@2171
   463
                      addDs [unique_session_keys] addss (!simpset)) 1);
paulson@2014
   464
val lemma = result() RS mp RS mp RSN(2,rev_notE);
paulson@2014
   465
paulson@2014
   466
goal thy 
paulson@2014
   467
 "!!evs. [| Says Server B \
paulson@2048
   468
\            {|NA, Crypt {|NA, K|} (shrK A),                             \
paulson@2048
   469
\                  Crypt {|NB, K|} (shrK B)|} : set_of_list evs;         \
paulson@2135
   470
\           Says B Spy {|NA, NB, K|} ~: set_of_list evs;                 \
paulson@2032
   471
\           A ~: lost;  B ~: lost;  evs : otway lost |]                  \
paulson@2032
   472
\        ==> K ~: analz (sees lost Spy evs)";
paulson@2014
   473
by (forward_tac [Says_Server_message_form] 1 THEN assume_tac 1);
paulson@2014
   474
by (fast_tac (!claset addSEs [lemma]) 1);
paulson@2032
   475
qed "Spy_not_see_encrypted_key";
paulson@2032
   476
paulson@1945
   477
paulson@2032
   478
goal thy 
paulson@2048
   479
 "!!evs. [| C ~: {A,B,Server};                                           \
paulson@2048
   480
\           Says Server B                                                \
paulson@2048
   481
\            {|NA, Crypt {|NA, K|} (shrK A),                             \
paulson@2048
   482
\                  Crypt {|NB, K|} (shrK B)|} : set_of_list evs;         \
paulson@2135
   483
\           Says B Spy {|NA, NB, K|} ~: set_of_list evs;                 \
paulson@2032
   484
\           A ~: lost;  B ~: lost;  evs : otway lost |]                  \
paulson@2032
   485
\        ==> K ~: analz (sees lost C evs)";
paulson@2032
   486
by (rtac (subset_insertI RS sees_mono RS analz_mono RS contra_subsetD) 1);
paulson@2032
   487
by (rtac (sees_lost_agent_subset_sees_Spy RS analz_mono RS contra_subsetD) 1);
paulson@2032
   488
by (FIRSTGOAL (rtac Spy_not_see_encrypted_key));
paulson@2032
   489
by (REPEAT_FIRST (fast_tac (!claset addIs [otway_mono RS subsetD])));
paulson@2032
   490
qed "Agent_not_see_encrypted_key";
paulson@1945
   491
paulson@1945
   492
paulson@2048
   493
(**** Authenticity properties relating to NB ****)
paulson@2048
   494
paulson@2048
   495
(*Only OR2 can have caused such a part of a message to appear.  We do not
paulson@2194
   496
  know anything about X: it does NOT have to have the right form.*)
paulson@2048
   497
goal thy 
paulson@2048
   498
 "!!evs. [| B ~: lost;  evs : otway lost |]                    \
paulson@2048
   499
\        ==> Crypt {|NA, NB, Agent A, Agent B|} (shrK B)       \
paulson@2048
   500
\             : parts (sees lost Spy evs) -->                  \
paulson@2194
   501
\            (EX X. Says B Server                              \
paulson@2194
   502
\             {|NA, Agent A, Agent B, X,                       \
paulson@2048
   503
\               Crypt {|NA, NB, Agent A, Agent B|} (shrK B)|}  \
paulson@2048
   504
\             : set_of_list evs)";
paulson@2064
   505
by (parts_induct_tac 1);
paulson@2064
   506
by (auto_tac (!claset, !simpset addcongs [conj_cong]));
paulson@2194
   507
bind_thm ("Crypt_imp_OR2", result() RSN (2,rev_mp) RS exE);
paulson@2048
   508
paulson@2048
   509
paulson@2048
   510
(** The Nonce NB uniquely identifies B's  message. **)
paulson@2048
   511
paulson@2048
   512
goal thy 
paulson@2048
   513
 "!!evs. [| evs : otway lost; B ~: lost |]               \
paulson@2064
   514
\ ==> EX NA' A'. ALL NA A.                               \
paulson@2048
   515
\      Crypt {|NA, NB, Agent A, Agent B|} (shrK B) : parts(sees lost Spy evs) \
paulson@2048
   516
\      --> NA = NA' & A = A'";
paulson@2064
   517
by (parts_induct_tac 1);
paulson@2064
   518
by (simp_tac (!simpset addsimps [all_conj_distrib]) 1); 
paulson@2048
   519
(*OR2: creation of new Nonce.  Move assertion into global context*)
paulson@2064
   520
by (expand_case_tac "NB = ?y" 1);
paulson@2048
   521
by (fast_tac (!claset addSEs (nonce_not_seen_now::partsEs)) 1);
paulson@2048
   522
val lemma = result();
paulson@2048
   523
paulson@2048
   524
goal thy 
paulson@2048
   525
 "!!evs.[| Crypt {|NA, NB, Agent A, Agent B|} (shrK B) \
paulson@2048
   526
\                  : parts(sees lost Spy evs);         \
paulson@2048
   527
\          Crypt {|NC, NB, Agent C, Agent B|} (shrK B) \
paulson@2048
   528
\                  : parts(sees lost Spy evs);         \
paulson@2048
   529
\          evs : otway lost;  B ~: lost |]             \
paulson@2048
   530
\        ==> NC = NA & C = A";
paulson@2048
   531
by (dtac lemma 1);
paulson@2048
   532
by (assume_tac 1);
paulson@2048
   533
by (REPEAT (etac exE 1));
paulson@2048
   534
(*Duplicate the assumption*)
paulson@2048
   535
by (forw_inst_tac [("psi", "ALL C.?P(C)")] asm_rl 1);
paulson@2048
   536
by (fast_tac (!claset addSDs [spec]) 1);
paulson@2048
   537
qed "unique_NB";
paulson@2048
   538
paulson@2048
   539
paulson@2048
   540
(*If the encrypted message appears, and B has used Nonce NB,
paulson@2048
   541
  then it originated with the Server!*)
paulson@2048
   542
goal thy 
paulson@2048
   543
 "!!evs. [| B ~: lost;  B ~= Spy;  evs : otway lost |]                   \
paulson@2048
   544
\    ==> Crypt {|NB, Key K|} (shrK B) : parts (sees lost Spy evs)        \
paulson@2048
   545
\        --> (ALL X'. Says B Server                                      \
paulson@2048
   546
\                       {|NA, Agent A, Agent B, X',                      \
paulson@2048
   547
\                         Crypt {|NA, NB, Agent A, Agent B|} (shrK B)|}  \
paulson@2048
   548
\             : set_of_list evs                                          \
paulson@2048
   549
\             --> Says Server B                                          \
paulson@2048
   550
\                  {|NA, Crypt {|NA, Key K|} (shrK A),                   \
paulson@2048
   551
\                        Crypt {|NB, Key K|} (shrK B)|}                  \
paulson@2048
   552
\                   : set_of_list evs)";
paulson@2064
   553
by (parts_induct_tac 1);
paulson@2048
   554
(*OR1: it cannot be a new Nonce, contradiction.*)
paulson@2048
   555
by (fast_tac (!claset addSIs [parts_insertI]
paulson@2048
   556
                      addSEs partsEs
paulson@2048
   557
                      addEs [Says_imp_old_nonces RS less_irrefl]
paulson@2048
   558
                      addss (!simpset)) 1);
paulson@2048
   559
(*OR4*)
paulson@2194
   560
by (fast_tac (!claset addSEs [MPair_parts, Crypt_imp_OR2]) 2);
paulson@2194
   561
(*OR3*)
paulson@2048
   562
by (step_tac (!claset delrules [disjCI, impCE]) 1);
paulson@2048
   563
by (fast_tac (!claset delrules [conjI] (*stop split-up*)) 3); 
paulson@2048
   564
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS parts.Inj]
paulson@2048
   565
                      addSEs [MPair_parts]
paulson@2048
   566
                      addDs  [unique_NB]) 2);
paulson@2048
   567
by (fast_tac (!claset addSEs [MPair_parts]
paulson@2048
   568
                      addSDs [Says_imp_sees_Spy RS parts.Inj]
paulson@2048
   569
                      addSEs  [no_nonce_OR1_OR2 RSN (2, rev_notE)]
paulson@2048
   570
                      delrules [conjI, impCE] (*stop split-up*)) 1);
paulson@2048
   571
qed_spec_mp "NB_Crypt_imp_Server_msg";
paulson@2048
   572
paulson@2048
   573
paulson@2048
   574
(*Guarantee for B: if it gets a message with matching NB then the Server
paulson@2048
   575
  has sent the correct message.*)
paulson@2048
   576
goal thy 
paulson@2048
   577
 "!!evs. [| B ~: lost;  B ~= Spy;  evs : otway lost;               \
paulson@2048
   578
\           Says S B {|NA, X, Crypt {|NB, Key K|} (shrK B)|}       \
paulson@2048
   579
\            : set_of_list evs;                                    \
paulson@2048
   580
\           Says B Server {|NA, Agent A, Agent B, X',              \
paulson@2048
   581
\                           Crypt {|NA, NB, Agent A, Agent B|}     \
paulson@2048
   582
\                                 (shrK B)|}                       \
paulson@2048
   583
\            : set_of_list evs |]                                  \
paulson@2048
   584
\        ==> Says Server B                                         \
paulson@2048
   585
\                 {|NA,                                            \
paulson@2048
   586
\                   Crypt {|NA, Key K|} (shrK A),                  \
paulson@2048
   587
\                   Crypt {|NB, Key K|} (shrK B)|}                 \
paulson@2048
   588
\                   : set_of_list evs";
paulson@2048
   589
by (fast_tac (!claset addSIs [NB_Crypt_imp_Server_msg]
paulson@2048
   590
                      addEs  partsEs
paulson@2048
   591
                      addDs  [Says_imp_sees_Spy RS parts.Inj]) 1);
paulson@2064
   592
qed "B_trust_OR3";
paulson@2048
   593
paulson@2048
   594
paulson@2064
   595
B_trust_OR3 RS Spy_not_see_encrypted_key;
paulson@2048
   596
paulson@2048
   597
paulson@1945
   598
goal thy 
paulson@2194
   599
 "!!evs. [| B ~: lost;  evs : otway lost |]                    \
paulson@2194
   600
\        ==> Says Server B                                                 \
paulson@2194
   601
\              {|NA, Crypt {|NA, Key K|} (shrK A),                         \
paulson@2194
   602
\                Crypt {|NB, Key K|} (shrK B)|} : set_of_list evs -->      \
paulson@2194
   603
\            (EX X. Says B Server {|NA, Agent A, Agent B, X,              \
paulson@2194
   604
\                            Crypt {|NA, NB, Agent A, Agent B|}     \
paulson@2194
   605
\                                  (shrK B)|}                       \
paulson@2194
   606
\            : set_of_list evs)";
paulson@2032
   607
by (etac otway.induct 1);
paulson@2194
   608
by (Auto_tac());
paulson@2194
   609
bd (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@2194
   618
 "!!evs. [| Says B' A {|NA, Crypt {|NA, Key K|} (shrK A)|}         \
paulson@2194
   619
\            : set_of_list evs;                                    \
paulson@2194
   620
\           Says A B {|NA, Agent A, Agent B,                       \
paulson@2194
   621
\                      Crypt {|NA, Agent A, Agent B|} (shrK A)|}   \
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@2194
   625
\                            Crypt {|NA, NB, Agent A, Agent B|}    \
paulson@2194
   626
\                                  (shrK B)|}                      \
paulson@2194
   627
\            : set_of_list evs";
paulson@2194
   628
by (fast_tac (!claset addSDs  [A_trust_OR4]
paulson@2194
   629
	              addSEs [OR3_imp_OR2]) 1);
paulson@2194
   630
qed "A_auths_B";
paulson@2194
   631
paulson@2194
   632