src/HOL/Auth/Recur.ML
author paulson
Fri Jan 17 12:49:31 1997 +0100 (1997-01-17)
changeset 2516 4d68fbe6378b
parent 2485 c4368c967c56
child 2533 2d5604a51562
permissions -rw-r--r--
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson@2449
     1
(*  Title:      HOL/Auth/Recur
paulson@2449
     2
    ID:         $Id$
paulson@2449
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@2449
     4
    Copyright   1996  University of Cambridge
paulson@2449
     5
paulson@2449
     6
Inductive relation "recur" for the Recursive Authentication protocol.
paulson@2449
     7
*)
paulson@2449
     8
paulson@2449
     9
open Recur;
paulson@2449
    10
paulson@2449
    11
proof_timing:=true;
paulson@2449
    12
HOL_quantifiers := false;
paulson@2516
    13
Pretty.setdepth 30;
paulson@2449
    14
paulson@2449
    15
paulson@2449
    16
(** Possibility properties: traces that reach the end 
paulson@2516
    17
        ONE theorem would be more elegant and faster!
paulson@2516
    18
        By induction on a list of agents (no repetitions)
paulson@2449
    19
**)
paulson@2449
    20
paulson@2516
    21
paulson@2449
    22
(*Simplest case: Alice goes directly to the server*)
paulson@2481
    23
goal thy
paulson@2449
    24
 "!!A. A ~= Server   \
paulson@2449
    25
\ ==> EX K NA. EX evs: recur lost.          \
paulson@2516
    26
\     Says Server A {|Crypt (shrK A) {|Key K, Agent Server, Nonce NA|}, \
paulson@2449
    27
\                       Agent Server|}      \
paulson@2449
    28
\         : set_of_list evs";
paulson@2449
    29
by (REPEAT (resolve_tac [exI,bexI] 1));
paulson@2451
    30
by (rtac (recur.Nil RS recur.RA1 RS 
paulson@2516
    31
          (respond.One RSN (4,recur.RA3))) 2);
paulson@2516
    32
by possibility_tac;
paulson@2449
    33
result();
paulson@2449
    34
paulson@2449
    35
paulson@2449
    36
(*Case two: Alice, Bob and the server*)
paulson@2481
    37
goal thy
paulson@2449
    38
 "!!A B. [| A ~= B; A ~= Server; B ~= Server |]   \
paulson@2449
    39
\ ==> EX K. EX NA. EX evs: recur lost.          \
paulson@2516
    40
\       Says B A {|Crypt (shrK A) {|Key K, Agent B, Nonce NA|}, \
paulson@2449
    41
\                       Agent Server|}                          \
paulson@2449
    42
\         : set_of_list evs";
paulson@2516
    43
by (cut_facts_tac [Nonce_supply2, Key_supply2] 1);
paulson@2516
    44
by (REPEAT (eresolve_tac [exE, conjE] 1));
paulson@2449
    45
by (REPEAT (resolve_tac [exI,bexI] 1));
paulson@2451
    46
by (rtac (recur.Nil RS recur.RA1 RS recur.RA2 RS 
paulson@2516
    47
          (respond.One RS respond.Cons RSN (4,recur.RA3)) RS
paulson@2516
    48
          recur.RA4) 2);
paulson@2516
    49
by basic_possibility_tac;
paulson@2516
    50
by (DEPTH_SOLVE (eresolve_tac [asm_rl, less_not_refl2, 
paulson@2516
    51
			       less_not_refl2 RS not_sym] 1));
paulson@2449
    52
result();
paulson@2449
    53
paulson@2449
    54
paulson@2516
    55
(*Case three: Alice, Bob, Charlie and the server
paulson@2481
    56
goal thy
paulson@2516
    57
 "!!A B. [| A ~= B; B ~= C; A ~= Server; B ~= Server; C ~= Server |]   \
paulson@2449
    58
\ ==> EX K. EX NA. EX evs: recur lost.          \
paulson@2516
    59
\       Says B A {|Crypt (shrK A) {|Key K, Agent B, Nonce NA|}, \
paulson@2449
    60
\                       Agent Server|}                          \
paulson@2449
    61
\         : set_of_list evs";
paulson@2516
    62
by (cut_facts_tac [Nonce_supply3, Key_supply3] 1);
paulson@2516
    63
by (REPEAT (eresolve_tac [exE, conjE] 1));
paulson@2449
    64
by (REPEAT (resolve_tac [exI,bexI] 1));
paulson@2451
    65
by (rtac (recur.Nil RS recur.RA1 RS recur.RA2 RS recur.RA2 RS 
paulson@2516
    66
          (respond.One RS respond.Cons RS respond.Cons RSN
paulson@2516
    67
           (4,recur.RA3)) RS recur.RA4 RS recur.RA4) 2);
paulson@2516
    68
(*SLOW: 70 seconds*)
paulson@2516
    69
by basic_possibility_tac;
paulson@2516
    70
by (DEPTH_SOLVE (swap_res_tac [refl, conjI, disjCI] 1 
paulson@2516
    71
		 ORELSE
paulson@2516
    72
		 eresolve_tac [asm_rl, less_not_refl2, 
paulson@2516
    73
			       less_not_refl2 RS not_sym] 1));
paulson@2449
    74
result();
paulson@2516
    75
****************)
paulson@2449
    76
