src/HOL/Auth/NS_Public.ML
author paulson
Fri Jan 17 12:49:31 1997 +0100 (1997-01-17)
changeset 2516 4d68fbe6378b
parent 2497 47de509bdd55
child 2536 1e04eb7f7eb1
permissions -rw-r--r--
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson@2318
     1
(*  Title:      HOL/Auth/NS_Public
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
Version incorporating Lowe's fix (inclusion of B's identify in round 2).
paulson@2318
     8
*)
paulson@2318
     9
paulson@2318
    10
open NS_Public;
paulson@2318
    11
paulson@2318
    12
proof_timing:=true;
paulson@2318
    13
HOL_quantifiers := false;
paulson@2318
    14
paulson@2318
    15
AddIffs [Spy_in_lost];
paulson@2318
    16
paulson@2318
    17
(*Replacing the variable by a constant improves search speed by 50%!*)
paulson@2318
    18
val Says_imp_sees_Spy' = 
paulson@2318
    19
    read_instantiate_sg (sign_of thy) [("lost","lost")] Says_imp_sees_Spy;
paulson@2318
    20
paulson@2318
    21
paulson@2318
    22
(*A "possibility property": there are traces that reach the end*)
paulson@2318
    23
goal thy 
paulson@2318
    24
 "!!A B. A ~= B ==> EX NB. EX evs: ns_public.               \
paulson@2318
    25
\                     Says A B (Crypt (pubK B) (Nonce NB)) : set_of_list evs";
paulson@2318
    26
by (REPEAT (resolve_tac [exI,bexI] 1));
paulson@2318
    27
by (rtac (ns_public.Nil RS ns_public.NS1 RS ns_public.NS2 RS ns_public.NS3) 2);
paulson@2516
    28
by possibility_tac;
paulson@2318
    29
result();
paulson@2318
    30
paulson@2318
    31
paulson@2318
    32
(**** Inductive proofs about ns_public ****)
paulson@2318
    33
paulson@2318
    34
(*Nobody sends themselves messages*)
paulson@2318
    35
goal thy "!!evs. evs : ns_public ==> ALL A X. Says A A X ~: set_of_list evs";
paulson@2318
    36
by (etac ns_public.induct 1);
paulson@2318
    37
by (Auto_tac());
paulson@2318
    38
qed_spec_mp "not_Says_to_self";
paulson@2318
    39
Addsimps [not_Says_to_self];
paulson@2318
    40
AddSEs   [not_Says_to_self RSN (2, rev_notE)];
paulson@2318
    41
paulson@2318
    42
paulson@2318
    43
(*For proving the easier theorems about X ~: parts (sees lost Spy evs) *)
paulson@2318
    44
fun parts_induct_tac i = SELECT_GOAL
paulson@2318
    45
    (DETERM (etac ns_public.induct 1 THEN 
paulson@2318
    46
             (*Fake message*)
paulson@2318
    47
             TRY (best_tac (!claset addDs [impOfSubs analz_subset_parts,
paulson@2318
    48
                                           impOfSubs Fake_parts_insert]
paulson@2318
    49
                                    addss (!simpset)) 2)) THEN
paulson@2318
    50
     (*Base case*)
paulson@2318
    51
     fast_tac (!claset addss (!simpset)) 1 THEN
paulson@2318
    52
     ALLGOALS Asm_simp_tac) i;
paulson@2318
    53
paulson@2318
    54
(** Theorems of the form X ~: parts (sees lost Spy evs) imply that NOBODY
paulson@2318
    55
    sends messages containing X! **)
paulson@2318
    56
paulson@2318
    57
(*Spy never sees another agent's private key! (unless it's lost at start)*)
paulson@2318
    58
goal thy 
paulson@2318
    59
 "!!evs. evs : ns_public \
paulson@2318
    60
\        ==> (Key (priK A) : parts (sees lost Spy evs)) = (A : lost)";
paulson@2318
    61
by (parts_induct_tac 1);
paulson@2318
    62
by (Auto_tac());
paulson@2318
    63
qed "Spy_see_priK";
paulson@2318
    64
