src/HOL/Auth/OtwayRees.ML
author paulson
Mon Dec 16 11:08:11 1996 +0100 (1996-12-16)
changeset 2417 95f275c8476e
parent 2375 14539397fc04
child 2451 ce85a2aafc7a
permissions -rw-r--r--
New tactic: prove_unique_tac
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@2375
   168
                              addSDs [Says_imp_sees_Spy RS parts.Inj]
paulson@2375
   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@2375
   260
by (ALLGOALS (*Takes 12 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@2417
   309
by (prove_unique_tac lemma 1);
paulson@2014
   310
qed "unique_session_keys";
paulson@2014
   311
paulson@2014
   312
paulson@2014
   313
paulson@2048
   314
(**** Authenticity properties relating to NA ****)
paulson@2014
   315
paulson@2014
   316
(*Only OR1 can have caused such a part of a message to appear.*)
paulson@2014
   317
goal thy 
paulson@2064
   318
 "!!evs. [| A ~: lost;  evs : otway lost |]                        \
paulson@2284
   319
\        ==> Crypt (shrK A) {|NA, Agent A, Agent B|}               \
paulson@2064
   320
\             : parts (sees lost Spy evs) -->                      \
paulson@2064
   321
\            Says A B {|NA, Agent A, Agent B,                      \
paulson@2284
   322
\                       Crypt (shrK A) {|NA, Agent A, Agent B|}|}  \
paulson@2014
   323
\             : set_of_list evs";
paulson@2064
   324
by (parts_induct_tac 1);
paulson@2014
   325
qed_spec_mp "Crypt_imp_OR1";
paulson@2014
   326
paulson@2014
   327
paulson@2064
   328
(** The Nonce NA uniquely identifies A's message. **)
paulson@2014
   329
paulson@2014
   330
goal thy 
paulson@2032
   331
 "!!evs. [| evs : otway lost; A ~: lost |]               \
paulson@2014
   332
\ ==> EX B'. ALL B.    \
paulson@2284
   333
\        Crypt (shrK A) {|NA, Agent A, Agent B|} : parts (sees lost Spy evs) \
paulson@2048
   334
\        --> B = B'";
paulson@2064
   335
by (parts_induct_tac 1);
paulson@2064
   336
by (simp_tac (!simpset addsimps [all_conj_distrib]) 1); 
paulson@2026
   337
(*OR1: creation of new Nonce.  Move assertion into global context*)
paulson@2064
   338
by (expand_case_tac "NA = ?y" 1);
paulson@2014
   339
by (best_tac (!claset addSEs partsEs
paulson@2032
   340
                      addEs  [new_nonces_not_seen RSN(2,rev_notE)]) 1);
paulson@2014
   341
val lemma = result();
paulson@2014
   342
paulson@2014
   343
goal thy 
paulson@2284
   344
 "!!evs.[| Crypt (shrK A) {|NA, Agent A, Agent B|}: parts(sees lost Spy evs); \
paulson@2284
   345
\          Crypt (shrK A) {|NA, Agent A, Agent C|}: parts(sees lost Spy evs); \
paulson@2048
   346
\          evs : otway lost;  A ~: lost |]                                    \
paulson@2014
   347
\        ==> B = C";
paulson@2417
   348
by (prove_unique_tac lemma 1);
paulson@2048
   349
qed "unique_NA";
paulson@2014
   350
paulson@2014
   351
paulson@2014
   352
val nonce_not_seen_now = le_refl RSN (2, new_nonces_not_seen) RSN (2,rev_notE);
paulson@2014
   353
paulson@2014
   354
(*It is impossible to re-use a nonce in both OR1 and OR2.  This holds because
paulson@2014
   355
  OR2 encrypts Nonce NB.  It prevents the attack that can occur in the
paulson@2014
   356
  over-simplified version of this protocol: see OtwayRees_Bad.*)
paulson@2014
   357
goal thy 
paulson@2328
   358
 "!!evs. [| A ~: lost;  evs : otway lost |]                      \
paulson@2284
   359
\        ==> Crypt (shrK A) {|NA, Agent A, Agent B|}             \
paulson@2328
   360
\             : parts (sees lost Spy evs) -->                    \
paulson@2284
   361
\            Crypt (shrK A) {|NA', NA, Agent A', Agent A|}       \
paulson@2032
   362
\             ~: parts (sees lost Spy evs)";
paulson@2071
   363
by (parts_induct_tac 1);
paulson@2071
   364
by (REPEAT (fast_tac (!claset addSEs (partsEs@[nonce_not_seen_now])
paulson@2026
   365
                              addSDs  [impOfSubs parts_insert_subset_Un]
paulson@2071
   366
                              addss (!simpset)) 1));
paulson@2014
   367
qed_spec_mp"no_nonce_OR1_OR2";
paulson@2014
   368
paulson@2014
   369
paulson@2053
   370
(*Crucial property: If the encrypted message appears, and A has used NA
paulson@2053
   371
  to start a run, then it originated with the Server!*)
paulson@2014
   372
goal thy 
paulson@2048
   373
 "!!evs. [| A ~: lost;  A ~= Spy;  evs : otway lost |]                 \
paulson@2284
   374
\    ==> Crypt (shrK A) {|NA, Key K|} : parts (sees lost Spy evs)      \
paulson@2048
   375
\        --> Says A B {|NA, Agent A, Agent B,                          \
paulson@2284
   376
\                       Crypt (shrK A) {|NA, Agent A, Agent B|}|}      \
paulson@2048
   377
\             : set_of_list evs -->                                    \
paulson@2048
   378
\            (EX NB. Says Server B                                     \
paulson@2048
   379
\                 {|NA,                                                \
paulson@2284
   380
\                   Crypt (shrK A) {|NA, Key K|},                      \
paulson@2284
   381
\                   Crypt (shrK B) {|NB, Key K|}|}                     \
paulson@2014
   382
\                   : set_of_list evs)";
paulson@2064
   383
by (parts_induct_tac 1);
paulson@2014
   384
(*OR1: it cannot be a new Nonce, contradiction.*)
paulson@2014
   385
by (fast_tac (!claset addSIs [parts_insertI]
paulson@2032
   386
                      addSEs partsEs
paulson@2032
   387
                      addEs [Says_imp_old_nonces RS less_irrefl]
paulson@2032
   388
                      addss (!simpset)) 1);
paulson@2064
   389
(*OR3 and OR4*) 
paulson@2014
   390
(*OR4*)
paulson@2014
   391
by (REPEAT (Safe_step_tac 2));
paulson@2014
   392
by (REPEAT (best_tac (!claset addSDs [parts_cut]) 3));
paulson@2014
   393
by (fast_tac (!claset addSIs [Crypt_imp_OR1]
paulson@2032
   394
                      addEs  partsEs
paulson@2032
   395
                      addDs [Says_imp_sees_Spy RS parts.Inj]) 2);
paulson@2064
   396
(*OR3*)  (** LEVEL 5 **)
paulson@2064
   397
by (asm_simp_tac (!simpset addsimps [ex_disj_distrib]) 1);
paulson@2014
   398
by (step_tac (!claset delrules [disjCI, impCE]) 1);
paulson@2014
   399
by (fast_tac (!claset addSEs [MPair_parts]
paulson@2032
   400
                      addSDs [Says_imp_sees_Spy RS parts.Inj]
paulson@2014
   401
                      addEs  [no_nonce_OR1_OR2 RSN (2, rev_notE)]
paulson@2048
   402
                      delrules [conjI] (*stop split-up into 4 subgoals*)) 2);
paulson@2048
   403
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS parts.Inj]
paulson@2048
   404
                      addSEs [MPair_parts]
paulson@2048
   405
                      addEs  [unique_NA]) 1);
