src/HOL/Auth/Recur.ML
author paulson
Thu Jan 08 18:10:34 1998 +0100 (1998-01-08)
changeset 4537 4e835bd9fada
parent 4509 828148415197
child 4552 bb8ff763c93d
permissions -rw-r--r--
Expressed most Oops rules using Notes instead of Says, and other tidying
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
wenzelm@4449
    11
set proof_timing;
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@3519
    25
\ ==> EX K NA. EX evs: recur.                                      \
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@3519
    38
\ ==> EX K. EX NA. EX evs: recur.                          \
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@3519
    57
\ ==> EX K. EX NA. EX evs: recur.                                 \
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
(*Nobody sends themselves messages*)
paulson@3519
    78
goal thy "!!evs. evs : recur ==> ALL A X. Says A A X ~: set evs";
paulson@2449
    79
by (etac recur.induct 1);
paulson@4477
    80
by Auto_tac;
paulson@2449
    81
qed_spec_mp "not_Says_to_self";
paulson@2449
    82
Addsimps [not_Says_to_self];
paulson@2449
    83
AddSEs   [not_Says_to_self RSN (2, rev_notE)];
paulson@2449
    84
paulson@2449
    85
paulson@2516
    86
paulson@2516
    87
goal thy "!!evs. (PA,RB,KAB) : respond evs ==> Key KAB : parts{RB}";
paulson@2516
    88
by (etac respond.induct 1);
paulson@2516
    89
by (ALLGOALS Simp_tac);
paulson@2516
    90
qed "respond_Key_in_parts";
paulson@2516
    91
paulson@2516
    92
goal thy "!!evs. (PA,RB,KAB) : respond evs ==> Key KAB ~: used evs";
paulson@2516
    93
by (etac respond.induct 1);
paulson@2516
    94
by (REPEAT (assume_tac 1));
paulson@2516
    95
qed "respond_imp_not_used";
paulson@2516
    96
paulson@2516
    97
goal thy
paulson@2516
    98
 "!!evs. [| Key K : parts {RB};  (PB,RB,K') : respond evs |] \
paulson@2516
    99
\        ==> Key K ~: used evs";
paulson@2516
   100
by (etac rev_mp 1);
paulson@2516
   101
by (etac respond.induct 1);
wenzelm@4091
   102
by (auto_tac(claset() addDs [Key_not_used, respond_imp_not_used],
wenzelm@4091
   103
             simpset()));
paulson@2516
   104
qed_spec_mp "Key_in_parts_respond";
paulson@2516
   105
paulson@2449
   106
(*Simple inductive reasoning about responses*)
paulson@2516
   107
goal thy "!!evs. (PA,RB,KAB) : respond evs ==> RB : responses evs";
paulson@2449
   108
by (etac respond.induct 1);
paulson@2516
   109
by (REPEAT (ares_tac (respond_imp_not_used::responses.intrs) 1));
paulson@2449
   110
qed "respond_imp_responses";
paulson@2449
   111
paulson@2449
   112
paulson@2449
   113
(** For reasoning about the encrypted portion of messages **)
paulson@2449
   114
paulson@3683
   115
val RA2_analz_spies = Says_imp_spies RS analz.Inj |> standard;
paulson@2449
   116
nipkow@3465
   117
goal thy "!!evs. Says C' B {|Crypt K X, X', RA|} : set evs \
paulson@3683
   118
\                ==> RA : analz (spies evs)";
wenzelm@4091
   119
by (blast_tac (claset() addSDs [Says_imp_spies RS analz.Inj]) 1);
paulson@3683
   120
qed "RA4_analz_spies";
paulson@2449
   121
paulson@2451
   122
(*RA2_analz... and RA4_analz... let us treat those cases using the same 
paulson@2449
   123
  argument as for the Fake case.  This is possible for most, but not all,
paulson@2451
   124
  proofs: Fake does not invent new nonces (as in RA2), and of course Fake
paulson@2449
   125
  messages originate from the Spy. *)