paulson@2449
    77
(**** Inductive proofs about recur ****)
paulson@2449
    78
paulson@2449
    79
(*Monotonicity*)
paulson@2449
    80
goal thy "!!evs. lost' <= lost ==> recur lost' <= recur lost";
paulson@2449
    81
by (rtac subsetI 1);
paulson@2449
    82
by (etac recur.induct 1);
paulson@2449
    83
by (REPEAT_FIRST
paulson@2449
    84
    (best_tac (!claset addIs (impOfSubs (sees_mono RS analz_mono RS synth_mono)
paulson@2449
    85
                              :: recur.intrs))));
paulson@2449
    86
qed "recur_mono";
paulson@2449
    87
paulson@2449
    88
(*Nobody sends themselves messages*)
paulson@2449
    89
goal thy "!!evs. evs : recur lost ==> ALL A X. Says A A X ~: set_of_list evs";
paulson@2449
    90
by (etac recur.induct 1);
paulson@2449
    91
by (Auto_tac());
paulson@2449
    92
qed_spec_mp "not_Says_to_self";
paulson@2449
    93
Addsimps [not_Says_to_self];
paulson@2449
    94
AddSEs   [not_Says_to_self RSN (2, rev_notE)];
paulson@2449
    95
paulson@2449
    96
paulson@2516
    97
paulson@2516
    98
goal thy "!!evs. (PA,RB,KAB) : respond evs ==> Key KAB : parts{RB}";
paulson@2516
    99
by (etac respond.induct 1);
paulson@2516
   100
by (ALLGOALS Simp_tac);
paulson@2516
   101
qed "respond_Key_in_parts";
paulson@2516
   102
paulson@2516
   103
goal thy "!!evs. (PA,RB,KAB) : respond evs ==> Key KAB ~: used evs";
paulson@2516
   104
by (etac respond.induct 1);
paulson@2516
   105
by (REPEAT (assume_tac 1));
paulson@2516
   106
qed "respond_imp_not_used";
paulson@2516
   107
paulson@2516
   108
goal thy
paulson@2516
   109
 "!!evs. [| Key K : parts {RB};  (PB,RB,K') : respond evs |] \
paulson@2516
   110
\        ==> Key K ~: used evs";
paulson@2516
   111
by (etac rev_mp 1);
paulson@2516
   112
by (etac respond.induct 1);
paulson@2516
   113
by (auto_tac(!claset addDs [Key_not_used, respond_imp_not_used],
paulson@2516
   114
             !simpset));
paulson@2516
   115
qed_spec_mp "Key_in_parts_respond";
paulson@2516
   116
paulson@2449
   117
(*Simple inductive reasoning about responses*)
paulson@2516
   118
goal thy "!!evs. (PA,RB,KAB) : respond evs ==> RB : responses evs";
paulson@2449
   119
by (etac respond.induct 1);
paulson@2516
   120
by (REPEAT (ares_tac (respond_imp_not_used::responses.intrs) 1));
paulson@2449
   121
qed "respond_imp_responses";
paulson@2449
   122
paulson@2449
   123
paulson@2449
   124
(** For reasoning about the encrypted portion of messages **)
paulson@2449
   125
paulson@2451
   126
val RA2_analz_sees_Spy = Says_imp_sees_Spy RS analz.Inj |> standard;
paulson@2449
   127
paulson@2516
   128
goal thy "!!evs. Says C' B {|X, X', RA|} : set_of_list evs \
paulson@2449
   129
\                ==> RA : analz (sees lost Spy evs)";
paulson@2449
   130
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS analz.Inj]) 1);
paulson@2451
   131
qed "RA4_analz_sees_Spy";
paulson@2449
   132
paulson@2451
   133
(*RA2_analz... and RA4_analz... let us treat those cases using the same 
paulson@2449
   134
  argument as for the Fake case.  This is possible for most, but not all,
paulson@2451
   135
  proofs: Fake does not invent new nonces (as in RA2), and of course Fake
paulson@2449
   136
  messages originate from the Spy. *)
paulson@2449
   137
paulson@2451
   138
bind_thm ("RA2_parts_sees_Spy",
paulson@2451
   139
          RA2_analz_sees_Spy RS (impOfSubs analz_subset_parts));
paulson@2451
   140
bind_thm ("RA4_parts_sees_Spy",
paulson@2451
   141
          RA4_analz_sees_Spy RS (impOfSubs analz_subset_parts));
paulson@2449
   142
paulson@2449
   143
(*We instantiate the variable to "lost".  Leaving it as a Var makes proofs
paulson@2449
   144
  harder to complete, since simplification does less for us.*)
paulson@2449
   145
val parts_Fake_tac = 
paulson@2449
   146
    let val tac = forw_inst_tac [("lost","lost")] 
paulson@2451
   147
    in  tac RA2_parts_sees_Spy 4              THEN
paulson@2485
   148
        etac subst 4 (*RA2: DELETE needless definition of PA!*)  THEN
paulson@2516
   149
        forward_tac [respond_imp_responses] 5 THEN
paulson@2516
   150
        tac RA4_parts_sees_Spy 6
paulson@2449
   151
    end;
paulson@2449
   152
paulson@2449
   153
(*For proving the easier theorems about X ~: parts (sees lost Spy evs) *)
paulson@2449
   154