paulson@2048
   406
qed_spec_mp "NA_Crypt_imp_Server_msg";
paulson@2014
   407
paulson@2014
   408
paulson@2053
   409
(*Corollary: if A receives B's OR4 message and the nonce NA agrees
paulson@2014
   410
  then the key really did come from the Server!  CANNOT prove this of the
paulson@2048
   411
  bad form of this protocol, even though we can prove
paulson@2032
   412
  Spy_not_see_encrypted_key*)
paulson@2014
   413
goal thy 
paulson@2284
   414
 "!!evs. [| Says B' A {|NA, Crypt (shrK A) {|NA, Key K|}|}         \
paulson@2053
   415
\            : set_of_list evs;                                    \
paulson@2053
   416
\           Says A B {|NA, Agent A, Agent B,                       \
paulson@2284
   417
\                      Crypt (shrK A) {|NA, Agent A, Agent B|}|}   \
paulson@2053
   418
\            : set_of_list evs;                                    \
paulson@2053
   419
\           A ~: lost;  A ~= Spy;  evs : otway lost |]             \
paulson@2053
   420
\        ==> EX NB. Says Server B                                  \
paulson@2048
   421
\                     {|NA,                                        \
paulson@2284
   422
\                       Crypt (shrK A) {|NA, Key K|},              \
paulson@2284
   423
\                       Crypt (shrK B) {|NB, Key K|}|}             \
paulson@2053
   424