Addsimps [Spy_see_priK];
paulson@2318
    65
paulson@2318
    66
goal thy 
paulson@2318
    67
 "!!evs. evs : ns_public \
paulson@2318
    68
\        ==> (Key (priK A) : analz (sees lost Spy evs)) = (A : lost)";
paulson@2318
    69
by (auto_tac(!claset addDs [impOfSubs analz_subset_parts], !simpset));
paulson@2318
    70
qed "Spy_analz_priK";
paulson@2318
    71
Addsimps [Spy_analz_priK];
paulson@2318
    72
paulson@2318
    73
goal thy  "!!A. [| Key (priK A) : parts (sees lost Spy evs);       \
paulson@2318
    74
\                  evs : ns_public |] ==> A:lost";
paulson@2318
    75
by (fast_tac (!claset addDs [Spy_see_priK]) 1);
paulson@2318
    76
qed "Spy_see_priK_D";
paulson@2318
    77
paulson@2318
    78
bind_thm ("Spy_analz_priK_D", analz_subset_parts RS subsetD RS Spy_see_priK_D);
paulson@2318
    79
AddSDs [Spy_see_priK_D, Spy_analz_priK_D];
paulson@2318
    80
paulson@2318
    81
paulson@2418
    82
fun analz_induct_tac i = 
paulson@2516
    83
    etac ns_public.induct i     THEN
paulson@2418
    84
    ALLGOALS (asm_simp_tac 
paulson@2516
    85
              (!simpset addsimps [not_parts_not_analz]
paulson@2451
    86
                        setloop split_tac [expand_if]));
paulson@2318
    87
paulson@2318
    88
(**** Authenticity properties obtained from NS2 ****)
paulson@2318
    89
paulson@2318
    90
(*It is impossible to re-use a nonce in both NS1 and NS2, provided the nonce
paulson@2318
    91
  is secret.  (Honest users generate fresh nonces.)*)
paulson@2318
    92
goal thy 
paulson@2318
    93
 "!!evs. evs : ns_public                       \
paulson@2318
    94
\ ==> Nonce NA ~: analz (sees lost Spy evs) -->           \
paulson@2318
    95
\     Crypt (pubK B) {|Nonce NA, Agent A|} : parts (sees lost Spy evs) --> \
paulson@2480
    96
\     Crypt (pubK C) {|NA', Nonce NA, Agent D|} ~: parts (sees lost Spy evs)";
paulson@2418
    97
by (analz_induct_tac 1);
paulson@2318
    98
(*NS3*)
paulson@2497
    99
by (fast_tac (!claset addSEs partsEs) 4);
paulson@2318
   100
(*NS2*)
paulson@2497
   101
by (fast_tac (!claset addSEs partsEs) 3);
paulson@2318
   102
(*Fake*)
paulson@2374
   103
by (best_tac (!claset addIs [analz_insertI]
paulson@2516
   104
                      addDs [impOfSubs analz_subset_parts,
paulson@2516
   105
                             impOfSubs Fake_parts_insert]
paulson@2516
   106
                      addss (!simpset)) 2);
paulson@2318
   107
(*Base*)
paulson@2374
   108
by (fast_tac (!claset addss (!simpset)) 1);
paulson@2318
   109
bind_thm ("no_nonce_NS1_NS2", result() RSN (2, rev_mp) RSN (2, rev_mp));
paulson@2318
   110
paulson@2318
   111
paulson@2480
   112
(*Unicity for NS1: nonce NA identifies agents A and B*)
paulson@2318
   113
goal thy 
paulson@2318
   114
 "!!evs. evs : ns_public                                                    \
paulson@2318
   115
\ ==> Nonce NA ~: analz (sees lost Spy evs) -->                             \
paulson@2318
   116
\     (EX A' B'. ALL A B.                                                   \
paulson@2318
   117
\      Crypt (pubK B) {|Nonce NA, Agent A|} : parts (sees lost Spy evs) --> \
paulson@2318
   118
\      A=A' & B=B')";
paulson@2418
   119
by (analz_induct_tac 1);
paulson@2318
   120
(*NS1*)
paulson@2497
   121
by (simp_tac (!simpset addsimps [all_conj_distrib]) 3);
paulson@2318
   122
by (expand_case_tac "NA = ?y" 3 THEN
paulson@2497
   123
    REPEAT (fast_tac (!claset addSEs partsEs) 3));
paulson@2318
   124
(*Base*)
paulson@2318
   125
by (fast_tac (!claset addss (!simpset)) 1);
paulson@2318
   126
(*Fake*)
paulson@2497
   127
by (simp_tac (!simpset addsimps [all_conj_distrib, parts_insert_sees]) 1);
paulson@2374
   128
by (step_tac (!claset addSIs [analz_insertI]) 1);
paulson@2318
   129
by (ex_strip_tac 1);
paulson@2318
   130
by (best_tac (!claset delrules [conjI]
paulson@2516
   131
                      addSDs [impOfSubs Fake_parts_insert]
paulson@2516
   132
                      addDs  [impOfSubs analz_subset_parts]
paulson@2318
   133
                      addss (!simpset)) 1);
paulson@2318
   134
val lemma = result();
paulson@2318
   135
paulson@2318
   136
goal thy 
paulson@2318
   137
 "!!evs. [| Crypt(pubK B)  {|Nonce NA, Agent A|}  : parts(sees lost Spy evs); \
paulson@2318
   138
\           Crypt(pubK B') {|Nonce NA, Agent A'|} : parts(sees lost Spy evs); \
paulson@2318
   139
\           Nonce NA ~: analz (sees lost Spy evs);                            \
paulson@2318
   140
\           evs : ns_public |]                                                \
paulson@2318
   141