fun parts_induct_tac i = SELECT_GOAL
paulson@2449
   155
    (DETERM (etac recur.induct 1 THEN parts_Fake_tac THEN
paulson@2449
   156
             (*Fake message*)
paulson@2449
   157
             TRY (best_tac (!claset addDs [impOfSubs analz_subset_parts,
paulson@2449
   158
                                           impOfSubs Fake_parts_insert]
paulson@2449
   159
                                    addss (!simpset)) 2)) THEN
paulson@2449
   160
     (*Base case*)
paulson@2449
   161
     fast_tac (!claset addss (!simpset)) 1 THEN
paulson@2449
   162
     ALLGOALS Asm_simp_tac) i;
paulson@2449
   163
paulson@2449
   164
(** Theorems of the form X ~: parts (sees lost Spy evs) imply that NOBODY
paulson@2449
   165
    sends messages containing X! **)
paulson@2449
   166
paulson@2449
   167
paulson@2449
   168
(** Spy never sees another agent's long-term key (unless initially lost) **)
paulson@2449
   169
paulson@2449
   170
goal thy 
paulson@2449
   171
 "!!evs. evs : recur lost \
paulson@2449
   172
\        ==> (Key (shrK A) : parts (sees lost Spy evs)) = (A : lost)";
paulson@2449
   173
by (parts_induct_tac 1);
paulson@2451
   174
(*RA2*)
paulson@2449
   175
by (best_tac (!claset addSEs partsEs addSDs [parts_cut]
paulson@2449
   176
                      addss (!simpset)) 1);
paulson@2451
   177
(*RA3*)
paulson@2449
   178
by (fast_tac (!claset addDs [Key_in_parts_respond]
paulson@2449
   179
                      addss (!simpset addsimps [parts_insert_sees])) 1);
paulson@2449
   180
qed "Spy_see_shrK";
paulson@2449
   181
Addsimps [Spy_see_shrK];
paulson@2449
   182
paulson@2449
   183
goal thy 
paulson@2449
   184
 "!!evs. evs : recur lost \
paulson@2449
   185
\        ==> (Key (shrK A) : analz (sees lost Spy evs)) = (A : lost)";
paulson@2449
   186
by (auto_tac(!claset addDs [impOfSubs analz_subset_parts], !simpset));
paulson@2449
   187
qed "Spy_analz_shrK";
paulson@2449
   188
Addsimps [Spy_analz_shrK];
paulson@2449
   189
paulson@2449
   190
goal thy  "!!A. [| Key (shrK A) : parts (sees lost Spy evs);       \
paulson@2449
   191
\                  evs : recur lost |] ==> A:lost";
paulson@2449
   192
by (fast_tac (!claset addDs [Spy_see_shrK]) 1);
paulson@2449
   193
qed "Spy_see_shrK_D";
paulson@2449
   194
paulson@2449
   195
bind_thm ("Spy_analz_shrK_D", analz_subset_parts RS subsetD RS Spy_see_shrK_D);
paulson@2449
   196
AddSDs [Spy_see_shrK_D, Spy_analz_shrK_D];
paulson@2449
   197
paulson@2449
   198
paulson@2516
   199
paulson@2516
   200
(** Nobody can have used non-existent keys! **)
paulson@2449
   201
paulson@2516
   202
goal thy
paulson@2516
   203
 "!!evs. [| K : keysFor (parts {RB});  (PB,RB,K') : respond evs |] \
paulson@2516
   204
\        ==> K : range shrK";
paulson@2516
   205
by (etac rev_mp 1);
paulson@2516
   206
by (etac (respond_imp_responses RS responses.induct) 1);
paulson@2449
   207
by (Auto_tac());
paulson@2516
   208
qed_spec_mp "Key_in_keysFor_parts";
paulson@2449
   209
paulson@2449
   210
paulson@2516
   211
goal thy "!!evs. evs : recur lost ==>          \
paulson@2516
   212
\       Key K ~: used evs --> K ~: keysFor (parts (sees lost Spy evs))";
paulson@2449
   213
by (parts_induct_tac 1);
paulson@2451
   214
(*RA3*)
paulson@2516
   215
by (best_tac (!claset addDs  [Key_in_keysFor_parts]
paulson@2516
   216
                      addss  (!simpset addsimps [parts_insert_sees])) 2);
paulson@2516
   217
(*Fake*)
paulson@2516
   218
by (best_tac
paulson@2516
   219
      (!claset addIs [impOfSubs analz_subset_parts]
paulson@2516
   220
               addDs [impOfSubs (analz_subset_parts RS keysFor_mono),
paulson@2516
   221
                      impOfSubs (parts_insert_subset_Un RS keysFor_mono)]
paulson@2516
   222
               addss (!simpset)) 1);
paulson@2449
   223
qed_spec_mp "new_keys_not_used";
paulson@2449
   224
paulson@2449
   225
paulson@2449
   226
bind_thm ("new_keys_not_analzd",
paulson@2449
   227
          [analz_subset_parts RS keysFor_mono,
paulson@2449
   228
           new_keys_not_used] MRS contra_subsetD);
paulson@2449
   229
paulson@2449
   230
Addsimps [new_keys_not_used, new_keys_not_analzd];
paulson@2449
   231
paulson@2449
   232
paulson@2449
   233
paulson@2449
   234