paulson@2449
   126
paulson@3683
   127
bind_thm ("RA2_parts_spies",
paulson@3683
   128
          RA2_analz_spies RS (impOfSubs analz_subset_parts));
paulson@3683
   129
bind_thm ("RA4_parts_spies",
paulson@3683
   130
          RA4_analz_spies RS (impOfSubs analz_subset_parts));
paulson@2449
   131
paulson@3683
   132
(*For proving the easier theorems about X ~: parts (spies evs).*)
paulson@3519
   133
fun parts_induct_tac i = 
paulson@3519
   134
    etac recur.induct i				THEN
paulson@3683
   135
    forward_tac [RA2_parts_spies] (i+3)	THEN
paulson@3519
   136
    etac subst (i+3) (*RA2: DELETE needless definition of PA!*)  THEN
paulson@3519
   137
    forward_tac [respond_imp_responses] (i+4)	THEN
paulson@3683
   138
    forward_tac [RA4_parts_spies] (i+5)	THEN
paulson@3519
   139
    prove_simple_subgoals_tac i;
paulson@2449
   140
paulson@2449
   141
paulson@3683
   142
(** Theorems of the form X ~: parts (spies evs) imply that NOBODY
paulson@2449
   143
    sends messages containing X! **)
paulson@2449
   144
paulson@2449
   145
paulson@3683
   146
(** Spy never sees another agent's shared key! (unless it's bad at start) **)
paulson@2449
   147
paulson@2449
   148
goal thy 
paulson@3683
   149
 "!!evs. evs : recur ==> (Key (shrK A) : parts (spies evs)) = (A : bad)";
paulson@3519
   150
by (parts_induct_tac 1);
paulson@3121
   151
by (Fake_parts_insert_tac 1);
paulson@3121
   152
by (ALLGOALS 
wenzelm@4091
   153
    (asm_simp_tac (simpset() addsimps [parts_insert2, parts_insert_spies])));
paulson@2550
   154
(*RA3*)
wenzelm@4091
   155
by (blast_tac (claset() addDs [Key_in_parts_respond]) 2);
paulson@2451
   156
(*RA2*)
wenzelm@4091
   157
by (blast_tac (claset() addSEs partsEs  addDs [parts_cut]) 1);
paulson@2449
   158
qed "Spy_see_shrK";
paulson@2449
   159
Addsimps [Spy_see_shrK];
paulson@2449
   160
paulson@2449
   161
goal thy 
paulson@3683
   162
 "!!evs. evs : recur ==> (Key (shrK A) : analz (spies evs)) = (A : bad)";
wenzelm@4091
   163
by (auto_tac(claset() addDs [impOfSubs analz_subset_parts], simpset()));
paulson@2449
   164
qed "Spy_analz_shrK";
paulson@2449
   165
Addsimps [Spy_analz_shrK];
paulson@2449
   166
paulson@4471
   167
AddSDs [Spy_see_shrK RSN (2, rev_iffD1), 
paulson@4471
   168
	Spy_analz_shrK RSN (2, rev_iffD1)];
paulson@2449
   169
paulson@2516
   170
paulson@2516
   171
(** Nobody can have used non-existent keys! **)
paulson@2449
   172
paulson@4509
   173
(*The special case of H={} has the same proof*)
paulson@2516
   174
goal thy
paulson@4509
   175
 "!!evs. [| K : keysFor (parts (insert RB H));  (PB,RB,K') : respond evs |] \
paulson@4509
   176
\        ==> K : range shrK | K : keysFor (parts H)";
paulson@2516
   177
by (etac rev_mp 1);
paulson@2516
   178
by (etac (respond_imp_responses RS responses.induct) 1);
paulson@4477
   179
by Auto_tac;
paulson@2516
   180
qed_spec_mp "Key_in_keysFor_parts";
paulson@2449
   181