\        ==> A=A' & B=B'";
paulson@2480
   142
by (prove_unique_tac lemma 1);
paulson@2318
   143
qed "unique_NA";
paulson@2318
   144
paulson@2318
   145
paulson@2318
   146
(*Secrecy: Spy does not see the nonce sent in msg NS1 if A and B are secure*)
paulson@2318
   147
goal thy 
paulson@2318
   148
 "!!evs. [| A ~: lost;  B ~: lost;  evs : ns_public |]   \
paulson@2318
   149
\ ==> Says A B (Crypt (pubK B) {|Nonce NA, Agent A|}) : set_of_list evs \
paulson@2318
   150
\     --> Nonce NA ~: analz (sees lost Spy evs)";
paulson@2418
   151
by (analz_induct_tac 1);
paulson@2318
   152
(*NS3*)
paulson@2318
   153
by (fast_tac (!claset addSDs [Says_imp_sees_Spy' RS parts.Inj]
paulson@2318
   154
                      addEs  [no_nonce_NS1_NS2 RSN (2, rev_notE)]) 4);
paulson@2318
   155
(*NS1*)
paulson@2318
   156
by (fast_tac (!claset addSEs partsEs
paulson@2516
   157
                      addSDs [Says_imp_sees_Spy' RS parts.Inj]
paulson@2497
   158
                      addIs  [impOfSubs analz_subset_parts]) 2);
paulson@2318
   159
(*Fake*)
paulson@2497
   160
by (spy_analz_tac 1);
paulson@2318
   161
(*NS2*)
paulson@2318
   162
by (Step_tac 1);
paulson@2318
   163
by (fast_tac (!claset addSEs partsEs
paulson@2497
   164
                      addSDs [Says_imp_sees_Spy' RS parts.Inj]) 2);
paulson@2497
   165
(*14 seconds.  Much slower still if one tries to prove all NS2 in one step.*)
paulson@2497
   166
by (best_tac (!claset addSDs [Says_imp_sees_Spy' RS parts.Inj]
paulson@2318
   167
                      addDs  [unique_NA]) 1);
paulson@2318
   168
bind_thm ("Spy_not_see_NA", result() RSN (2, rev_mp));
paulson@2318
   169
paulson@2318
   170
paulson@2318
   171
(*Authentication for A: if she receives message 2 and has used NA
paulson@2318
   172
  to start a run, then B has sent message 2.*)
paulson@2318
   173
goal thy 
paulson@2318
   174
 "!!evs. [| A ~: lost;  B ~: lost;  evs : ns_public |]       \
paulson@2318
   175
\ ==> Crypt (pubK A) {|Nonce NA, Nonce NB, Agent B|}         \
paulson@2318
   176
\                                : parts (sees lost Spy evs) \
paulson@2318
   177
\     --> Says A B (Crypt (pubK B) {|Nonce NA, Agent A|}) : set_of_list evs \
paulson@2318
   178
\     --> Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB, Agent B|})         \
paulson@2318
   179
\           : set_of_list evs";
paulson@2318
   180
by (etac ns_public.induct 1);
paulson@2318
   181
by (ALLGOALS Asm_simp_tac);
paulson@2318
   182
(*NS1*)
paulson@2318
   183
by (fast_tac (!claset addSEs partsEs
paulson@2497
   184
                      addSDs [Says_imp_sees_Spy' RS parts.Inj]) 2);
paulson@2318
   185
(*Fake*)
paulson@2318
   186
by (REPEAT_FIRST (resolve_tac [impI, conjI]));
paulson@2318
   187
by (fast_tac (!claset addss (!simpset)) 1);
paulson@2318
   188
by (forward_tac [Spy_not_see_NA] 1 THEN REPEAT (assume_tac 1));
paulson@2318
   189
by (best_tac (!claset addSIs [disjI2]
paulson@2516
   190
                      addSDs [impOfSubs Fake_parts_insert]
paulson@2516
   191
                      addDs  [impOfSubs analz_subset_parts]
paulson@2516
   192
                      addss (!simpset)) 1);
paulson@2318
   193
qed_spec_mp "NA_decrypt_imp_B_msg";
paulson@2318
   194
paulson@2318
   195
(*Corollary: if A receives B's message NS2 and the nonce NA agrees
paulson@2318
   196
  then that message really originated with B.*)
paulson@2318
   197
goal thy 
paulson@2318
   198
 "!!evs. [| Says B' A (Crypt(pubK A) {|Nonce NA, Nonce NB, Agent B|}) \
paulson@2318
   199
\             : set_of_list evs;\
paulson@2318
   200
\           Says A B (Crypt (pubK B) {|Nonce NA, Agent A|}) : set_of_list evs;\
paulson@2318
   201
\           A ~: lost;  B ~: lost;  evs : ns_public |]  \
paulson@2318
   202
\        ==> Says B A (Crypt(pubK A) {|Nonce NA, Nonce NB, Agent B|}) \
paulson@2318
   203
\              : set_of_list evs";
paulson@2318
   204
by (fast_tac (!claset addSIs [NA_decrypt_imp_B_msg]
paulson@2318
   205
                      addEs  partsEs
paulson@2318
   206
                      addDs  [Says_imp_sees_Spy' RS parts.Inj]) 1);
paulson@2318
   207
qed "A_trusts_NS2";
paulson@2318
   208
paulson@2318
   209
(*If the encrypted message appears then it originated with Alice in NS1*)
paulson@2318
   210
goal thy 
paulson@2318
   211
 "!!evs. evs : ns_public                   \
paulson@2318
   212
\    ==> Nonce NA ~: analz (sees lost Spy evs) --> \
paulson@2318
   213
\        Crypt (pubK B) {|Nonce NA, Agent A|} : parts (sees lost Spy evs) --> \
paulson@2480
   214
\        Says A B (Crypt (pubK B) {|Nonce NA, Agent A|}) : set_of_list evs";
paulson@2480
   215
by (analz_induct_tac 1);
paulson@2318
   216
(*Fake*)
paulson@2318
   217
by (best_tac (!claset addSIs [disjI2]
paulson@2516
   218
                      addSDs [impOfSubs Fake_parts_insert]
paulson@2516
   219
                      addIs  [analz_insertI]
paulson@2516
   220
                      addDs  [impOfSubs analz_subset_parts]
paulson@2516
   221
                      addss (!simpset)) 2);
paulson@2318
   222
(*Base*)
paulson@2318
   223
by (fast_tac (!claset addss (!simpset)) 1);
paulson@2318
   224
qed_spec_mp "B_trusts_NS1";
paulson@2318
   225
paulson@2318
   226
paulson@2318
   227
paulson@2318
   228
(**** Authenticity properties obtained from NS2 ****)
paulson@2318
   229
paulson@2480
   230
(*Unicity for NS2: nonce NB identifies nonce NA and agents A, B 
paulson@2318
   231
  [unicity of B makes Lowe's fix work]
paulson@2318
   232
  [proof closely follows that for unique_NA] *)
paulson@2318
   233
goal thy 
paulson@2318
   234
 "!!evs. evs : ns_public                                                    \
paulson@2318
   235
\ ==> Nonce NB ~: analz (sees lost Spy evs) -->                             \
paulson@2318
   236
\     (EX A' NA' B'. ALL A NA B.                                            \
paulson@2318
   237
\      Crypt (pubK A) {|Nonce NA, Nonce NB, Agent B|}   \
paulson@2318
   238
\        : parts (sees lost Spy evs)  -->  A=A' & NA=NA' & B=B')";
paulson@2418
   239
by (analz_induct_tac 1);
paulson@2318
   240
(*NS2*)
paulson@2497
   241
by (simp_tac (!simpset addsimps [all_conj_distrib]) 3);
paulson@2318
   242
by (expand_case_tac "NB = ?y" 3 THEN
paulson@2497
   243
    REPEAT (fast_tac (!claset addSEs partsEs) 3));
paulson@2318
   244
(*Base*)
paulson@2318
   245
by (fast_tac (!claset addss (!simpset)) 1);
paulson@2318
   246
(*Fake*)
paulson@2497
   247
by (simp_tac (!simpset addsimps [all_conj_distrib, parts_insert_sees]) 1);
paulson@2374
   248
by (step_tac (!claset addSIs [analz_insertI]) 1);
paulson@2318
   249
by (ex_strip_tac 1);
paulson@2318
   250
by (best_tac (!claset delrules [conjI]
paulson@2516
   251
                      addSDs [impOfSubs Fake_parts_insert]
paulson@2516
   252
                      addDs  [impOfSubs analz_subset_parts] 
paulson@2516
   253
                      addss (!simpset)) 1);
paulson@2318
   254
val lemma = result();
paulson@2318
   255
paulson@2318
   256
goal thy 
paulson@2318
   257
 "!!evs. [| Crypt(pubK A)  {|Nonce NA, Nonce NB, Agent B|}   \
paulson@2318
   258
\             : parts(sees lost Spy evs);                    \
paulson@2318
   259
\           Crypt(pubK A') {|Nonce NA', Nonce NB, Agent B'|} \
paulson@2318
   260
\             : parts(sees lost Spy evs);                    \
paulson@2318
   261
\           Nonce NB ~: analz (sees lost Spy evs);           \
paulson@2318
   262
\           evs : ns_public |]                               \
paulson@2318
   263
\        ==> A=A' & NA=NA' & B=B'";
paulson@2418
   264
by (prove_unique_tac lemma 1);
paulson@2318
   265
qed "unique_NB";
paulson@2318
   266
paulson@2318
   267
paulson@2318
   268
(*Secrecy: Spy does not see the nonce sent in msg NS2 if A and B are secure*)
paulson@2318
   269
goal thy 
paulson@2318
   270
 "!!evs. [| A ~: lost;  B ~: lost;  evs : ns_public |]   \
paulson@2318
   271
\ ==> Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB, Agent B|}) \
paulson@2318
   272
\       : set_of_list evs \
paulson@2318
   273
\     --> Nonce NB ~: analz (sees lost Spy evs)";
paulson@2418
   274
by (analz_induct_tac 1);
paulson@2318
   275
(*NS3*)
paulson@2318
   276
by (fast_tac (!claset addSDs [Says_imp_sees_Spy' RS parts.Inj]
paulson@2318
   277
                      addDs  [unique_NB]) 4);
paulson@2318
   278
(*NS1*)
paulson@2318
   279
by (fast_tac (!claset addSEs partsEs
paulson@2497
   280
                      addSDs [Says_imp_sees_Spy' RS parts.Inj]) 2);
paulson@2318
   281
(*Fake*)
paulson@2497
   282
by (spy_analz_tac 1);
paulson@2318
   283
(*NS2*)
paulson@2318
   284
by (Step_tac 1);
paulson@2318
   285
by (fast_tac (!claset addSEs partsEs
paulson@2497
   286
                      addSDs [Says_imp_sees_Spy' RS parts.Inj]) 3);
paulson@2497
   287
by (best_tac (!claset addSDs [Says_imp_sees_Spy' RS parts.Inj]
paulson@2497
   288
                      addEs  [no_nonce_NS1_NS2 RSN (2, rev_notE)]) 2);
paulson@2497
   289
by (fast_tac (!claset addIs  [impOfSubs analz_subset_parts]) 1);
paulson@2318
   290
bind_thm ("Spy_not_see_NB", result() RSN (2, rev_mp));
paulson@2318
   291
paulson@2318
   292
paulson@2318
   293
(*Matches only NS2, not NS1 (or NS3)*)
paulson@2318
   294
val Says_imp_sees_Spy'' = 
paulson@2318
   295
    read_instantiate [("X","Crypt ?K {|?XX,?YY,?ZZ|}")] Says_imp_sees_Spy';
paulson@2318
   296
paulson@2318
   297
paulson@2318
   298
(*Authentication for B: if he receives message 3 and has used NB
paulson@2318
   299
  in message 2, then A has sent message 3.*)
paulson@2318
   300
goal thy 
paulson@2318
   301
 "!!evs. [| A ~: lost;  B ~: lost;  evs : ns_public |]       \
paulson@2318
   302
\ ==> Crypt (pubK B) (Nonce NB) : parts (sees lost Spy evs) \
paulson@2318
   303
\     --> Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB, Agent B|}) \
paulson@2318
   304
\       : set_of_list evs \
paulson@2318
   305
\     --> Says A B (Crypt (pubK B) (Nonce NB)) : set_of_list evs";
paulson@2318
   306
by (etac ns_public.induct 1);
paulson@2318
   307
by (ALLGOALS Asm_simp_tac);
paulson@2318
   308
(*NS1*)
paulson@2318
   309
by (fast_tac (!claset addSEs partsEs
paulson@2497
   310
                      addSDs [Says_imp_sees_Spy' RS parts.Inj]) 2);
paulson@2318
   311
(*Fake*)
paulson@2318
   312
by (REPEAT_FIRST (resolve_tac [impI, conjI]));
paulson@2318
   313
by (fast_tac (!claset addss (!simpset)) 1);
paulson@2318
   314
by (forward_tac [Spy_not_see_NB] 1 THEN REPEAT (assume_tac 1));
paulson@2318
   315
by (best_tac (!claset addSIs [disjI2]
paulson@2516
   316
                      addSDs [impOfSubs Fake_parts_insert]
paulson@2516
   317
                      addDs  [impOfSubs analz_subset_parts] 
paulson@2516
   318
                      addss (!simpset)) 1);
paulson@2318
   319
(*NS3*)
paulson@2318
   320
by (Step_tac 1);
paulson@2318
   321
by (forward_tac [Spy_not_see_NB] 1 THEN REPEAT (assume_tac 1));
paulson@2318
   322
by (best_tac (!claset addSDs [Says_imp_sees_Spy'' RS parts.Inj]
paulson@2516
   323
                      addDs  [unique_NB]) 1);
paulson@2318
   324
qed_spec_mp "NB_decrypt_imp_A_msg";
paulson@2318
   325
paulson@2324
   326
(*Corollary: if B receives message NS3 and the nonce NB agrees,
paulson@2318
   327
  then that message really originated with A.*)
paulson@2318
   328
goal thy 
paulson@2318
   329
 "!!evs. [| Says A' B (Crypt (pubK B) (Nonce NB)): set_of_list evs;    \
paulson@2318
   330
\           Says B A  (Crypt (pubK A) {|Nonce NA, Nonce NB, Agent B|}) \
paulson@2318
   331
\             : set_of_list evs;                                       \
paulson@2318
   332
\           A ~: lost;  B ~: lost;  evs : ns_public |]                 \
paulson@2318
   333
\        ==> Says A B (Crypt (pubK B) (Nonce NB)) : set_of_list evs";
paulson@2318
   334
by (fast_tac (!claset addSIs [NB_decrypt_imp_A_msg]
paulson@2318
   335
                      addEs  partsEs
paulson@2318
   336
                      addDs  [Says_imp_sees_Spy' RS parts.Inj]) 1);
paulson@2318
   337
qed "B_trusts_NS3";
paulson@2318
   338
paulson@2318
   339
paulson@2318
   340
(**** Overall guarantee for B*)
paulson@2318
   341
paulson@2318
   342
(*If B receives NS3 and the nonce NB agrees with the nonce he joined with
paulson@2318
   343
  NA, then A initiated the run using NA.
paulson@2318
   344
  SAME PROOF AS NB_decrypt_imp_A_msg*)
paulson@2318
   345
goal thy 
paulson@2318
   346
 "!!evs. [| A ~: lost;  B ~: lost;  evs : ns_public |]       \
paulson@2318
   347
\ ==> Crypt (pubK B) (Nonce NB) : parts (sees lost Spy evs) \
paulson@2318
   348
\     --> Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB, Agent B|}) \
paulson@2318
   349
\       : set_of_list evs \
paulson@2318
   350
\     --> Says A B (Crypt (pubK B) {|Nonce NA, Agent A|}) : set_of_list evs";
paulson@2318
   351
by (etac ns_public.induct 1);
paulson@2318
   352
by (ALLGOALS Asm_simp_tac);
paulson@2318
   353
(*Fake, NS2, NS3*)
paulson@2318
   354
(*NS1*)
paulson@2318
   355
by (fast_tac (!claset addSEs partsEs
paulson@2497
   356
                      addSDs [Says_imp_sees_Spy' RS parts.Inj]) 2);
paulson@2318
   357
(*Fake*)
paulson@2318
   358
by (REPEAT_FIRST (resolve_tac [impI, conjI]));
paulson@2318
   359
by (fast_tac (!claset addss (!simpset)) 1);
paulson@2318
   360
by (forward_tac [Spy_not_see_NB] 1 THEN REPEAT (assume_tac 1));
paulson@2318
   361
by (best_tac (!claset addSIs [disjI2]
paulson@2516
   362
                      addDs [impOfSubs analz_subset_parts,
paulson@2516
   363
                             impOfSubs Fake_parts_insert]
paulson@2516
   364
                      addss (!simpset)) 1);
paulson@2318
   365
(*NS3*)
paulson@2318
   366
by (Step_tac 1);
paulson@2318
   367
by (forward_tac [Spy_not_see_NB] 1 THEN REPEAT (assume_tac 1));
paulson@2318
   368
by (best_tac (!claset addSDs [Says_imp_sees_Spy'' RS parts.Inj]
paulson@2516
   369
                      addDs  [unique_NB]) 1);
paulson@2318
   370
val lemma = result() RSN (2, rev_mp) RSN (2, rev_mp);
paulson@2318
   371
paulson@2318
   372
goal thy 
paulson@2318
   373
 "!!evs. [| Says A' B (Crypt (pubK B) (Nonce NB)): set_of_list evs;    \
paulson@2318
   374
\           Says B A  (Crypt (pubK A) {|Nonce NA, Nonce NB, Agent B|}) \
paulson@2318
   375
\             : set_of_list evs;                                       \
paulson@2318
   376
\           A ~: lost;  B ~: lost;  evs : ns_public |]                 \
paulson@2318
   377
\    ==> Says A B (Crypt (pubK B) {|Nonce NA, Agent A|}) : set_of_list evs";
paulson@2318
   378
by (fast_tac (!claset addSIs [lemma]
paulson@2318
   379
                      addEs  partsEs
paulson@2318
   380
                      addDs  [Says_imp_sees_Spy' RS parts.Inj]) 1);
paulson@2318
   381
qed_spec_mp "B_trusts_protocol";
paulson@2318
   382