\                       : set_of_list evs";
paulson@2048
   425
by (fast_tac (!claset addSIs [NA_Crypt_imp_Server_msg]
paulson@2032
   426
                      addEs  partsEs
paulson@2032
   427
                      addDs  [Says_imp_sees_Spy RS parts.Inj]) 1);
paulson@2328
   428
qed "A_trusts_OR4";
paulson@2014
   429
paulson@2014
   430
paulson@2048
   431
(** Crucial secrecy property: Spy does not see the keys sent in msg OR3
paulson@2048
   432
    Does not in itself guarantee security: an attack could violate 
paulson@2048
   433
    the premises, e.g. by having A=Spy **)
paulson@2014
   434
paulson@1941
   435
goal thy 
paulson@2166
   436
 "!!evs. [| A ~: lost;  B ~: lost;  evs : otway lost |]                    \
paulson@2048
   437
\        ==> Says Server B                                                 \
paulson@2284
   438
\              {|NA, Crypt (shrK A) {|NA, Key K|},                         \
paulson@2284
   439
\                Crypt (shrK B) {|NB, Key K|}|} : set_of_list evs -->      \
paulson@2135
   440
\            Says B Spy {|NA, NB, Key K|} ~: set_of_list evs -->           \
paulson@2048
   441
\            Key K ~: analz (sees lost Spy evs)";
paulson@2032
   442
by (etac otway.induct 1);
paulson@2064
   443
by analz_Fake_tac;
paulson@1964
   444
by (ALLGOALS
paulson@2375
   445
    (asm_simp_tac (!simpset addsimps ([not_parts_not_analz,
paulson@2375
   446
				       analz_insert_Key_newK] @ pushes)
paulson@2375
   447
		            setloop split_tac [expand_if])));
paulson@1941
   448
(*OR3*)
paulson@2166
   449
by (fast_tac (!claset addEs [Says_imp_old_keys RS less_irrefl]
paulson@2048
   450
                      addss (!simpset addsimps [parts_insert2])) 3);
paulson@2135
   451
(*OR4, OR2, Fake*) 
paulson@2375
   452
by (REPEAT_FIRST spy_analz_tac);
paulson@2135
   453
(*Oops*) (** LEVEL 5 **)
paulson@2135
   454
by (fast_tac (!claset delrules [disjE]
paulson@2171
   455
                      addDs [unique_session_keys] addss (!simpset)) 1);
paulson@2014
   456
val lemma = result() RS mp RS mp RSN(2,rev_notE);
paulson@2014
   457
paulson@2014
   458
goal thy 
paulson@2014
   459
 "!!evs. [| Says Server B \
paulson@2284
   460
\            {|NA, Crypt (shrK A) {|NA, K|},                             \
paulson@2284
   461
\                  Crypt (shrK B) {|NB, K|}|} : set_of_list evs;         \
paulson@2135
   462