paulson@2449
   182
paulson@3519
   183
goal thy "!!evs. evs : recur ==>          \
paulson@3683
   184
\                Key K ~: used evs --> K ~: keysFor (parts (spies evs))";
paulson@3519
   185
by (parts_induct_tac 1);
paulson@2451
   186
(*RA3*)
paulson@4509
   187
by (blast_tac (claset() addSDs [Key_in_keysFor_parts]) 2);
paulson@2516
   188
(*Fake*)
paulson@4509
   189
by (blast_tac (claset() addSDs [keysFor_parts_insert]) 1);
paulson@2449
   190
qed_spec_mp "new_keys_not_used";
paulson@2449
   191
paulson@2449
   192
paulson@2449
   193
bind_thm ("new_keys_not_analzd",
paulson@2449
   194
          [analz_subset_parts RS keysFor_mono,
paulson@2449
   195
           new_keys_not_used] MRS contra_subsetD);
paulson@2449
   196
paulson@2449
   197
Addsimps [new_keys_not_used, new_keys_not_analzd];
paulson@2449
   198
paulson@2449
   199
paulson@2449
   200
paulson@2449
   201
(*** Proofs involving analz ***)
paulson@2449
   202
paulson@3519
   203
(*For proofs involving analz.*)
paulson@3683
   204
val analz_spies_tac = 
paulson@2485
   205
    etac subst 4 (*RA2: DELETE needless definition of PA!*)  THEN
paulson@3683
   206
    dtac RA2_analz_spies 4 THEN 
paulson@2449
   207
    forward_tac [respond_imp_responses] 5                THEN
paulson@3683
   208
    dtac RA4_analz_spies 6;
paulson@2449
   209
paulson@2449
   210
paulson@2449
   211
(** Session keys are not used to encrypt other session keys **)
paulson@2449
   212
paulson@2451
   213
(*Version for "responses" relation.  Handles case RA3 in the theorem below.  
paulson@3683
   214
  Note that it holds for *any* set H (not just "spies evs")
paulson@2449
   215
  satisfying the inductive hypothesis.*)
paulson@2449
   216
goal thy  
paulson@2516
   217
 "!!evs. [| RB : responses evs;                             \
paulson@2516
   218
\           ALL K KK. KK <= Compl (range shrK) -->          \
paulson@2516
   219
\                     (Key K : analz (Key``KK Un H)) =      \
paulson@2516
   220
\                     (K : KK | Key K : analz H) |]         \
paulson@2516
   221
\       ==> ALL K KK. KK <= Compl (range shrK) -->          \
paulson@2516
   222
\                     (Key K : analz (insert RB (Key``KK Un H))) = \
paulson@2516
   223
\                     (K : KK | Key K : analz (insert RB H))";
paulson@2516
   224
by (etac responses.induct 1);
paulson@2516
   225
by (ALLGOALS (asm_simp_tac analz_image_freshK_ss));
paulson@2516
   226
qed "resp_analz_image_freshK_lemma";
paulson@2449
   227
paulson@2449
   228
(*Version for the protocol.  Proof is almost trivial, thanks to the lemma.*)
paulson@2449
   229
goal thy  
paulson@3519
   230
 "!!evs. evs : recur ==>                                    \
paulson@3519
   231
\  ALL K KK. KK <= Compl (range shrK) -->                   \
paulson@3683
   232
\            (Key K : analz (Key``KK Un (spies evs))) =  \
paulson@3683
   233
\            (K : KK | Key K : analz (spies evs))";
paulson@2449
   234
by (etac recur.induct 1);
paulson@3683
   235
by analz_spies_tac;
paulson@2516
   236
by (REPEAT_FIRST (resolve_tac [allI, impI]));
paulson@2516
   237
by (REPEAT_FIRST (rtac analz_image_freshK_lemma ));
paulson@2516
   238
