src/HOL/Auth/NS_Public_Bad.ML
author paulson
Mon Dec 16 11:13:44 1996 +0100 (1996-12-16)
changeset 2418 6b6a92d05fb2
parent 2374 4148aa5b00a2
child 2451 ce85a2aafc7a
permissions -rw-r--r--
New tactics: prove_unique_tac and analz_induct_tac
paulson@2318
     1
(*  Title:      HOL/Auth/NS_Public_Bad
paulson@2318
     2
    ID:         $Id$
paulson@2318
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@2318
     4
    Copyright   1996  University of Cambridge
paulson@2318
     5
paulson@2318
     6
Inductive relation "ns_public" for the Needham-Schroeder Public-Key protocol.
paulson@2318
     7
Flawed version, vulnerable to Lowe's attack.
paulson@2318
     8
paulson@2318
     9
From page 260 of
paulson@2318
    10
  Burrows, Abadi and Needham.  A Logic of Authentication.
paulson@2318
    11
  Proc. Royal Soc. 426 (1989)
paulson@2318
    12
*)
paulson@2318
    13
paulson@2318
    14
open NS_Public_Bad;
paulson@2318
    15
paulson@2318
    16
proof_timing:=true;
paulson@2318
    17
HOL_quantifiers := false;
paulson@2318
    18
Pretty.setdepth 20;
paulson@2318
    19
paulson@2318
    20
AddIffs [Spy_in_lost];
paulson@2318
    21
paulson@2318
    22
(*Replacing the variable by a constant improves search speed by 50%!*)
paulson@2318
    23
val Says_imp_sees_Spy' = 
paulson@2318
    24
    read_instantiate_sg (sign_of thy) [("lost","lost")] Says_imp_sees_Spy;
paulson@2318
    25
paulson@2318
    26
paulson@2318
    27
(*A "possibility property": there are traces that reach the end*)
paulson@2318
    28
goal thy 
paulson@2318
    29
 "!!A B. [| A ~= B |]   \
paulson@2318
    30
\        ==> EX NB. EX evs: ns_public.               \
paulson@2318
    31
\               Says A B (Crypt (pubK B) (Nonce NB)) : set_of_list evs";
paulson@2318
    32
by (REPEAT (resolve_tac [exI,bexI] 1));
paulson@2318
    33
by (rtac (ns_public.Nil RS ns_public.NS1 RS ns_public.NS2 RS ns_public.NS3) 2);
paulson@2318
    34
by (ALLGOALS (simp_tac (!simpset setsolver safe_solver)));
paulson@2318
    35
by (REPEAT_FIRST (resolve_tac [refl, conjI]));
paulson@2318
    36
by (REPEAT_FIRST (fast_tac (!claset addss (!simpset setsolver safe_solver))));
paulson@2318
    37
result();
paulson@2318
    38
paulson@2318
    39
paulson@2318
    40
(**** Inductive proofs about ns_public ****)
paulson@2318
    41
paulson@2318
    42
(*Nobody sends themselves messages*)
paulson@2318
    43
goal thy "!!evs. evs : ns_public ==> ALL A X. Says A A X ~: set_of_list evs";
paulson@2318
    44
by (etac ns_public.induct 1);
paulson@2318
    45
by (Auto_tac());
paulson@2318
    46
qed_spec_mp "not_Says_to_self";
paulson@2318
    47
Addsimps [not_Says_to_self];
paulson@2318
    48
AddSEs   [not_Says_to_self RSN (2, rev_notE)];
paulson@2318
    49
paulson@2318
    50
paulson@2318
    51
(*For proving the easier theorems about X ~: parts (sees lost Spy evs) *)
paulson@2318
    52