\           Says B Spy {|NA, NB, K|} ~: set_of_list evs;                 \
paulson@2032
   463
\           A ~: lost;  B ~: lost;  evs : otway lost |]                  \
paulson@2032
   464
\        ==> K ~: analz (sees lost Spy evs)";
paulson@2014
   465
by (forward_tac [Says_Server_message_form] 1 THEN assume_tac 1);
paulson@2014
   466
by (fast_tac (!claset addSEs [lemma]) 1);
paulson@2032
   467
qed "Spy_not_see_encrypted_key";
paulson@2032
   468
paulson@1945
   469
paulson@2032
   470
goal thy 
paulson@2048
   471
 "!!evs. [| C ~: {A,B,Server};                                           \
paulson@2048
   472
\           Says Server B                                                \
paulson@2284
   473
\            {|NA, Crypt (shrK A) {|NA, K|},                             \
paulson@2284
   474
\                  Crypt (shrK B) {|NB, K|}|} : set_of_list evs;         \
paulson@2135
   475
\           Says B Spy {|NA, NB, K|} ~: set_of_list evs;                 \
paulson@2032
   476
\           A ~: lost;  B ~: lost;  evs : otway lost |]                  \
paulson@2032
   477
\        ==> K ~: analz (sees lost C evs)";
paulson@2032
   478
by (rtac (subset_insertI RS sees_mono RS analz_mono RS contra_subsetD) 1);
paulson@2032
   479
by (rtac (sees_lost_agent_subset_sees_Spy RS analz_mono RS contra_subsetD) 1);
paulson@2032
   480
by (FIRSTGOAL (rtac Spy_not_see_encrypted_key));
paulson@2032
   481
by (REPEAT_FIRST (fast_tac (!claset addIs [otway_mono RS subsetD])));
paulson@2032
   482
qed "Agent_not_see_encrypted_key";
paulson@1945
   483
paulson@1945
   484
paulson@2048
   485
(**** Authenticity properties relating to NB ****)
paulson@2048
   486
paulson@2048
   487
(*Only OR2 can have caused such a part of a message to appear.  We do not
paulson@2194
   488
  know anything about X: it does NOT have to have the right form.*)
paulson@2048
   489
goal thy 
paulson@2048
   490
 "!!evs. [| B ~: lost;  evs : otway lost |]                    \
paulson@2284
   491
\        ==> Crypt (shrK B) {|NA, NB, Agent A, Agent B|}       \
paulson@2048
   492
\             : parts (sees lost Spy evs) -->                  \
paulson@2194
   493
\            (EX X. Says B Server                              \
paulson@2194
   494
\             {|NA, Agent A, Agent B, X,                       \
paulson@2284
   495
\               Crypt (shrK B) {|NA, NB, Agent A, Agent B|}|}  \
paulson@2048
   496
\             : set_of_list evs)";
paulson@2064
   497
by (parts_induct_tac 1);
paulson@2064
   498
by (auto_tac (!claset, !simpset addcongs [conj_cong]));
paulson@2194
   499
bind_thm ("Crypt_imp_OR2", result() RSN (2,rev_mp) RS exE);
paulson@2048
   500
paulson@2048
   501
paulson@2048
   502