by (ALLGOALS 
paulson@2516
   239
    (asm_simp_tac
paulson@2516
   240
     (analz_image_freshK_ss addsimps [resp_analz_image_freshK_lemma])));
paulson@3451
   241
(*Fake*) 
paulson@3451
   242
by (spy_analz_tac 1);
paulson@2516
   243
val raw_analz_image_freshK = result();
paulson@2516
   244
qed_spec_mp "analz_image_freshK";
paulson@2449
   245
paulson@2449
   246
paulson@3683
   247
(*Instance of the lemma with H replaced by (spies evs):
paulson@3519
   248
   [| RB : responses evs;  evs : recur; |]
paulson@2516
   249
   ==> KK <= Compl (range shrK) --> 
paulson@3683
   250
       Key K : analz (insert RB (Key``KK Un spies evs)) =
paulson@3683
   251
       (K : KK | Key K : analz (insert RB (spies evs))) 
paulson@2449
   252
*)
paulson@2516
   253
bind_thm ("resp_analz_image_freshK",
paulson@2516
   254
          raw_analz_image_freshK RSN
paulson@3961
   255
            (2, resp_analz_image_freshK_lemma) RS spec RS spec RS mp);
paulson@2449
   256
paulson@2449
   257
goal thy
paulson@3519
   258
 "!!evs. [| evs : recur;  KAB ~: range shrK |] ==>              \
paulson@3683
   259
\        Key K : analz (insert (Key KAB) (spies evs)) =      \
paulson@3683
   260
\        (K = KAB | Key K : analz (spies evs))";
paulson@2516
   261
by (asm_simp_tac (analz_image_freshK_ss addsimps [analz_image_freshK]) 1);
paulson@2516
   262
qed "analz_insert_freshK";
paulson@2449
   263
paulson@2449
   264
paulson@2516
   265
(*Everything that's hashed is already in past traffic. *)
paulson@3683
   266
goal thy "!!evs. [| Hash {|Key(shrK A), X|} : parts (spies evs);  \
paulson@3683
   267
\                   evs : recur;  A ~: bad |]                       \
paulson@3683
   268
\                ==> X : parts (spies evs)";
paulson@2550
   269
by (etac rev_mp 1);
paulson@3519
   270
by (parts_induct_tac 1);
paulson@2451
   271
(*RA3 requires a further induction*)
paulson@3121
   272
by (etac responses.induct 2);
paulson@2449
   273
by (ALLGOALS Asm_simp_tac);
paulson@2449
   274
(*Fake*)
wenzelm@4091
   275
by (simp_tac (simpset() addsimps [parts_insert_spies]) 1);
paulson@3121
   276
by (Fake_parts_insert_tac 1);
paulson@2550
   277
qed "Hash_imp_body";
paulson@2449
   278
paulson@2449
   279
paulson@2449
   280
(** The Nonce NA uniquely identifies A's message. 
paulson@2516
   281
    This theorem applies to steps RA1 and RA2!
paulson@2455
   282
paulson@2455
   283
  Unicity is not used in other proofs but is desirable in its own right.
paulson@2449
   284
**)
paulson@2449
   285
paulson@2449
   286
goal thy 
paulson@3683
   287
 "!!evs. [| evs : recur; A ~: bad |]                   \
paulson@2560
   288
\ ==> EX B' P'. ALL B P.                                     \
paulson@3683
   289
\        Hash {|Key(shrK A), Agent A, B, NA, P|} : parts (spies evs) \
paulson@2560
   290
\          -->  B=B' & P=P'";
paulson@3519
   291
by (parts_induct_tac 1);
paulson@3121
   292
by (Fake_parts_insert_tac 1);
paulson@2516
   293
by (etac responses.induct 3);
wenzelm@4091
   294
by (ALLGOALS (simp_tac (simpset() addsimps [all_conj_distrib]))); 
wenzelm@4091
   295
by (clarify_tac (claset() addSEs partsEs) 1);
paulson@2516
   296