fun parts_induct_tac i = SELECT_GOAL
paulson@2318
    53
    (DETERM (etac ns_public.induct 1 THEN 
paulson@2318
    54
             (*Fake message*)
paulson@2318
    55
             TRY (best_tac (!claset addDs [impOfSubs analz_subset_parts,
paulson@2318
    56
                                           impOfSubs Fake_parts_insert]
paulson@2318
    57
                                    addss (!simpset)) 2)) THEN
paulson@2318
    58
     (*Base case*)
paulson@2318
    59
     fast_tac (!claset addss (!simpset)) 1 THEN
paulson@2318
    60
     ALLGOALS Asm_simp_tac) i;
paulson@2318
    61
paulson@2318
    62
(** Theorems of the form X ~: parts (sees lost Spy evs) imply that NOBODY
paulson@2318
    63
    sends messages containing X! **)
paulson@2318
    64
paulson@2318
    65
(*Spy never sees another agent's private key! (unless it's lost at start)*)
paulson@2318
    66
goal thy 
paulson@2318
    67
 "!!evs. evs : ns_public \
paulson@2318
    68
\        ==> (Key (priK A) : parts (sees lost Spy evs)) = (A : lost)";
paulson@2318
    69
by (parts_induct_tac 1);
paulson@2318
    70
by (Auto_tac());
paulson@2318
    71
qed "Spy_see_priK";
paulson@2318
    72
Addsimps [Spy_see_priK];
paulson@2318
    73
paulson@2318
    74
goal thy 
paulson@2318
    75
 "!!evs. evs : ns_public \
paulson@2318
    76
\        ==> (Key (priK A) : analz (sees lost Spy evs)) = (A : lost)";
paulson@2318
    77
by (auto_tac(!claset addDs [impOfSubs analz_subset_parts], !simpset));
paulson@2318
    78
qed "Spy_analz_priK";
paulson@2318
    79
Addsimps [Spy_analz_priK];
paulson@2318
    80
paulson@2318
    81
goal thy  "!!A. [| Key (priK A) : parts (sees lost Spy evs);       \
paulson@2318
    82
\                  evs : ns_public |] ==> A:lost";
paulson@2318
    83
by (fast_tac (!claset addDs [Spy_see_priK]) 1);
paulson@2318
    84
qed "Spy_see_priK_D";
paulson@2318
    85
paulson@2318
    86
bind_thm ("Spy_analz_priK_D", analz_subset_parts RS subsetD RS Spy_see_priK_D);
paulson@2318
    87
AddSDs [Spy_see_priK_D, Spy_analz_priK_D];
paulson@2318
    88
paulson@2318
    89
paulson@2318
    90