(*** Proofs involving analz ***)
paulson@2449
   235
paulson@2449
   236
(*For proofs involving analz.  We again instantiate the variable to "lost".*)
paulson@2449
   237
val analz_Fake_tac = 
paulson@2485
   238
    etac subst 4 (*RA2: DELETE needless definition of PA!*)  THEN
paulson@2451
   239
    dres_inst_tac [("lost","lost")] RA2_analz_sees_Spy 4 THEN 
paulson@2449
   240
    forward_tac [respond_imp_responses] 5                THEN
paulson@2451
   241
    dres_inst_tac [("lost","lost")] RA4_analz_sees_Spy 6;
paulson@2449
   242
paulson@2449
   243
paulson@2449
   244
(** Session keys are not used to encrypt other session keys **)
paulson@2449
   245
paulson@2451
   246
(*Version for "responses" relation.  Handles case RA3 in the theorem below.  
paulson@2449
   247
  Note that it holds for *any* set H (not just "sees lost Spy evs")
paulson@2449
   248
  satisfying the inductive hypothesis.*)
paulson@2449
   249
goal thy  
paulson@2516
   250
 "!!evs. [| RB : responses evs;                             \
paulson@2516
   251
\           ALL K KK. KK <= Compl (range shrK) -->          \
paulson@2516
   252
\                     (Key K : analz (Key``KK Un H)) =      \
paulson@2516
   253
\                     (K : KK | Key K : analz H) |]         \
paulson@2516
   254
\       ==> ALL K KK. KK <= Compl (range shrK) -->          \
paulson@2516
   255
\                     (Key K : analz (insert RB (Key``KK Un H))) = \
paulson@2516
   256
\                     (K : KK | Key K : analz (insert RB H))";
paulson@2516
   257
by (etac responses.induct 1);
paulson@2516
   258
by (ALLGOALS (asm_simp_tac analz_image_freshK_ss));
paulson@2516
   259
qed "resp_analz_image_freshK_lemma";
paulson@2449
   260
paulson@2449
   261
(*Version for the protocol.  Proof is almost trivial, thanks to the lemma.*)
paulson@2449
   262
goal thy  
paulson@2516
   263
 "!!evs. evs : recur lost ==>                                   \
paulson@2516
   264
\  ALL K KK. KK <= Compl (range shrK) -->                       \
paulson@2516
   265
\            (Key K : analz (Key``KK Un (sees lost Spy evs))) = \
paulson@2516
   266
\            (K : KK | Key K : analz (sees lost Spy evs))";
paulson@2449
   267
by (etac recur.induct 1);
paulson@2449
   268
by analz_Fake_tac;
paulson@2516
   269
by (REPEAT_FIRST (resolve_tac [allI, impI]));
paulson@2516
   270
by (REPEAT_FIRST (rtac analz_image_freshK_lemma ));
paulson@2516
   271
by (ALLGOALS 
paulson@2516
   272
    (asm_simp_tac
paulson@2516
   273
     (analz_image_freshK_ss addsimps [resp_analz_image_freshK_lemma])));
paulson@2449
   274
(*Base*)
paulson@2449
   275
by (fast_tac (!claset addIs [image_eqI] addss (!simpset)) 1);
paulson@2451
   276
(*RA4, RA2, Fake*) 
paulson@2449
   277
by (REPEAT (spy_analz_tac 1));
paulson@2516
   278
val raw_analz_image_freshK = result();
paulson@2516
   279
qed_spec_mp "analz_image_freshK";
paulson@2449
   280
paulson@2449
   281
paulson@2449
   282
(*Instance of the lemma with H replaced by (sees lost Spy evs):
paulson@2516
   283
   [| RB : responses evs;  evs : recur lost; |]
paulson@2516
   284
   ==> KK <= Compl (range shrK) --> 
paulson@2516
   285
       Key K : analz (insert RB (Key``KK Un sees lost Spy evs)) =
paulson@2516
   286
       (K : KK | Key K : analz (insert RB (sees lost Spy evs))) 
paulson@2449
   287
*)
paulson@2516
   288
bind_thm ("resp_analz_image_freshK",
paulson@2516
   289
          raw_analz_image_freshK RSN
paulson@2516
   290
            (2, resp_analz_image_freshK_lemma) RS spec RS spec);
paulson@2449
   291
paulson@2449
   292
goal thy
paulson@2516
   293
 "!!evs. [| evs : recur lost;  KAB ~: range shrK |] ==>              \
paulson@2516
   294
\        Key K : analz (insert (Key KAB) (sees lost Spy evs)) =      \
paulson@2516
   295
\        (K = KAB | Key K : analz (sees lost Spy evs))";
paulson@2516
   296
by (asm_simp_tac (analz_image_freshK_ss addsimps [analz_image_freshK]) 1);
paulson@2516
   297
qed "analz_insert_freshK";
paulson@2449
   298
paulson@2449
   299
paulson@2516
   300