(*RA1,2: creation of new Nonce.  Move assertion into global context*)
paulson@2516
   297
by (ALLGOALS (expand_case_tac "NA = ?y"));
paulson@2516
   298
by (REPEAT_FIRST (ares_tac [exI]));
wenzelm@4091
   299
by (REPEAT (blast_tac (claset() addSDs [Hash_imp_body]
paulson@3683
   300
                               addSEs spies_partsEs) 1));
paulson@2449
   301
val lemma = result();
paulson@2449
   302
paulson@2481
   303
goalw thy [HPair_def]
paulson@3683
   304
 "!!A.[| Hash[Key(shrK A)] {|Agent A, B,NA,P|}   : parts(spies evs); \
paulson@3683
   305
\        Hash[Key(shrK A)] {|Agent A, B',NA,P'|} : parts(spies evs); \
paulson@3683
   306
\        evs : recur;  A ~: bad |]                                     \
paulson@3483
   307
\      ==> B=B' & P=P'";
paulson@2481
   308
by (REPEAT (eresolve_tac partsEs 1));
paulson@2449
   309
by (prove_unique_tac lemma 1);
paulson@2449
   310
qed "unique_NA";
paulson@2449
   311
paulson@2449
   312
paulson@2449
   313
(*** Lemmas concerning the Server's response
paulson@2449
   314
      (relations "respond" and "responses") 
paulson@2449
   315
***)
paulson@2449
   316
paulson@2449
   317
goal thy
paulson@3519
   318
 "!!evs. [| RB : responses evs;  evs : recur |] \
paulson@3683
   319
\ ==> (Key (shrK B) : analz (insert RB (spies evs))) = (B:bad)";
paulson@2516
   320
by (etac responses.induct 1);
paulson@2449
   321
by (ALLGOALS
paulson@2449
   322
    (asm_simp_tac 
paulson@2516
   323
     (analz_image_freshK_ss addsimps [Spy_analz_shrK,
paulson@2516
   324
                                      resp_analz_image_freshK])));
paulson@2449
   325
qed "shrK_in_analz_respond";
paulson@2449
   326
Addsimps [shrK_in_analz_respond];
paulson@2449
   327
paulson@2449
   328
paulson@2449
   329
goal thy  
paulson@2516
   330
 "!!evs. [| RB : responses evs;                             \
paulson@2516
   331
\           ALL K KK. KK <= Compl (range shrK) -->          \
paulson@2516
   332
\                     (Key K : analz (Key``KK Un H)) =      \
paulson@2516
   333
\                     (K : KK | Key K : analz H) |]         \
paulson@3483
   334
\       ==> (Key K : analz (insert RB H)) -->               \
paulson@2516
   335
\           (Key K : parts{RB} | Key K : analz H)";
paulson@2516
   336
by (etac responses.induct 1);
paulson@2449
   337
by (ALLGOALS
paulson@2449
   338
    (asm_simp_tac 
paulson@2516
   339
     (analz_image_freshK_ss addsimps [resp_analz_image_freshK_lemma])));
paulson@2516
   340
(*Simplification using two distinct treatments of "image"*)
wenzelm@4091
   341
by (simp_tac (simpset() addsimps [parts_insert2]) 1);
wenzelm@4091
   342
by (blast_tac (claset() delrules [allE]) 1);
paulson@2449
   343
qed "resp_analz_insert_lemma";
paulson@2449
   344
paulson@2449
   345
bind_thm ("resp_analz_insert",
paulson@2516
   346
          raw_analz_image_freshK RSN
paulson@2516
   347
            (2, resp_analz_insert_lemma) RSN(2, rev_mp));
paulson@2449
   348
paulson@2449
   349
paulson@2449
   350
(*The Server does not send such messages.  This theorem lets us avoid
paulson@2451
   351
  assuming B~=Server in RA4.*)
paulson@2449
   352
goal thy 
paulson@3519
   353
 "!!evs. evs : recur \
paulson@3483
   354
