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