(** The Nonce NB uniquely identifies B's  message. **)
paulson@2048
   503
paulson@2048
   504
goal thy 
paulson@2048
   505
 "!!evs. [| evs : otway lost; B ~: lost |]               \
paulson@2064
   506
\ ==> EX NA' A'. ALL NA A.                               \
paulson@2284
   507
\      Crypt (shrK B) {|NA, NB, Agent A, Agent B|} : parts(sees lost Spy evs) \
paulson@2048
   508
\      --> NA = NA' & A = A'";
paulson@2064
   509
by (parts_induct_tac 1);
paulson@2064
   510
by (simp_tac (!simpset addsimps [all_conj_distrib]) 1); 
paulson@2048
   511
(*OR2: creation of new Nonce.  Move assertion into global context*)
paulson@2064
   512
by (expand_case_tac "NB = ?y" 1);
paulson@2048
   513
by (fast_tac (!claset addSEs (nonce_not_seen_now::partsEs)) 1);
paulson@2048
   514
val lemma = result();
paulson@2048
   515
paulson@2048
   516
goal thy 
paulson@2284
   517
 "!!evs.[| Crypt (shrK B) {|NA, NB, Agent A, Agent B|} \
paulson@2048
   518
\                  : parts(sees lost Spy evs);         \
paulson@2284
   519
\          Crypt (shrK B) {|NC, NB, Agent C, Agent B|} \
paulson@2048
   520
\                  : parts(sees lost Spy evs);         \
paulson@2048
   521
\          evs : otway lost;  B ~: lost |]             \
paulson@2048
   522
\        ==> NC = NA & C = A";
paulson@2417
   523
by (prove_unique_tac lemma 1);
paulson@2048
   524
qed "unique_NB";
paulson@2048
   525
paulson@2048
   526
paulson@2048
   527
(*If the encrypted message appears, and B has used Nonce NB,
paulson@2048
   528
  then it originated with the Server!*)
paulson@2048
   529
goal thy 
paulson@2048
   530
 "!!evs. [| B ~: lost;  B ~= Spy;  evs : otway lost |]                   \
paulson@2284
   531
\    ==> Crypt (shrK B) {|NB, Key K|} : parts (sees lost Spy evs)        \
paulson@2048
   532
\        --> (ALL X'. Says B Server                                      \
paulson@2048
   533
\                       {|NA, Agent A, Agent B, X',                      \
paulson@2284
   534
\                         Crypt (shrK B) {|NA, NB, Agent A, Agent B|}|}  \
paulson@2048
   535
\             : set_of_list evs                                          \
paulson@2048
   536
\             --> Says Server B                                          \
paulson@2284
   537
\                  {|NA, Crypt (shrK A) {|NA, Key K|},                   \
paulson@2284
   538
\                        Crypt (shrK B) {|NB, Key K|}|}                  \
paulson@2048
   539
\                   : set_of_list evs)";
paulson@2064
   540
by (parts_induct_tac 1);
paulson@2048
   541
(*OR1: it cannot be a new Nonce, contradiction.*)
paulson@2048
   542
by (fast_tac (!claset addSIs [parts_insertI]
paulson@2048
   543
                      addSEs partsEs
paulson@2048
   544
                      addEs [Says_imp_old_nonces RS less_irrefl]
paulson@2048
   545
                      addss (!simpset)) 1);
paulson@2048
   546
(*OR4*)
paulson@2194
   547
by (fast_tac (!claset addSEs [MPair_parts, Crypt_imp_OR2]) 2);
paulson@2194
   548
(*OR3*)
paulson@2048
   549
by (step_tac (!claset delrules [disjCI, impCE]) 1);
paulson@2048
   550
by (fast_tac (!claset delrules [conjI] (*stop split-up*)) 3); 
paulson@2048
   551
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS parts.Inj]
paulson@2048
   552
                      addSEs [MPair_parts]
paulson@2048
   553
                      addDs  [unique_NB]) 2);
paulson@2048
   554
by (fast_tac (!claset addSEs [MPair_parts]
paulson@2048
   555
                      addSDs [Says_imp_sees_Spy RS parts.Inj]
paulson@2048
   556
                      addSEs  [no_nonce_OR1_OR2 RSN (2, rev_notE)]
paulson@2048
   557
                      delrules [conjI, impCE] (*stop split-up*)) 1);
paulson@2048
   558
qed_spec_mp "NB_Crypt_imp_Server_msg";
paulson@2048
   559
paulson@2048
   560
paulson@2048
   561
(*Guarantee for B: if it gets a message with matching NB then the Server
paulson@2048
   562
  has sent the correct message.*)
paulson@2048
   563