\        ==> ALL C X Y. Says Server C {|X, Agent Server, Y|} ~: set evs";
paulson@2449
   355
by (etac recur.induct 1);
paulson@2516
   356
by (etac (respond.induct) 5);
paulson@4477
   357
by Auto_tac;
paulson@2449
   358
qed_spec_mp "Says_Server_not";
paulson@2449
   359
AddSEs [Says_Server_not RSN (2,rev_notE)];
paulson@2449
   360
paulson@2449
   361
paulson@2516
   362
(*The last key returned by respond indeed appears in a certificate*)
paulson@2449
   363
goal thy 
paulson@2516
   364
 "!!K. (Hash[Key(shrK A)] {|Agent A, B, NA, P|}, RA, K) : respond evs \
paulson@2516
   365
\ ==> Crypt (shrK A) {|Key K, B, NA|} : parts {RA}";
paulson@2516
   366
by (etac respond.elim 1);
paulson@2516
   367
by (ALLGOALS Asm_full_simp_tac);
paulson@2516
   368
qed "respond_certificate";
paulson@2516
   369
paulson@2516
   370
paulson@2516
   371
goal thy 
paulson@2560
   372
 "!!K'. (PB,RB,KXY) : respond evs                          \
paulson@2560
   373
\  ==> EX A' B'. ALL A B N.                                \
paulson@2449
   374
\        Crypt (shrK A) {|Key K, Agent B, N|} : parts {RB} \
paulson@2449
   375
\          -->   (A'=A & B'=B) | (A'=B & B'=A)";
paulson@2516
   376
by (etac respond.induct 1);
wenzelm@4091
   377
by (ALLGOALS (asm_full_simp_tac (simpset() addsimps [all_conj_distrib]))); 
paulson@2449
   378
(*Base case*)
paulson@3121
   379
by (Blast_tac 1);
paulson@3730
   380
by Safe_tac;
paulson@2550
   381
by (expand_case_tac "K = KBC" 1);
paulson@2516
   382
by (dtac respond_Key_in_parts 1);
wenzelm@4091
   383
by (blast_tac (claset() addSIs [exI]
paulson@3519
   384
                       addSEs partsEs
paulson@3519
   385
                       addDs [Key_in_parts_respond]) 1);
paulson@2550
   386
by (expand_case_tac "K = KAB" 1);
paulson@2449
   387
by (REPEAT (ares_tac [exI] 2));
paulson@2449
   388
by (ex_strip_tac 1);
paulson@2516
   389
by (dtac respond_certificate 1);
paulson@2449
   390
by (Fast_tac 1);
paulson@2449
   391
val lemma = result();
paulson@2449
   392
paulson@2449
   393
goal thy 
paulson@2560
   394
 "!!RB. [| Crypt (shrK A) {|Key K, Agent B, N|} : parts {RB};      \
paulson@2449
   395
\          Crypt (shrK A') {|Key K, Agent B', N'|} : parts {RB};   \
paulson@2560
   396
\          (PB,RB,KXY) : respond evs |]                            \
paulson@2449
   397
\ ==>   (A'=A & B'=B) | (A'=B & B'=A)";
paulson@2560
   398
by (prove_unique_tac lemma 1);
paulson@2449
   399
qed "unique_session_keys";
paulson@2449
   400
paulson@2449
   401
paulson@2451
   402
(** Crucial secrecy property: Spy does not see the keys sent in msg RA3
paulson@2449
   403
    Does not in itself guarantee security: an attack could violate 
paulson@2449
   404
    the premises, e.g. by having A=Spy **)
paulson@2449
   405
paulson@2449
   406
goal thy 
paulson@3519
   407
 "!!evs. [| (PB,RB,KAB) : respond evs;  evs : recur |]              \
paulson@3683
   408
\        ==> ALL A A' N. A ~: bad & A' ~: bad -->                 \
paulson@2449
   409