(*Everything that's hashed is already in past traffic. *)
paulson@2485
   301
goal thy "!!i. [| evs : recur lost;  A ~: lost |] ==>              \
paulson@2485
   302
\              Hash {|Key(shrK A), X|} : parts (sees lost Spy evs) -->  \
paulson@2485
   303
\              X : parts (sees lost Spy evs)";
paulson@2516
   304
by (etac recur.induct 1);
paulson@2449
   305
by parts_Fake_tac;
paulson@2451
   306
(*RA3 requires a further induction*)
paulson@2516
   307
by (etac responses.induct 5);
paulson@2449
   308
by (ALLGOALS Asm_simp_tac);
paulson@2449
   309
(*Fake*)
paulson@2485
   310
by (best_tac (!claset addDs [impOfSubs analz_subset_parts,
paulson@2516
   311
                             impOfSubs Fake_parts_insert]
paulson@2516
   312
                      addss (!simpset addsimps [parts_insert_sees])) 2);
paulson@2485
   313
(*Two others*)
paulson@2485
   314
by (REPEAT (fast_tac (!claset addss (!simpset)) 1));
paulson@2485
   315
bind_thm ("Hash_imp_body", result() RSN (2, rev_mp));
paulson@2449
   316
paulson@2449
   317
paulson@2449
   318
(** The Nonce NA uniquely identifies A's message. 
paulson@2516
   319
    This theorem applies to steps RA1 and RA2!
paulson@2455
   320
paulson@2455
   321
  Unicity is not used in other proofs but is desirable in its own right.
paulson@2449
   322
**)
paulson@2449
   323
paulson@2449
   324
goal thy 
paulson@2449
   325
 "!!evs. [| evs : recur lost; A ~: lost |]               \
paulson@2449
   326
\ ==> EX B' P'. ALL B P.    \
paulson@2449
   327
\        Hash {|Key(shrK A), Agent A, Agent B, Nonce NA, P|} \
paulson@2449
   328
\          : parts (sees lost Spy evs)  -->  B=B' & P=P'";
paulson@2485
   329
by (parts_induct_tac 1);
paulson@2516
   330
by (etac responses.induct 3);
paulson@2485
   331
by (ALLGOALS (simp_tac (!simpset addsimps [all_conj_distrib]))); 
paulson@2449
   332
by (step_tac (!claset addSEs partsEs) 1);
paulson@2516
   333
(*RA1,2: creation of new Nonce.  Move assertion into global context*)
paulson@2516
   334
by (ALLGOALS (expand_case_tac "NA = ?y"));
paulson@2516
   335
by (REPEAT_FIRST (ares_tac [exI]));
paulson@2516
   336
by (REPEAT (best_tac (!claset addSDs [Hash_imp_body]
paulson@2516
   337
                              addSEs sees_Spy_partsEs) 1));
paulson@2449
   338
val lemma = result();
paulson@2449
   339
paulson@2481
   340
goalw thy [HPair_def]
paulson@2516
   341
 "!!evs.[| Hash[Key(shrK A)] {|Agent A, Agent B, Nonce NA, P|}   \
paulson@2485
   342
\            : parts (sees lost Spy evs);                          \
paulson@2516
   343
\          Hash[Key(shrK A)] {|Agent A, Agent B', Nonce NA, P'|} \
paulson@2485
   344
\            : parts (sees lost Spy evs);                          \
paulson@2485
   345
\          evs : recur lost;  A ~: lost |]                         \
paulson@2449
   346
\        ==> B=B' & P=P'";
paulson@2481
   347
by (REPEAT (eresolve_tac partsEs 1));
paulson@2449
   348
by (prove_unique_tac lemma 1);
paulson@2449
   349
qed "unique_NA";
paulson@2449
   350
paulson@2449
   351
paulson@2449
   352
(*** Lemmas concerning the Server's response
paulson@2449
   353
      (relations "respond" and "responses") 
paulson@2449
   354
***)
paulson@2449
   355
paulson@2449
   356
goal thy
paulson@2516
   357
 "!!evs. [| RB : responses evs;  evs : recur lost |] \
paulson@2449
   358
\ ==> (Key (shrK B) : analz (insert RB (sees lost Spy evs))) = (B:lost)";
paulson@2516
   359
by (etac responses.induct 1);
paulson@2449
   360
by (ALLGOALS
paulson@2449
   361
    (asm_simp_tac 
paulson@2516
   362
     (analz_image_freshK_ss addsimps [Spy_analz_shrK,
paulson@2516
   363
                                      resp_analz_image_freshK])));
paulson@2449
   364
qed "shrK_in_analz_respond";
paulson@2449
   365
Addsimps [shrK_in_analz_respond];
paulson@2449
   366
paulson@2449
   367
paulson@2449
   368
goal thy  
paulson@2516
   369
 "!!evs. [| RB : responses evs;                             \
paulson@2516
   370
\           ALL K KK. KK <= Compl (range shrK) -->          \
paulson@2516
   371
\                     (Key K : analz (Key``KK Un H)) =      \
paulson@2516
   372
\                     (K : KK | Key K : analz H) |]         \
paulson@2449
   373
\       ==> (Key K : analz (insert RB H)) --> \
paulson@2516
   374
\           (Key K : parts{RB} | Key K : analz H)";
paulson@2516
   375
by (etac responses.induct 1);
paulson@2449
   376
by (ALLGOALS
paulson@2449
   377
    (asm_simp_tac 
paulson@2516
   378
     (analz_image_freshK_ss addsimps [resp_analz_image_freshK_lemma])));
paulson@2516
   379
(*Simplification using two distinct treatments of "image"*)
paulson@2516
   380
by (simp_tac (!simpset addsimps [parts_insert2]) 1);
paulson@2449
   381