goal thy 
paulson@2048
   564
 "!!evs. [| B ~: lost;  B ~= Spy;  evs : otway lost;               \
paulson@2284
   565
\           Says S B {|NA, X, Crypt (shrK B) {|NB, Key K|}|}       \
paulson@2048
   566
\            : set_of_list evs;                                    \
paulson@2048
   567
\           Says B Server {|NA, Agent A, Agent B, X',              \
paulson@2284
   568
\                           Crypt (shrK B) {|NA, NB, Agent A, Agent B|} |} \
paulson@2048
   569
\            : set_of_list evs |]                                  \
paulson@2048
   570
\        ==> Says Server B                                         \
paulson@2048
   571
\                 {|NA,                                            \
paulson@2284
   572
\                   Crypt (shrK A) {|NA, Key K|},                  \
paulson@2284
   573
\                   Crypt (shrK B) {|NB, Key K|}|}                 \
paulson@2048
   574
\                   : set_of_list evs";
paulson@2048
   575
by (fast_tac (!claset addSIs [NB_Crypt_imp_Server_msg]
paulson@2048
   576
                      addEs  partsEs
paulson@2048
   577
                      addDs  [Says_imp_sees_Spy RS parts.Inj]) 1);
paulson@2328
   578
qed "B_trusts_OR3";
paulson@2048
   579
paulson@2048
   580
paulson@2328
   581
B_trusts_OR3 RS Spy_not_see_encrypted_key;
paulson@2048
   582
paulson@2048
   583
paulson@1945
   584
goal thy 
paulson@2214
   585
 "!!evs. [| B ~: lost;  evs : otway lost |]                           \
paulson@2214
   586
\        ==> Says Server B                                            \
paulson@2284
   587
\              {|NA, Crypt (shrK A) {|NA, Key K|},                    \
paulson@2284
   588
\                Crypt (shrK B) {|NB, Key K|}|} : set_of_list evs --> \
paulson@2214
   589
\            (EX X. Says B Server {|NA, Agent A, Agent B, X,          \
paulson@2284
   590
\                            Crypt (shrK B) {|NA, NB, Agent A, Agent B|} |} \
paulson@2194
   591
\            : set_of_list evs)";
paulson@2032
   592
by (etac otway.induct 1);
paulson@2194
   593
by (Auto_tac());
paulson@2284
   594
by (dtac (Says_imp_sees_Spy RS parts.Inj) 1);
paulson@2194
   595
by (fast_tac (!claset addSEs [MPair_parts, Crypt_imp_OR2]) 1);
paulson@2194
   596
bind_thm ("OR3_imp_OR2", result() RSN (2,rev_mp) RS exE);
paulson@2194
   597
paulson@2194
   598
paulson@2194
   599
(*After getting and checking OR4, agent A can trust that B has been active.
paulson@2194
   600
  We could probably prove that X has the expected form, but that is not
paulson@2194
   601
  strictly necessary for authentication.*)
paulson@2194
   602
goal thy 
paulson@2284
   603
 "!!evs. [| Says B' A {|NA, Crypt (shrK A) {|NA, Key K|}|}         \
paulson@2194
   604
\            : set_of_list evs;                                    \
paulson@2194
   605
\           Says A B {|NA, Agent A, Agent B,                       \
paulson@2284
   606
\                      Crypt (shrK A) {|NA, Agent A, Agent B|}|}   \
paulson@2194
   607
\            : set_of_list evs;                                    \
paulson@2194
   608
\           A ~: lost;  A ~= Spy;  B ~: lost;  evs : otway lost |] \
paulson@2194
   609
\        ==> EX NB X. Says B Server {|NA, Agent A, Agent B, X,     \
paulson@2284
   610
\                              Crypt (shrK B)  {|NA, NB, Agent A, Agent B|} |}\
paulson@2194
   611
\            : set_of_list evs";
paulson@2328
   612
by (fast_tac (!claset addSDs  [A_trusts_OR4]
paulson@2284
   613
                      addSEs [OR3_imp_OR2]) 1);
paulson@2194
   614
qed "A_auths_B";