\            Crypt (shrK A) {|Key K, Agent A', N|} : parts{RB} -->  \
paulson@3683
   410
\            Key K ~: analz (insert RB (spies evs))";
paulson@2516
   411
by (etac respond.induct 1);
paulson@2449
   412
by (forward_tac [respond_imp_responses] 2);
paulson@2516
   413
by (forward_tac [respond_imp_not_used] 2);
paulson@3961
   414
by (ALLGOALS (*6 seconds*)
paulson@2449
   415
    (asm_simp_tac 
paulson@3961
   416
     (analz_image_freshK_ss 
paulson@3961
   417
        addsimps expand_ifs
paulson@3961
   418
	addsimps 
paulson@3961
   419
          [shrK_in_analz_respond, resp_analz_image_freshK, parts_insert2])));
wenzelm@4091
   420
by (ALLGOALS (simp_tac (simpset() addsimps [ex_disj_distrib])));
paulson@3681
   421
(** LEVEL 5 **)
wenzelm@4091
   422
by (blast_tac (claset() addIs [impOfSubs analz_subset_parts]) 1);
paulson@3961
   423
by (REPEAT_FIRST (resolve_tac [allI, conjI, impI]));
paulson@3961
   424
by (ALLGOALS Clarify_tac);
wenzelm@4091
   425
by (blast_tac (claset() addSDs  [resp_analz_insert]
paulson@3961
   426
		       addIs  [impOfSubs analz_subset_parts]) 2);
wenzelm@4091
   427
by (blast_tac (claset() addSDs [respond_certificate]) 1);
paulson@3961
   428
by (Asm_full_simp_tac 1);
paulson@3961
   429
(*by unicity, either B=Aa or B=A', a contradiction if B: bad*)
paulson@3961
   430
by (blast_tac
wenzelm@4091
   431
    (claset() addSEs [MPair_parts]
paulson@3961
   432
	     addDs [parts.Body,
paulson@3961
   433
		    respond_certificate RSN (2, unique_session_keys)]) 1);
paulson@2533
   434
qed_spec_mp "respond_Spy_not_see_session_key";
paulson@2449
   435
paulson@2449
   436
paulson@2449
   437
goal thy
paulson@3683
   438
 "!!evs. [| Crypt (shrK A) {|Key K, Agent A', N|} : parts (spies evs); \
paulson@3730
   439
\           A ~: bad;  A' ~: bad;  evs : recur |]                      \
paulson@3683
   440
\        ==> Key K ~: analz (spies evs)";
paulson@2550
   441
by (etac rev_mp 1);
paulson@2449
   442
by (etac recur.induct 1);
paulson@3683
   443
by analz_spies_tac;
paulson@2449
   444
by (ALLGOALS
paulson@2449
   445
    (asm_simp_tac
wenzelm@4091
   446
     (simpset() addsimps (expand_ifs @
paulson@3961
   447
			 [analz_insert_eq, parts_insert_spies, 
paulson@3961
   448
			  analz_insert_freshK]))));
paulson@2451
   449
(*RA4*)
paulson@2533
   450
by (spy_analz_tac 5);
paulson@2533
   451
(*RA2*)
paulson@2533
   452
by (spy_analz_tac 3);
paulson@2449
   453
(*Fake*)
paulson@2533
   454
by (spy_analz_tac 2);
paulson@2533
   455
(*Base*)
paulson@3121
   456
by (Blast_tac 1);
paulson@2533
   457
(*RA3 remains*)
wenzelm@4091
   458
by (safe_tac (claset() delrules [impCE]));
paulson@2451
   459
(*RA3, case 2: K is an old key*)
wenzelm@4091
   460
by (blast_tac (claset() addSDs [resp_analz_insert]
paulson@3121
   461
                       addSEs partsEs
paulson@3730
   462
                       addDs  [Key_in_parts_respond]) 2);
paulson@2451
   463
(*RA3, case 1: use lemma previously proved by induction*)
wenzelm@4091
   464
by (blast_tac (claset() addSEs [respond_Spy_not_see_session_key RSN
paulson@3121
   465
			       (2,rev_notE)]) 1);
paulson@2550
   466
qed "Spy_not_see_session_key";
paulson@2449
   467
paulson@2449
   468
paulson@2449
   469
(**** Authenticity properties for Agents ****)
paulson@2449
   470
paulson@2481
   471
(*The response never contains Hashes*)
paulson@2481
   472
goal thy
paulson@2550
   473
 "!!evs. [| Hash {|Key (shrK B), M|} : parts (insert RB H); \
paulson@2550
   474
\           (PB,RB,K) : respond evs |]                      \
paulson@2550
   475
\        ==> Hash {|Key (shrK B), M|} : parts H";
paulson@2550
   476
by (etac rev_mp 1);
paulson@2516
   477
by (etac (respond_imp_responses RS responses.induct) 1);
paulson@4477
   478
by Auto_tac;
paulson@2550
   479
qed "Hash_in_parts_respond";
paulson@2481
   480
paulson@2533
   481
(*Only RA1 or RA2 can have caused such a part of a message to appear.
paulson@2533
   482
  This result is of no use to B, who cannot verify the Hash.  Moreover,
paulson@2533
   483
  it can say nothing about how recent A's message is.  It might later be
paulson@2533
   484
  used to prove B's presence to A at the run's conclusion.*)
paulson@2481
   485
goalw thy [HPair_def]
paulson@3683
   486
 "!!evs. [| Hash {|Key(shrK A), Agent A, Agent B, NA, P|} : parts(spies evs); \
paulson@3683
   487
\           A ~: bad;  evs : recur |]                      \
paulson@3466
   488