(*** Future nonces can't be seen or used! ***)
paulson@2318
    91
paulson@2318
    92
goal thy "!!evs. evs : ns_public ==> \
paulson@2318
    93
\                length evs <= length evt --> \
paulson@2318
    94
\                Nonce (newN evt) ~: parts (sees lost Spy evs)";
paulson@2318
    95
by (parts_induct_tac 1);
paulson@2318
    96
by (REPEAT_FIRST (fast_tac (!claset 
paulson@2318
    97
                              addSEs partsEs
paulson@2318
    98
                              addSDs  [Says_imp_sees_Spy' RS parts.Inj]
paulson@2318
    99
                              addEs [leD RS notE]
paulson@2318
   100
			      addDs  [impOfSubs analz_subset_parts,
paulson@2318
   101
                                      impOfSubs parts_insert_subset_Un,
paulson@2318
   102
                                      Suc_leD]
paulson@2318
   103
                              addss (!simpset))));
paulson@2318
   104
qed_spec_mp "new_nonces_not_seen";
paulson@2318
   105
Addsimps [new_nonces_not_seen];
paulson@2318
   106
paulson@2318
   107
val nonce_not_seen_now = le_refl RSN (2, new_nonces_not_seen) RSN (2,rev_notE);
paulson@2318
   108
paulson@2418
   109
fun analz_induct_tac i = 
paulson@2418
   110
    etac ns_public.induct i	THEN
paulson@2418
   111
    ALLGOALS (asm_simp_tac 
paulson@2418
   112
	      (!simpset addsimps ([not_parts_not_analz] @ pushes)
paulson@2418
   113
               setloop split_tac [expand_if]));
paulson@2418
   114
paulson@2318
   115
paulson@2318
   116
(**** Authenticity properties obtained from NS2 ****)
paulson@2318
   117
paulson@2318
   118
(*It is impossible to re-use a nonce in both NS1 and NS2, provided the nonce
paulson@2318
   119
  is secret.  (Honest users generate fresh nonces.)*)
paulson@2318
   120
goal thy 
paulson@2318
   121
 "!!evs. evs : ns_public                       \
paulson@2318
   122
\ ==> Nonce NA ~: analz (sees lost Spy evs) -->           \
paulson@2318
   123
\     Crypt (pubK B) {|Nonce NA, Agent A|} : parts (sees lost Spy evs) --> \
paulson@2318
   124
\     Crypt (pubK C) {|NA', Nonce NA|} ~: parts (sees lost Spy evs)";
paulson@2418
   125
by (analz_induct_tac 1);
paulson@2318
   126
(*NS3*)
paulson@2318
   127
by (fast_tac (!claset addSEs partsEs
paulson@2318
   128
                      addEs  [nonce_not_seen_now]) 4);
paulson@2318
   129
(*NS2*)
paulson@2318
   130
by (fast_tac (!claset addSEs partsEs
paulson@2318
   131
                      addEs  [nonce_not_seen_now]) 3);
paulson@2318
   132
(*Fake*)
paulson@2374
   133
by (best_tac (!claset addIs [analz_insertI]
paulson@2318
   134
		      addDs [impOfSubs analz_subset_parts,
paulson@2318
   135
			     impOfSubs Fake_parts_insert]
paulson@2318
   136
	              addss (!simpset)) 2);
paulson@2318
   137
(*Base*)
paulson@2374
   138
by (fast_tac (!claset addss (!simpset)) 1);
paulson@2318
   139
bind_thm ("no_nonce_NS1_NS2", result() RSN (2, rev_mp) RSN (2, rev_mp));
paulson@2318
   140
paulson@2318
   141
paulson@2318
   142
(*Uniqueness for NS1: nonce NA identifies agents A and B*)
paulson@2318
   143
goal thy 
paulson@2318
   144
 "!!evs. evs : ns_public                                                    \
paulson@2318
   145
\ ==> Nonce NA ~: analz (sees lost Spy evs) -->                             \
paulson@2318
   146
\     (EX A' B'. ALL A B.                                                   \
paulson@2318
   147
\      Crypt (pubK B) {|Nonce NA, Agent A|} : parts (sees lost Spy evs) --> \
paulson@2318
   148
\      A=A' & B=B')";
paulson@2418
   149
by (analz_induct_tac 1);
paulson@2318
   150
(*NS1*)
paulson@2318
   151
by (expand_case_tac "NA = ?y" 3 THEN
paulson@2318
   152
    REPEAT (fast_tac (!claset addSEs (nonce_not_seen_now::partsEs)) 3));
paulson@2318
   153
(*Base*)
paulson@2318
   154
by (fast_tac (!claset addss (!simpset)) 1);
paulson@2318
   155
(*Fake*)
paulson@2318
   156
by (simp_tac (!simpset addsimps [all_conj_distrib,parts_insert_sees]) 1);
paulson@2374
   157
by (step_tac (!claset addSIs [analz_insertI]) 1);
paulson@2318
   158
by (ex_strip_tac 1);
paulson@2318
   159
by (best_tac (!claset delrules [conjI]
paulson@2324
   160
		      addSDs [impOfSubs Fake_parts_insert]
paulson@2324
   161
	              addDs  [impOfSubs analz_subset_parts]
paulson@2318
   162
                      addss (!simpset)) 1);
paulson@2318
   163
val lemma = result();
paulson@2318
   164
paulson@2318
   165
goal thy 
paulson@2318
   166
 "!!evs. [| Crypt(pubK B)  {|Nonce NA, Agent A|}  : parts(sees lost Spy evs); \
paulson@2318
   167
\           Crypt(pubK B') {|Nonce NA, Agent A'|} : parts(sees lost Spy evs); \
paulson@2318
   168
\           Nonce NA ~: analz (sees lost Spy evs);                            \
paulson@2318
   169
\           evs : ns_public |]                                                \
paulson@2318
   170
\        ==> A=A' & B=B'";
paulson@2418
   171
by (prove_unique_tac lemma 1);
paulson@2318
   172
qed "unique_NA";
paulson@2318
   173
paulson@2318
   174
paulson@2318
   175
(*Secrecy: Spy does not see the nonce sent in msg NS1 if A and B are secure*)
paulson@2318
   176
goal thy 
paulson@2318
   177
 "!!evs. [| A ~: lost;  B ~: lost;  evs : ns_public |]   \
paulson@2318
   178
\ ==> Says A B (Crypt (pubK B) {|Nonce NA, Agent A|}) : set_of_list evs \
paulson@2318
   179
\     --> Nonce NA ~: analz (sees lost Spy evs)";
paulson@2418
   180
by (analz_induct_tac 1);
paulson@2318
   181
(*NS3*)
paulson@2318
   182
by (fast_tac (!claset addSDs [Says_imp_sees_Spy' RS parts.Inj]
paulson@2318
   183
                      addEs  [no_nonce_NS1_NS2 RSN (2, rev_notE)]) 4);
paulson@2318
   184
(*NS1*)
paulson@2318
   185
by (fast_tac (!claset addSEs partsEs
paulson@2318
   186
                      addSDs [new_nonces_not_seen, 
paulson@2318
   187
			      Says_imp_sees_Spy' RS parts.Inj]) 2);
paulson@2318
   188
(*Fake*)
paulson@2374
   189
by (REPEAT_FIRST spy_analz_tac);
paulson@2318
   190
(*NS2*)
paulson@2318
   191
by (Step_tac 1);
paulson@2318
   192
by (fast_tac (!claset addSEs partsEs
paulson@2318
   193
                      addSDs [new_nonces_not_seen, 
paulson@2318
   194
			      Says_imp_sees_Spy' RS parts.Inj]) 2);
paulson@2318
   195
by (fast_tac (!claset addSDs [Says_imp_sees_Spy' RS parts.Inj]
paulson@2318
   196
                      addDs  [unique_NA]) 1);
paulson@2318
   197
bind_thm ("Spy_not_see_NA", result() RSN (2, rev_mp));
paulson@2318
   198
paulson@2318
   199
paulson@2318
   200
(*Authentication for A: if she receives message 2 and has used NA
paulson@2318
   201
  to start a run, then B has sent message 2.*)
paulson@2318
   202
goal thy 
paulson@2318
   203
 "!!evs. [| A ~: lost;  B ~: lost;  evs : ns_public |]       \
paulson@2318
   204
\ ==> Crypt (pubK A) {|Nonce NA, Nonce NB|} : parts (sees lost Spy evs) \
paulson@2318
   205
\     --> Says A B (Crypt (pubK B) {|Nonce NA, Agent A|}) : set_of_list evs \
paulson@2318
   206
\     --> Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set_of_list evs";
paulson@2418
   207
by (analz_induct_tac 1);
paulson@2318
   208
by (ALLGOALS Asm_simp_tac);
paulson@2318
   209
(*NS1*)
paulson@2318
   210
by (fast_tac (!claset addSEs partsEs
paulson@2318
   211
                      addSDs [new_nonces_not_seen, 
paulson@2318
   212
			      Says_imp_sees_Spy' RS parts.Inj]) 2);
paulson@2318
   213
(*Fake*)
paulson@2318
   214
by (REPEAT_FIRST (resolve_tac [impI, conjI]));
paulson@2318
   215
by (fast_tac (!claset addss (!simpset)) 1);
paulson@2318
   216
by (forward_tac [Spy_not_see_NA] 1 THEN REPEAT (assume_tac 1));
paulson@2324
   217
by (best_tac (!claset addSIs [disjI2]
paulson@2324
   218
		      addSDs [impOfSubs Fake_parts_insert]
paulson@2324
   219
		      addDs  [impOfSubs analz_subset_parts]
paulson@2318
   220
	              addss (!simpset)) 1);
paulson@2318
   221
(*NS2*)
paulson@2318
   222
by (Step_tac 1);
paulson@2318
   223
by (forward_tac [Spy_not_see_NA] 1 THEN REPEAT (assume_tac 1));
paulson@2318
   224
by (fast_tac (!claset addSDs [Says_imp_sees_Spy' RS parts.Inj]
paulson@2318
   225
                      addDs  [unique_NA]) 1);
paulson@2318
   226
qed_spec_mp "NA_decrypt_imp_B_msg";
paulson@2318
   227
paulson@2318
   228
(*Corollary: if A receives B's message NS2 and the nonce NA agrees
paulson@2318
   229
  then that message really originated with B.*)
paulson@2318
   230
goal thy 
paulson@2318
   231
 "!!evs. [| Says B' A (Crypt(pubK A) {|Nonce NA, Nonce NB|}): set_of_list evs;\
paulson@2318
   232
\           Says A B (Crypt (pubK B) {|Nonce NA, Agent A|}) : set_of_list evs;\
paulson@2318
   233
\           A ~: lost;  B ~: lost;  evs : ns_public |]  \
paulson@2318
   234
\        ==> Says B A (Crypt(pubK A) {|Nonce NA, Nonce NB|}): set_of_list evs";
paulson@2318
   235
by (fast_tac (!claset addSIs [NA_decrypt_imp_B_msg]
paulson@2318
   236
                      addEs  partsEs
paulson@2318
   237
                      addDs  [Says_imp_sees_Spy' RS parts.Inj]) 1);
paulson@2318
   238
qed "A_trusts_NS2";
paulson@2318
   239
paulson@2318
   240
(*If the encrypted message appears then it originated with Alice in NS1*)
paulson@2318
   241
goal thy 
paulson@2318
   242
 "!!evs. evs : ns_public                   \
paulson@2318
   243
\    ==> Nonce NA ~: analz (sees lost Spy evs) --> \
paulson@2318
   244
\        Crypt (pubK B) {|Nonce NA, Agent A|} : parts (sees lost Spy evs) --> \
paulson@2318
   245
\        Says A B (Crypt (pubK B) {|Nonce NA, Agent A|}) : set_of_list evs";
paulson@2418
   246
by (analz_induct_tac 1);
paulson@2318
   247
(*Fake*)
paulson@2318
   248
by (best_tac (!claset addSIs [disjI2]
paulson@2324
   249
		      addSDs [impOfSubs Fake_parts_insert]
paulson@2374
   250
		      addIs  [analz_insertI]
paulson@2324
   251
		      addDs  [impOfSubs analz_subset_parts]
paulson@2318
   252
	              addss (!simpset)) 2);
paulson@2318
   253
(*Base*)
paulson@2318
   254
by (fast_tac (!claset addss (!simpset)) 1);
paulson@2318
   255
qed_spec_mp "B_trusts_NS1";
paulson@2318
   256
paulson@2318
   257
paulson@2318
   258
paulson@2318
   259
(**** Authenticity properties obtained from NS2 ****)
paulson@2318
   260
paulson@2318
   261
(*Uniqueness for NS2: nonce NB identifies agent A and nonce NA
paulson@2318
   262
  [proof closely follows that for unique_NA] *)
paulson@2318
   263
goal thy 
paulson@2318
   264
 "!!evs. evs : ns_public                                                    \
paulson@2318
   265
\ ==> Nonce NB ~: analz (sees lost Spy evs) -->                             \
paulson@2324
   266
\     (EX A' NA'. ALL A NA.                                                 \
paulson@2318
   267
\      Crypt (pubK A) {|Nonce NA, Nonce NB|} : parts (sees lost Spy evs) --> \
paulson@2318
   268
\      A=A' & NA=NA')";
paulson@2418
   269
by (analz_induct_tac 1);
paulson@2318
   270
(*NS2*)
paulson@2318
   271
by (expand_case_tac "NB = ?y" 3 THEN
paulson@2318
   272
    REPEAT (fast_tac (!claset addSEs (nonce_not_seen_now::partsEs)) 3));
paulson@2318
   273
(*Base*)
paulson@2318
   274
by (fast_tac (!claset addss (!simpset)) 1);
paulson@2318
   275
(*Fake*)
paulson@2318
   276
by (simp_tac (!simpset addsimps [all_conj_distrib,parts_insert_sees]) 1);
paulson@2374
   277
by (step_tac (!claset addSIs [analz_insertI]) 1);
paulson@2318
   278
by (ex_strip_tac 1);
paulson@2318
   279
by (best_tac (!claset delrules [conjI]
paulson@2324
   280
	              addSDs [impOfSubs Fake_parts_insert]
paulson@2324
   281
	              addDs  [impOfSubs analz_subset_parts] 
paulson@2324
   282
	              addss (!simpset)) 1);
paulson@2318
   283
val lemma = result();
paulson@2318
   284
paulson@2318
   285
goal thy 
paulson@2318
   286
 "!!evs. [| Crypt(pubK A) {|Nonce NA, Nonce NB|}  : parts(sees lost Spy evs); \
paulson@2318
   287
\           Crypt(pubK A'){|Nonce NA', Nonce NB|} : parts(sees lost Spy evs); \
paulson@2318
   288
\           Nonce NB ~: analz (sees lost Spy evs);                            \
paulson@2318
   289
\           evs : ns_public |]                                                \
paulson@2318
   290
\        ==> A=A' & NA=NA'";
paulson@2418
   291
by (prove_unique_tac lemma 1);
paulson@2318
   292
qed "unique_NB";
paulson@2318
   293
paulson@2318
   294
paulson@2318
   295
(*NB remains secret PROVIDED Alice never responds with round 3*)
paulson@2318
   296
goal thy 
paulson@2318
   297
 "!!evs. [| A ~: lost;  B ~: lost;  evs : ns_public |]   \
paulson@2318
   298
\ ==> Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set_of_list evs --> \
paulson@2318
   299
\     (ALL C. Says A C (Crypt (pubK C) (Nonce NB)) ~: set_of_list evs) --> \
paulson@2318
   300
\     Nonce NB ~: analz (sees lost Spy evs)";
paulson@2418
   301
by (analz_induct_tac 1);
paulson@2318
   302
(*NS1*)
paulson@2318
   303
by (fast_tac (!claset addSEs partsEs
paulson@2318
   304
                      addSDs [new_nonces_not_seen, 
paulson@2318
   305
			      Says_imp_sees_Spy' RS parts.Inj]) 2);
paulson@2318
   306
(*Fake*)
paulson@2374
   307
by (REPEAT_FIRST spy_analz_tac);
paulson@2318
   308
(*NS2 and NS3*)
paulson@2318
   309
by (Step_tac 1);
paulson@2318
   310
(*NS2*)
paulson@2318
   311
by (fast_tac (!claset addSDs [Says_imp_sees_Spy' RS parts.Inj]
paulson@2318
   312
                      addEs  [no_nonce_NS1_NS2 RSN (2, rev_notE)]) 3);
paulson@2318
   313
by (fast_tac (!claset addSEs partsEs
paulson@2318
   314
                      addSDs [new_nonces_not_seen, 
paulson@2318
   315
                              Says_imp_sees_Spy' RS parts.Inj]) 2);
paulson@2318
   316
by (Fast_tac 1);
paulson@2318
   317
(*NS3*)
paulson@2318
   318
by (Fast_tac 2);
paulson@2318
   319
by (fast_tac (!claset addSEs partsEs
paulson@2318
   320
                      addSDs [Says_imp_sees_Spy' RS parts.Inj,
paulson@2318
   321
			      new_nonces_not_seen, 
paulson@2318
   322
                              impOfSubs analz_subset_parts]) 1);
paulson@2318
   323
paulson@2318
   324
by (forw_inst_tac [("A'","A")] (Says_imp_sees_Spy' RS parts.Inj RS unique_NB) 1
paulson@2318
   325
    THEN REPEAT (eresolve_tac [asm_rl, Says_imp_sees_Spy' RS parts.Inj] 1));
paulson@2318
   326
by (Fast_tac 1);
paulson@2318
   327
bind_thm ("Spy_not_see_NB", result() RSN (2, rev_mp) RS mp);
paulson@2318
   328
paulson@2318
   329
paulson@2318
   330
paulson@2318
   331
(*Authentication for B: if he receives message 3 and has used NB
paulson@2318
   332
  in message 2, then A has sent message 3.*)
paulson@2318
   333
goal thy 
paulson@2318
   334
 "!!evs. [| A ~: lost;  B ~: lost;  evs : ns_public |]       \
paulson@2318
   335
\ ==> Crypt (pubK B) (Nonce NB) : parts (sees lost Spy evs) \
paulson@2318
   336
\     --> Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set_of_list evs \
paulson@2318
   337
\     --> (EX C. Says A C (Crypt (pubK C) (Nonce NB)) : set_of_list evs)";
paulson@2418
   338
by (analz_induct_tac 1);
paulson@2318
   339
by (ALLGOALS (asm_simp_tac (!simpset addsimps [ex_disj_distrib])));
paulson@2318
   340
by (ALLGOALS Asm_simp_tac);
paulson@2318
   341
(*NS1*)
paulson@2318
   342
by (fast_tac (!claset addSEs partsEs
paulson@2318
   343
                      addSDs [new_nonces_not_seen, 
paulson@2318
   344
			      Says_imp_sees_Spy' RS parts.Inj]) 2);
paulson@2318
   345
(*Fake*)
paulson@2318
   346
by (REPEAT_FIRST (resolve_tac [impI, conjI]));
paulson@2318
   347
by (fast_tac (!claset addss (!simpset)) 1);
paulson@2318
   348
br (ccontr RS disjI2) 1;
paulson@2318
   349
by (forward_tac [Spy_not_see_NB] 1 THEN REPEAT (assume_tac 1));
paulson@2318
   350
by (Fast_tac 1);
paulson@2318
   351
by (best_tac (!claset addSDs [impOfSubs Fake_parts_insert]
paulson@2318
   352
	              addDs  [impOfSubs analz_subset_parts] 
paulson@2318
   353
	              addss (!simpset)) 1);
paulson@2318
   354
(*NS3*)
paulson@2318
   355
by (Step_tac 1);
paulson@2318
   356
by (forward_tac [Spy_not_see_NB] 1 THEN REPEAT1 (assume_tac 1));
paulson@2318
   357
by (Fast_tac 1);
paulson@2318
   358
by (best_tac (!claset addSDs [Says_imp_sees_Spy' RS parts.Inj]
paulson@2318
   359
	              addDs  [unique_NB]) 1);
paulson@2318
   360
qed_spec_mp "NB_decrypt_imp_A_msg";
paulson@2318
   361
paulson@2318
   362
paulson@2318
   363
(*Corollary: if B receives message NS3 and the nonce NB agrees
paulson@2318
   364
  then A sent NB to somebody....*)
paulson@2318
   365
goal thy 
paulson@2318
   366
 "!!evs. [| Says A' B (Crypt (pubK B) (Nonce NB)): set_of_list evs;    \
paulson@2318
   367
\           Says B A  (Crypt (pubK A) {|Nonce NA, Nonce NB|})          \
paulson@2318
   368
\             : set_of_list evs;                                       \
paulson@2318
   369
\           A ~: lost;  B ~: lost;  evs : ns_public |]                 \
paulson@2318
   370
\        ==> EX C. Says A C (Crypt (pubK C) (Nonce NB)) : set_of_list evs";
paulson@2318
   371
by (fast_tac (!claset addSIs [NB_decrypt_imp_A_msg]
paulson@2318
   372
                      addEs  partsEs
paulson@2318
   373
                      addDs  [Says_imp_sees_Spy' RS parts.Inj]) 1);
paulson@2318
   374
qed "B_trusts_NS3";
paulson@2318
   375
paulson@2318
   376
paulson@2318
   377
(*Can we strengthen the secrecy theorem?  NO*)
paulson@2318
   378
goal thy 
paulson@2318
   379
 "!!evs. [| A ~: lost;  B ~: lost;  evs : ns_public |]   \
paulson@2318
   380
\ ==> Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set_of_list evs \
paulson@2318
   381
\     --> Nonce NB ~: analz (sees lost Spy evs)";
paulson@2418
   382
by (analz_induct_tac 1);
paulson@2318
   383
(*NS1*)
paulson@2318
   384
by (fast_tac (!claset addSEs partsEs
paulson@2318
   385
                      addSDs [new_nonces_not_seen, 
paulson@2318
   386
			      Says_imp_sees_Spy' RS parts.Inj]) 2);
paulson@2318
   387
(*Fake*)
paulson@2374
   388
by (REPEAT_FIRST spy_analz_tac);
paulson@2318
   389
(*NS2 and NS3*)
paulson@2318
   390
by (Step_tac 1);
paulson@2318
   391
(*NS2*)
paulson@2318
   392
by (fast_tac (!claset addSEs partsEs
paulson@2318
   393
                      addSDs [new_nonces_not_seen, 
paulson@2318
   394
                              Says_imp_sees_Spy' RS parts.Inj]) 2);
paulson@2318
   395
by (fast_tac (!claset addSDs [Says_imp_sees_Spy' RS parts.Inj]
paulson@2318
   396
                      addEs  [no_nonce_NS1_NS2 RSN (2, rev_notE)]) 1);
paulson@2318
   397
(*NS3*)
paulson@2318
   398
by (forw_inst_tac [("A'","A")] (Says_imp_sees_Spy' RS parts.Inj RS unique_NB) 1
paulson@2318
   399
    THEN REPEAT (eresolve_tac [asm_rl, Says_imp_sees_Spy' RS parts.Inj] 1));
paulson@2318
   400
by (Step_tac 1);
paulson@2318
   401
paulson@2318
   402
(*
paulson@2318
   403
THIS IS THE ATTACK!
paulson@2318
   404
Level 9
paulson@2318
   405
!!evs. [| A ~: lost; B ~: lost; evs : ns_public |]
paulson@2318
   406
       ==> Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB|})
paulson@2318
   407
           : set_of_list evs -->
paulson@2318
   408
           Nonce NB ~: analz (sees lost Spy evs)
paulson@2318
   409
 1. !!evs Aa Ba B' NAa NBa evsa.
paulson@2318
   410
       [| A ~: lost; B ~: lost; evsa : ns_public; A ~= Ba;
paulson@2318
   411
          Says B' A (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set_of_list evsa;
paulson@2318
   412
          Says A Ba (Crypt (pubK Ba) {|Nonce NA, Agent A|}) : set_of_list evsa;
paulson@2318
   413
          Ba : lost;
paulson@2318
   414
          Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set_of_list evsa;
paulson@2318
   415
          Nonce NB ~: analz (sees lost Spy evsa) |]
paulson@2318
   416
       ==> False
paulson@2318
   417
*)
paulson@2318
   418
paulson@2318
   419
paulson@2318
   420