by (fast_tac (!claset delrules [allE]) 1);
paulson@2449
   382
qed "resp_analz_insert_lemma";
paulson@2449
   383
paulson@2449
   384
bind_thm ("resp_analz_insert",
paulson@2516
   385
          raw_analz_image_freshK RSN
paulson@2516
   386
            (2, resp_analz_insert_lemma) RSN(2, rev_mp));
paulson@2449
   387
paulson@2449
   388
paulson@2449
   389
(*The Server does not send such messages.  This theorem lets us avoid
paulson@2451
   390
  assuming B~=Server in RA4.*)
paulson@2449
   391
goal thy 
paulson@2449
   392
 "!!evs. evs : recur lost       \
paulson@2449
   393
\ ==> ALL C X Y P. Says Server C {|X, Agent Server, Agent C, Y, P|} \
paulson@2449
   394
\                  ~: set_of_list evs";
paulson@2449
   395
by (etac recur.induct 1);
paulson@2516
   396
by (etac (respond.induct) 5);
paulson@2449
   397
by (Auto_tac());
paulson@2449
   398
qed_spec_mp "Says_Server_not";
paulson@2449
   399
AddSEs [Says_Server_not RSN (2,rev_notE)];
paulson@2449
   400
paulson@2449
   401
paulson@2516
   402
(*The last key returned by respond indeed appears in a certificate*)
paulson@2449
   403
goal thy 
paulson@2516
   404
 "!!K. (Hash[Key(shrK A)] {|Agent A, B, NA, P|}, RA, K) : respond evs \
paulson@2516
   405
\ ==> Crypt (shrK A) {|Key K, B, NA|} : parts {RA}";
paulson@2516
   406
by (etac respond.elim 1);
paulson@2516
   407
by (ALLGOALS Asm_full_simp_tac);
paulson@2516
   408
qed "respond_certificate";
paulson@2516
   409
paulson@2516
   410
paulson@2516
   411
goal thy 
paulson@2516
   412
 "!!K'. (PB,RB,KXY) : respond evs               \
paulson@2516
   413
\  ==> EX A' B'. ALL A B N.              \
paulson@2449
   414
\        Crypt (shrK A) {|Key K, Agent B, N|} : parts {RB} \
paulson@2449
   415
\          -->   (A'=A & B'=B) | (A'=B & B'=A)";
paulson@2516
   416
by (etac respond.induct 1);
paulson@2449
   417
by (ALLGOALS (asm_full_simp_tac (!simpset addsimps [all_conj_distrib]))); 
paulson@2449
   418
(*Base case*)
paulson@2449
   419
by (Fast_tac 1);
paulson@2449
   420
by (Step_tac 1);
paulson@2516
   421
(*Case analysis on K=KBC*)
paulson@2449
   422
by (expand_case_tac "K = ?y" 1);
paulson@2516
   423
by (dtac respond_Key_in_parts 1);
paulson@2449
   424
by (best_tac (!claset addSIs [exI]
paulson@2449
   425
                      addSEs partsEs
paulson@2516
   426
                      addDs [Key_in_parts_respond]) 1);
paulson@2516
   427
(*Case analysis on K=KAB*)
paulson@2449
   428
by (expand_case_tac "K = ?y" 1);
paulson@2449
   429
by (REPEAT (ares_tac [exI] 2));
paulson@2449
   430
by (ex_strip_tac 1);
paulson@2516
   431
by (dtac respond_certificate 1);
paulson@2449
   432
by (Fast_tac 1);
paulson@2449
   433
val lemma = result();
paulson@2449
   434
paulson@2449
   435
goal thy 
paulson@2449
   436
 "!!RB. [| Crypt (shrK A) {|Key K, Agent B, N|} : parts {RB};    \
paulson@2449
   437
\          Crypt (shrK A') {|Key K, Agent B', N'|} : parts {RB};   \
paulson@2516
   438
\          (PB,RB,KXY) : respond evs |]               \
paulson@2449
   439
\ ==>   (A'=A & B'=B) | (A'=B & B'=A)";
paulson@2516
   440
by (prove_unique_tac lemma 1);  (*50 seconds??, due to the disjunctions*)
paulson@2449
   441
qed "unique_session_keys";
paulson@2449
   442
paulson@2449
   443
paulson@2451
   444
(** Crucial secrecy property: Spy does not see the keys sent in msg RA3
paulson@2449
   445
    Does not in itself guarantee security: an attack could violate 
paulson@2449
   446
    the premises, e.g. by having A=Spy **)
paulson@2449
   447
paulson@2449
   448
goal thy 
paulson@2516
   449
 "!!evs. [| (PB,RB,KAB) : respond evs;  evs : recur lost |]       \
paulson@2449
   450
\        ==> ALL A A' N. A ~: lost & A' ~: lost -->  \
paulson@2449
   451