\     ==> Says A B (Hash[Key(shrK A)] {|Agent A, Agent B, NA, P|}) : set evs";
paulson@2516
   489
by (etac rev_mp 1);
paulson@3519
   490
by (parts_induct_tac 1);
paulson@3121
   491
by (Fake_parts_insert_tac 1);
paulson@2451
   492
(*RA3*)
wenzelm@4091
   493
by (blast_tac (claset() addSDs [Hash_in_parts_respond]) 1);
paulson@2449
   494
qed_spec_mp "Hash_auth_sender";
paulson@2449
   495
paulson@2516
   496
(** These two results subsume (for all agents) the guarantees proved
paulson@2449
   497
    separately for A and B in the Otway-Rees protocol.
paulson@2449
   498
**)
paulson@2449
   499
paulson@2449
   500
paulson@2533
   501
(*Certificates can only originate with the Server.*)
paulson@2449
   502
goal thy 
paulson@3683
   503
 "!!evs. [| Crypt (shrK A) Y : parts (spies evs);    \
paulson@3683
   504
\           A ~: bad;  A ~= Spy;  evs : recur |]       \
paulson@3519
   505
\        ==> EX C RC. Says Server C RC : set evs  &     \
paulson@2550
   506
\                     Crypt (shrK A) Y : parts {RC}";
paulson@2550
   507
by (etac rev_mp 1);
paulson@3519
   508
by (parts_induct_tac 1);
paulson@3121
   509
by (Fake_parts_insert_tac 1);
paulson@2451
   510
(*RA4*)
paulson@3121
   511
by (Blast_tac 4);
paulson@2455
   512
(*RA3*)
wenzelm@4091
   513
by (full_simp_tac (simpset() addsimps [parts_insert_spies]) 3
paulson@3121
   514
    THEN Blast_tac 3);
paulson@2455
   515
(*RA1*)
paulson@3121
   516
by (Blast_tac 1);
paulson@2451
   517
(*RA2: it cannot be a new Nonce, contradiction.*)
paulson@3121
   518
by (Blast_tac 1);
paulson@2550
   519
qed "Cert_imp_Server_msg";