\            Crypt (shrK A) {|Key K, Agent A', N|} : parts{RB} -->  \
paulson@2449
   452
\            Key K ~: analz (insert RB (sees lost Spy evs))";
paulson@2516
   453
by (etac respond.induct 1);
paulson@2449
   454
by (forward_tac [respond_imp_responses] 2);
paulson@2516
   455
by (forward_tac [respond_imp_not_used] 2);
paulson@2516
   456
by (ALLGOALS (*43 seconds*)
paulson@2449
   457
    (asm_simp_tac 
paulson@2516
   458
     (analz_image_freshK_ss addsimps 
paulson@2516
   459
          [analz_image_freshK, not_parts_not_analz,
paulson@2516
   460
           shrK_in_analz_respond,
paulson@2516
   461
           read_instantiate [("H", "?ff``?xx")] parts_insert,
paulson@2516
   462
           resp_analz_image_freshK, analz_insert_freshK])));
paulson@2516
   463
by (ALLGOALS Simp_tac);
paulson@2516
   464
by (fast_tac (!claset addIs [impOfSubs analz_subset_parts]) 1);
paulson@2449
   465
by (step_tac (!claset addSEs [MPair_parts]) 1);
paulson@2516
   466
(** LEVEL 7 **)
paulson@2516
   467
by (fast_tac (!claset addSDs [resp_analz_insert, Key_in_parts_respond]
paulson@2516
   468
                      addDs  [impOfSubs analz_subset_parts]) 4);
paulson@2516
   469
by (fast_tac (!claset addSDs [respond_certificate]) 3);
paulson@2449
   470
by (best_tac (!claset addSEs partsEs
paulson@2449
   471
                      addDs [Key_in_parts_respond]
paulson@2449
   472
                      addss (!simpset)) 2);
paulson@2516
   473
by (dtac unique_session_keys 1);
paulson@2516
   474
by (etac respond_certificate 1);
paulson@2516
   475
by (assume_tac 1);
paulson@2516
   476
by (Fast_tac 1);
paulson@2449
   477
qed_spec_mp "respond_Spy_not_see_encrypted_key";
paulson@2449
   478
paulson@2449
   479
paulson@2449
   480
goal thy
paulson@2455
   481
 "!!evs. [| A ~: lost;  A' ~: lost;  evs : recur lost |]            \
paulson@2455
   482
\        ==> Says Server B RB : set_of_list evs -->                 \
paulson@2449
   483
\            Crypt (shrK A) {|Key K, Agent A', N|} : parts{RB} -->  \
paulson@2449
   484
\            Key K ~: analz (sees lost Spy evs)";
paulson@2449
   485
by (etac recur.induct 1);
paulson@2449
   486
by analz_Fake_tac;
paulson@2449
   487
by (ALLGOALS
paulson@2449
   488
    (asm_simp_tac
paulson@2516
   489
     (!simpset addsimps [not_parts_not_analz, analz_insert_freshK] 
paulson@2449
   490
               setloop split_tac [expand_if])));
paulson@2451
   491
(*RA4*)
paulson@2449
   492
by (spy_analz_tac 4);
paulson@2449
   493
(*Fake*)
paulson@2449
   494
by (spy_analz_tac 1);
paulson@2449
   495
by (step_tac (!claset delrules [impCE]) 1);
paulson@2451
   496
(*RA2*)
paulson@2449
   497
by (spy_analz_tac 1);
paulson@2451
   498
(*RA3, case 2: K is an old key*)
paulson@2516
   499
by (best_tac (!claset addSDs [resp_analz_insert]
paulson@2516
   500
                      addSEs partsEs
paulson@2516
   501
                      addDs [Key_in_parts_respond, 
paulson@2516
   502
                             Says_imp_sees_Spy RS parts.Inj RSN (2, parts_cut)]
paulson@2516
   503
                      addss (!simpset)) 2);
paulson@2451
   504
(*RA3, case 1: use lemma previously proved by induction*)
paulson@2449
   505
by (fast_tac (!claset addSEs [respond_Spy_not_see_encrypted_key RSN
paulson@2516
   506
                              (2,rev_notE)]) 1);
paulson@2449
   507
bind_thm ("Spy_not_see_encrypted_key", result() RS mp RSN (2, rev_mp));
paulson@2449
   508
paulson@2449
   509
paulson@2449
   510
goal thy 
paulson@2455
   511
 "!!evs. [| Says Server B RB : set_of_list evs;                 \
paulson@2449
   512
\           Crypt (shrK A) {|Key K, Agent A', N|} : parts{RB};  \
paulson@2455
   513
\           C ~: {A,A',Server};                                 \
paulson@2455
   514
\           A ~: lost;  A' ~: lost;  evs : recur lost |]        \
paulson@2449
   515
\        ==> Key K ~: analz (sees lost C evs)";
paulson@2449
   516
by (rtac (subset_insertI RS sees_mono RS analz_mono RS contra_subsetD) 1);
paulson@2449
   517
by (rtac (sees_lost_agent_subset_sees_Spy RS analz_mono RS contra_subsetD) 1);
paulson@2449
   518
by (FIRSTGOAL (rtac Spy_not_see_encrypted_key));
paulson@2449
   519
by (REPEAT_FIRST (fast_tac (!claset addIs [recur_mono RS subsetD])));
paulson@2449
   520
qed "Agent_not_see_encrypted_key";
paulson@2449
   521
paulson@2449
   522
paulson@2449
   523
(**** Authenticity properties for Agents ****)
paulson@2449
   524
paulson@2481
   525
(*The response never contains Hashes*)
paulson@2481
   526
goal thy
paulson@2516
   527
 "!!evs. (PB,RB,K) : respond evs \
paulson@2481
   528
\        ==> Hash {|Key (shrK B), M|} : parts (insert RB H) --> \
paulson@2481
   529
\            Hash {|Key (shrK B), M|} : parts H";
paulson@2516
   530
by (etac (respond_imp_responses RS responses.induct) 1);
paulson@2481
   531
by (Auto_tac());
paulson@2481
   532
bind_thm ("Hash_in_parts_respond", result() RSN (2, rev_mp));
paulson@2481
   533
paulson@2451
   534
(*Only RA1 or RA2 can have caused such a part of a message to appear.*)
paulson@2481
   535
goalw thy [HPair_def]
paulson@2449
   536
 "!!evs. [| Hash {|Key(shrK A), Agent A, Agent B, NA, P|}         \
paulson@2449
   537
\             : parts (sees lost Spy evs);                        \
paulson@2449
   538
\            A ~: lost;  evs : recur lost |]                        \
paulson@2516
   539
\        ==> Says A B (Hash[Key(shrK A)] {|Agent A, Agent B, NA, P|})  \
paulson@2449
   540
\             : set_of_list evs";
paulson@2516
   541
by (etac rev_mp 1);
paulson@2449
   542
by (parts_induct_tac 1);
paulson@2451
   543
(*RA3*)
paulson@2485
   544
by (fast_tac (!claset addSDs [Hash_in_parts_respond]) 1);
paulson@2449
   545
qed_spec_mp "Hash_auth_sender";
paulson@2449
   546
paulson@2449
   547
paulson@2516
   548
(** These two results subsume (for all agents) the guarantees proved
paulson@2449
   549
    separately for A and B in the Otway-Rees protocol.
paulson@2449
   550
**)
paulson@2449
   551
paulson@2449
   552
paulson@2455
   553
(*Encrypted messages can only originate with the Server.*)
paulson@2449
   554
goal thy 
paulson@2455
   555
 "!!evs. [| A ~: lost;  A ~= Spy;  evs : recur lost |]       \
paulson@2455
   556
\    ==> Crypt (shrK A) Y : parts (sees lost Spy evs)        \
paulson@2455
   557
\        --> (EX C RC. Says Server C RC : set_of_list evs &  \
paulson@2455
   558
\                      Crypt (shrK A) Y : parts {RC})";
paulson@2449
   559
by (parts_induct_tac 1);
paulson@2451
   560
(*RA4*)
paulson@2455
   561
by (Fast_tac 4);
paulson@2455
   562
(*RA3*)
paulson@2455
   563
by (full_simp_tac (!simpset addsimps [parts_insert_sees]) 3
paulson@2455
   564
    THEN Fast_tac 3);
paulson@2455
   565
(*RA1*)
paulson@2455
   566
by (Fast_tac 1);
paulson@2451
   567
(*RA2: it cannot be a new Nonce, contradiction.*)
paulson@2449
   568
by (deepen_tac (!claset delrules [impCE]
paulson@2449
   569
                      addSIs [disjI2]
paulson@2455
   570
                      addSEs [MPair_parts]
paulson@2449
   571
                      addDs  [parts_cut, parts.Body]
paulson@2449
   572
                      addss  (!simpset)) 0 1);
paulson@2449
   573
qed_spec_mp "Crypt_imp_Server_msg";
paulson@2449
   574
paulson@2449
   575
paulson@2455
   576
(*Corollary: if A receives B's message then the key came from the Server*)
paulson@2449
   577
goal thy 
paulson@2449
   578
 "!!evs. [| Says B' A RA : set_of_list evs;                        \
paulson@2455
   579
\           Crypt (shrK A) {|Key K, Agent A', NA|} : parts {RA};   \
paulson@2449
   580
\           A ~: lost;  A ~= Spy;  evs : recur lost |]             \
paulson@2455
   581
\        ==> EX C RC. Says Server C RC : set_of_list evs &         \
paulson@2451
   582
\                       Crypt (shrK A) {|Key K, Agent A', NA|} : parts {RC}";
paulson@2449
   583
by (best_tac (!claset addSIs [Crypt_imp_Server_msg]
paulson@2449
   584
                      addDs  [Says_imp_sees_Spy RS parts.Inj RSN (2,parts_cut)]
paulson@2449
   585
                      addss  (!simpset)) 1);
paulson@2449
   586
qed "Agent_trust";
paulson@2449
   587
paulson@2449
   588
paulson@2455
   589
(*Overall guarantee: if A receives a certificant mentioning A'
paulson@2455
   590
  then the only other agent who knows the key is A'.*)
paulson@2449
   591
goal thy 
paulson@2449
   592
 "!!evs. [| Says B' A RA : set_of_list evs;                           \
paulson@2451
   593
\           Crypt (shrK A) {|Key K, Agent A', NA|} : parts {RA};      \
paulson@2451
   594
\           C ~: {A,A',Server};                                       \
paulson@2451
   595
\           A ~: lost;  A' ~: lost;  A ~= Spy;  evs : recur lost |]   \
paulson@2449
   596
\        ==> Key K ~: analz (sees lost C evs)";
paulson@2449
   597
by (dtac Agent_trust 1 THEN REPEAT_FIRST assume_tac);
paulson@2449
   598
by (fast_tac (!claset addSEs [Agent_not_see_encrypted_key RSN(2,rev_notE)]) 1);
paulson@2449
   599
qed "Agent_secrecy";
paulson@2449
   600