src/HOL/Auth/NS_Shared.ML
changeset 3683 aafe719dff14
parent 3679 8df171ccdbd8
child 3730 6933d20f335f
equal deleted inserted replaced
3682:597efdb7decb 3683:aafe719dff14
    46 Addsimps [not_Says_to_self];
    46 Addsimps [not_Says_to_self];
    47 AddSEs   [not_Says_to_self RSN (2, rev_notE)];
    47 AddSEs   [not_Says_to_self RSN (2, rev_notE)];
    48 
    48 
    49 (*For reasoning about the encrypted portion of message NS3*)
    49 (*For reasoning about the encrypted portion of message NS3*)
    50 goal thy "!!evs. Says S A (Crypt KA {|N, B, K, X|}) : set evs \
    50 goal thy "!!evs. Says S A (Crypt KA {|N, B, K, X|}) : set evs \
    51 \                ==> X : parts (sees Spy evs)";
    51 \                ==> X : parts (spies evs)";
    52 by (blast_tac (!claset addSEs sees_Spy_partsEs) 1);
    52 by (blast_tac (!claset addSEs spies_partsEs) 1);
    53 qed "NS3_msg_in_parts_sees_Spy";
    53 qed "NS3_msg_in_parts_spies";
    54                               
    54                               
    55 goal thy
    55 goal thy
    56     "!!evs. Says Server A (Crypt (shrK A) {|NA, B, K, X|}) : set evs \
    56     "!!evs. Says Server A (Crypt (shrK A) {|NA, B, K, X|}) : set evs \
    57 \           ==> K : parts (sees Spy evs)";
    57 \           ==> K : parts (spies evs)";
    58 by (blast_tac (!claset addSEs sees_Spy_partsEs) 1);
    58 by (blast_tac (!claset addSEs spies_partsEs) 1);
    59 qed "Oops_parts_sees_Spy";
    59 qed "Oops_parts_spies";
    60 
    60 
    61 (*For proving the easier theorems about X ~: parts (sees Spy evs).*)
    61 (*For proving the easier theorems about X ~: parts (spies evs).*)
    62 fun parts_induct_tac i = 
    62 fun parts_induct_tac i = 
    63     etac ns_shared.induct i  THEN 
    63     etac ns_shared.induct i  THEN 
    64     forward_tac [Oops_parts_sees_Spy] (i+7)  THEN
    64     forward_tac [Oops_parts_spies] (i+7)  THEN
    65     dtac NS3_msg_in_parts_sees_Spy (i+4)     THEN
    65     dtac NS3_msg_in_parts_spies (i+4)     THEN
    66     prove_simple_subgoals_tac i;
    66     prove_simple_subgoals_tac i;
    67 
    67 
    68 
    68 
    69 (** Theorems of the form X ~: parts (sees Spy evs) imply that NOBODY
    69 (** Theorems of the form X ~: parts (spies evs) imply that NOBODY
    70     sends messages containing X! **)
    70     sends messages containing X! **)
    71 
    71 
    72 (*Spy never sees another agent's shared key! (unless it's lost at start)*)
    72 (*Spy never sees another agent's shared key! (unless it's bad at start)*)
    73 goal thy 
    73 goal thy 
    74  "!!evs. evs : ns_shared \
    74  "!!evs. evs : ns_shared ==> (Key (shrK A) : parts (spies evs)) = (A : bad)";
    75 \        ==> (Key (shrK A) : parts (sees Spy evs)) = (A : lost)";
       
    76 by (parts_induct_tac 1);
    75 by (parts_induct_tac 1);
    77 by (Fake_parts_insert_tac 1);
    76 by (Fake_parts_insert_tac 1);
    78 by (Blast_tac 1);
    77 by (Blast_tac 1);
    79 qed "Spy_see_shrK";
    78 qed "Spy_see_shrK";
    80 Addsimps [Spy_see_shrK];
    79 Addsimps [Spy_see_shrK];
    81 
    80 
    82 goal thy 
    81 goal thy 
    83  "!!evs. evs : ns_shared \
    82  "!!evs. evs : ns_shared ==> (Key (shrK A) : analz (spies evs)) = (A : bad)";
    84 \        ==> (Key (shrK A) : analz (sees Spy evs)) = (A : lost)";
       
    85 by (auto_tac(!claset addDs [impOfSubs analz_subset_parts], !simpset));
    83 by (auto_tac(!claset addDs [impOfSubs analz_subset_parts], !simpset));
    86 qed "Spy_analz_shrK";
    84 qed "Spy_analz_shrK";
    87 Addsimps [Spy_analz_shrK];
    85 Addsimps [Spy_analz_shrK];
    88 
    86 
    89 goal thy  "!!A. [| Key (shrK A) : parts (sees Spy evs);       \
    87 goal thy  "!!A. [| Key (shrK A) : parts (spies evs);       \
    90 \                  evs : ns_shared |] ==> A:lost";
    88 \                  evs : ns_shared |] ==> A:bad";
    91 by (blast_tac (!claset addDs [Spy_see_shrK]) 1);
    89 by (blast_tac (!claset addDs [Spy_see_shrK]) 1);
    92 qed "Spy_see_shrK_D";
    90 qed "Spy_see_shrK_D";
    93 
    91 
    94 bind_thm ("Spy_analz_shrK_D", analz_subset_parts RS subsetD RS Spy_see_shrK_D);
    92 bind_thm ("Spy_analz_shrK_D", analz_subset_parts RS subsetD RS Spy_see_shrK_D);
    95 AddSDs [Spy_see_shrK_D, Spy_analz_shrK_D];
    93 AddSDs [Spy_see_shrK_D, Spy_analz_shrK_D];
    96 
    94 
    97 
    95 
    98 (*Nobody can have used non-existent keys!*)
    96 (*Nobody can have used non-existent keys!*)
    99 goal thy "!!evs. evs : ns_shared ==>      \
    97 goal thy "!!evs. evs : ns_shared ==>      \
   100 \         Key K ~: used evs --> K ~: keysFor (parts (sees Spy evs))";
    98 \         Key K ~: used evs --> K ~: keysFor (parts (spies evs))";
   101 by (parts_induct_tac 1);
    99 by (parts_induct_tac 1);
   102 (*Fake*)
   100 (*Fake*)
   103 by (best_tac
   101 by (best_tac
   104       (!claset addIs [impOfSubs analz_subset_parts]
   102       (!claset addIs [impOfSubs analz_subset_parts]
   105                addDs [impOfSubs (analz_subset_parts RS keysFor_mono),
   103                addDs [impOfSubs (analz_subset_parts RS keysFor_mono),
   106                       impOfSubs (parts_insert_subset_Un RS keysFor_mono)]
   104                       impOfSubs (parts_insert_subset_Un RS keysFor_mono)]
   107                addss (!simpset)) 1);
   105                addss (!simpset)) 1);
   108 (*NS2, NS4, NS5*)
   106 (*NS2, NS4, NS5*)
   109 by (ALLGOALS (blast_tac (!claset addSEs sees_Spy_partsEs)));
   107 by (ALLGOALS (blast_tac (!claset addSEs spies_partsEs)));
   110 qed_spec_mp "new_keys_not_used";
   108 qed_spec_mp "new_keys_not_used";
   111 
   109 
   112 bind_thm ("new_keys_not_analzd",
   110 bind_thm ("new_keys_not_analzd",
   113           [analz_subset_parts RS keysFor_mono,
   111           [analz_subset_parts RS keysFor_mono,
   114            new_keys_not_used] MRS contra_subsetD);
   112            new_keys_not_used] MRS contra_subsetD);
   118 
   116 
   119 (** Lemmas concerning the form of items passed in messages **)
   117 (** Lemmas concerning the form of items passed in messages **)
   120 
   118 
   121 (*Describes the form of K, X and K' when the Server sends this message.*)
   119 (*Describes the form of K, X and K' when the Server sends this message.*)
   122 goal thy 
   120 goal thy 
   123  "!!evs. [| Says Server A (Crypt K' {|N, Agent B, Key K, X|}) \
   121  "!!evs. [| Says Server A (Crypt K' {|N, Agent B, Key K, X|}) : set evs; \
   124 \             : set evs;                                      \
       
   125 \           evs : ns_shared |]                           \
   122 \           evs : ns_shared |]                           \
   126 \        ==> K ~: range shrK &                                \
   123 \        ==> K ~: range shrK &                                \
   127 \            X = (Crypt (shrK B) {|Key K, Agent A|}) &        \
   124 \            X = (Crypt (shrK B) {|Key K, Agent A|}) &        \
   128 \            K' = shrK A";
   125 \            K' = shrK A";
   129 by (etac rev_mp 1);
   126 by (etac rev_mp 1);
   132 qed "Says_Server_message_form";
   129 qed "Says_Server_message_form";
   133 
   130 
   134 
   131 
   135 (*If the encrypted message appears then it originated with the Server*)
   132 (*If the encrypted message appears then it originated with the Server*)
   136 goal thy
   133 goal thy
   137  "!!evs. [| Crypt (shrK A) {|NA, Agent B, Key K, X|}                    \
   134  "!!evs. [| Crypt (shrK A) {|NA, Agent B, Key K, X|} : parts (spies evs); \
   138 \            : parts (sees Spy evs);                                    \
   135 \           A ~: bad;  evs : ns_shared |]                              \
   139 \           A ~: lost;  evs : ns_shared |]                              \
       
   140 \         ==> Says Server A (Crypt (shrK A) {|NA, Agent B, Key K, X|})  \
   136 \         ==> Says Server A (Crypt (shrK A) {|NA, Agent B, Key K, X|})  \
   141 \               : set evs";
   137 \               : set evs";
   142 by (etac rev_mp 1);
   138 by (etac rev_mp 1);
   143 by (parts_induct_tac 1);
   139 by (parts_induct_tac 1);
   144 by (Fake_parts_insert_tac 1);
   140 by (Fake_parts_insert_tac 1);
   151 goal thy 
   147 goal thy 
   152  "!!evs. [| Says S A (Crypt (shrK A) {|Nonce NA, Agent B, Key K, X|})      \
   148  "!!evs. [| Says S A (Crypt (shrK A) {|Nonce NA, Agent B, Key K, X|})      \
   153 \              : set evs;                                                  \
   149 \              : set evs;                                                  \
   154 \           evs : ns_shared |]                                             \
   150 \           evs : ns_shared |]                                             \
   155 \        ==> (K ~: range shrK & X = (Crypt (shrK B) {|Key K, Agent A|}))   \
   151 \        ==> (K ~: range shrK & X = (Crypt (shrK B) {|Key K, Agent A|}))   \
   156 \            | X : analz (sees Spy evs)";
   152 \            | X : analz (spies evs)";
   157 by (case_tac "A : lost" 1);
   153 by (case_tac "A : bad" 1);
   158 by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS analz.Inj]
   154 by (fast_tac (!claset addSDs [Says_imp_spies RS analz.Inj]
   159                       addss (!simpset)) 1);
   155                       addss (!simpset)) 1);
   160 by (forward_tac [Says_imp_sees_Spy RS parts.Inj] 1);
   156 by (forward_tac [Says_imp_spies RS parts.Inj] 1);
   161 by (blast_tac (!claset addSDs [A_trusts_NS2, Says_Server_message_form]) 1);
   157 by (blast_tac (!claset addSDs [A_trusts_NS2, Says_Server_message_form]) 1);
   162 qed "Says_S_message_form";
   158 qed "Says_S_message_form";
   163 
   159 
   164 
   160 
   165 (*For proofs involving analz.*)
   161 (*For proofs involving analz.*)
   166 val analz_sees_tac = 
   162 val analz_spies_tac = 
   167     forward_tac [Says_Server_message_form] 8 THEN
   163     forward_tac [Says_Server_message_form] 8 THEN
   168     forward_tac [Says_S_message_form] 5 THEN 
   164     forward_tac [Says_S_message_form] 5 THEN 
   169     REPEAT_FIRST (eresolve_tac [asm_rl, conjE, disjE] ORELSE' hyp_subst_tac);
   165     REPEAT_FIRST (eresolve_tac [asm_rl, conjE, disjE] ORELSE' hyp_subst_tac);
   170 
   166 
   171 
   167 
   172 (****
   168 (****
   173  The following is to prove theorems of the form
   169  The following is to prove theorems of the form
   174 
   170 
   175   Key K : analz (insert (Key KAB) (sees Spy evs)) ==>
   171   Key K : analz (insert (Key KAB) (spies evs)) ==>
   176   Key K : analz (sees Spy evs)
   172   Key K : analz (spies evs)
   177 
   173 
   178  A more general formula must be proved inductively.
   174  A more general formula must be proved inductively.
   179 
   175 
   180 ****)
   176 ****)
   181 
   177 
   183 (*NOT useful in this form, but it says that session keys are not used
   179 (*NOT useful in this form, but it says that session keys are not used
   184   to encrypt messages containing other keys, in the actual protocol.
   180   to encrypt messages containing other keys, in the actual protocol.
   185   We require that agents should behave like this subsequently also.*)
   181   We require that agents should behave like this subsequently also.*)
   186 goal thy 
   182 goal thy 
   187  "!!evs. [| evs : ns_shared;  Kab ~: range shrK |] ==>  \
   183  "!!evs. [| evs : ns_shared;  Kab ~: range shrK |] ==>  \
   188 \           (Crypt KAB X) : parts (sees Spy evs) &      \
   184 \           (Crypt KAB X) : parts (spies evs) &      \
   189 \           Key K : parts {X} --> Key K : parts (sees Spy evs)";
   185 \           Key K : parts {X} --> Key K : parts (spies evs)";
   190 by (parts_induct_tac 1);
   186 by (parts_induct_tac 1);
   191 (*Deals with Faked messages*)
   187 (*Deals with Faked messages*)
   192 by (blast_tac (!claset addSEs partsEs
   188 by (blast_tac (!claset addSEs partsEs
   193                        addDs [impOfSubs parts_insert_subset_Un]) 1);
   189                        addDs [impOfSubs parts_insert_subset_Un]) 1);
   194 (*Base, NS4 and NS5*)
   190 (*Base, NS4 and NS5*)
   200 
   196 
   201 (*The equality makes the induction hypothesis easier to apply*)
   197 (*The equality makes the induction hypothesis easier to apply*)
   202 goal thy  
   198 goal thy  
   203  "!!evs. evs : ns_shared ==>                                \
   199  "!!evs. evs : ns_shared ==>                                \
   204 \  ALL K KK. KK <= Compl (range shrK) -->                        \
   200 \  ALL K KK. KK <= Compl (range shrK) -->                        \
   205 \            (Key K : analz (Key``KK Un (sees Spy evs))) =  \
   201 \            (Key K : analz (Key``KK Un (spies evs))) =  \
   206 \            (K : KK | Key K : analz (sees Spy evs))";
   202 \            (K : KK | Key K : analz (spies evs))";
   207 by (etac ns_shared.induct 1);
   203 by (etac ns_shared.induct 1);
   208 by analz_sees_tac;
   204 by analz_spies_tac;
   209 by (REPEAT_FIRST (resolve_tac [allI, impI]));
   205 by (REPEAT_FIRST (resolve_tac [allI, impI]));
   210 by (REPEAT_FIRST (rtac analz_image_freshK_lemma ));
   206 by (REPEAT_FIRST (rtac analz_image_freshK_lemma ));
   211 (*Takes 24 secs*)
   207 (*Takes 24 secs*)
   212 by (ALLGOALS (asm_simp_tac analz_image_freshK_ss));
   208 by (ALLGOALS (asm_simp_tac analz_image_freshK_ss));
   213 (*Fake*) 
   209 (*Fake*) 
   217 qed_spec_mp "analz_image_freshK";
   213 qed_spec_mp "analz_image_freshK";
   218 
   214 
   219 
   215 
   220 goal thy
   216 goal thy
   221  "!!evs. [| evs : ns_shared;  KAB ~: range shrK |] ==>     \
   217  "!!evs. [| evs : ns_shared;  KAB ~: range shrK |] ==>     \
   222 \        Key K : analz (insert (Key KAB) (sees Spy evs)) = \
   218 \        Key K : analz (insert (Key KAB) (spies evs)) = \
   223 \        (K = KAB | Key K : analz (sees Spy evs))";
   219 \        (K = KAB | Key K : analz (spies evs))";
   224 by (asm_simp_tac (analz_image_freshK_ss addsimps [analz_image_freshK]) 1);
   220 by (asm_simp_tac (analz_image_freshK_ss addsimps [analz_image_freshK]) 1);
   225 qed "analz_insert_freshK";
   221 qed "analz_insert_freshK";
   226 
   222 
   227 
   223 
   228 (** The session key K uniquely identifies the message **)
   224 (** The session key K uniquely identifies the message **)
   229 
   225 
   230 goal thy 
   226 goal thy 
   231  "!!evs. evs : ns_shared ==>                                        \
   227  "!!evs. evs : ns_shared ==>                                        \
   232 \      EX A' NA' B' X'. ALL A NA B X.                                    \
   228 \      EX A' NA' B' X'. ALL A NA B X.                                    \
   233 \       Says Server A (Crypt (shrK A) {|NA, Agent B, Key K, X|})         \
   229 \       Says Server A (Crypt (shrK A) {|NA, Agent B, Key K, X|}) : set evs \
   234 \       : set evs -->         A=A' & NA=NA' & B=B' & X=X'";
   230 \       -->         A=A' & NA=NA' & B=B' & X=X'";
   235 by (etac ns_shared.induct 1);
   231 by (etac ns_shared.induct 1);
   236 by (ALLGOALS (asm_simp_tac (!simpset addsimps [all_conj_distrib])));
   232 by (ALLGOALS (asm_simp_tac (!simpset addsimps [all_conj_distrib])));
   237 by (Step_tac 1);
   233 by (Step_tac 1);
   238 (*NS3*)
   234 (*NS3*)
   239 by (ex_strip_tac 2);
   235 by (ex_strip_tac 2);
   240 by (Blast_tac 2);
   236 by (Blast_tac 2);
   241 (*NS2: it can't be a new key*)
   237 (*NS2: it can't be a new key*)
   242 by (expand_case_tac "K = ?y" 1);
   238 by (expand_case_tac "K = ?y" 1);
   243 by (REPEAT (ares_tac [refl,exI,impI,conjI] 2));
   239 by (REPEAT (ares_tac [refl,exI,impI,conjI] 2));
   244 by (blast_tac (!claset delrules [conjI]    (*prevent split-up into 4 subgoals*)
   240 by (blast_tac (!claset delrules [conjI]    (*prevent split-up into 4 subgoals*)
   245                       addSEs sees_Spy_partsEs) 1);
   241                       addSEs spies_partsEs) 1);
   246 val lemma = result();
   242 val lemma = result();
   247 
   243 
   248 (*In messages of this form, the session key uniquely identifies the rest*)
   244 (*In messages of this form, the session key uniquely identifies the rest*)
   249 goal thy 
   245 goal thy 
   250  "!!evs. [| Says Server A                                    \
   246  "!!evs. [| Says Server A                                    \
   251 \             (Crypt (shrK A) {|NA, Agent B, Key K, X|})     \
   247 \             (Crypt (shrK A) {|NA, Agent B, Key K, X|}) : set evs; \ 
   252 \                  : set evs;                                \ 
       
   253 \           Says Server A'                                   \
   248 \           Says Server A'                                   \
   254 \             (Crypt (shrK A') {|NA', Agent B', Key K, X'|}) \
   249 \             (Crypt (shrK A') {|NA', Agent B', Key K, X'|}) : set evs; \
   255 \                  : set evs;                                \
       
   256 \           evs : ns_shared |] ==> A=A' & NA=NA' & B=B' & X = X'";
   250 \           evs : ns_shared |] ==> A=A' & NA=NA' & B=B' & X = X'";
   257 by (prove_unique_tac lemma 1);
   251 by (prove_unique_tac lemma 1);
   258 qed "unique_session_keys";
   252 qed "unique_session_keys";
   259 
   253 
   260 
   254 
   261 (** Crucial secrecy property: Spy does not see the keys sent in msg NS2 **)
   255 (** Crucial secrecy property: Spy does not see the keys sent in msg NS2 **)
   262 
   256 
   263 goal thy 
   257 goal thy 
   264  "!!evs. [| A ~: lost;  B ~: lost;  evs : ns_shared |]            \
   258  "!!evs. [| A ~: bad;  B ~: bad;  evs : ns_shared |]            \
   265 \        ==> Says Server A                                             \
   259 \        ==> Says Server A                                             \
   266 \              (Crypt (shrK A) {|NA, Agent B, Key K,                   \
   260 \              (Crypt (shrK A) {|NA, Agent B, Key K,                   \
   267 \                                Crypt (shrK B) {|Key K, Agent A|}|})  \
   261 \                                Crypt (shrK B) {|Key K, Agent A|}|})  \
   268 \             : set evs -->                                            \
   262 \             : set evs -->                                            \
   269 \        (ALL NB. Says A Spy {|NA, NB, Key K|} ~: set evs) -->         \
   263 \        (ALL NB. Says A Spy {|NA, NB, Key K|} ~: set evs) -->         \
   270 \        Key K ~: analz (sees Spy evs)";
   264 \        Key K ~: analz (spies evs)";
   271 by (etac ns_shared.induct 1);
   265 by (etac ns_shared.induct 1);
   272 by analz_sees_tac;
   266 by analz_spies_tac;
   273 by (ALLGOALS 
   267 by (ALLGOALS 
   274     (asm_simp_tac 
   268     (asm_simp_tac 
   275      (!simpset addsimps ([analz_insert_eq, analz_insert_freshK] @ pushes)
   269      (!simpset addsimps ([analz_insert_eq, analz_insert_freshK] @ pushes)
   276                setloop split_tac [expand_if])));
   270                setloop split_tac [expand_if])));
   277 (*Oops*)
   271 (*Oops*)
   278 by (blast_tac (!claset addDs [unique_session_keys]) 5);
   272 by (blast_tac (!claset addDs [unique_session_keys]) 5);
   279 (*NS3, replay sub-case*) 
   273 (*NS3, replay sub-case*) 
   280 by (Blast_tac 4);
   274 by (Blast_tac 4);
   281 (*NS2*)
   275 (*NS2*)
   282 by (blast_tac (!claset addSEs sees_Spy_partsEs
   276 by (blast_tac (!claset addSEs spies_partsEs
   283                        addIs [parts_insertI, impOfSubs analz_subset_parts]) 2);
   277                        addIs [parts_insertI, impOfSubs analz_subset_parts]) 2);
   284 (*Fake*) 
   278 (*Fake*) 
   285 by (spy_analz_tac 1);
   279 by (spy_analz_tac 1);
   286 (*NS3, Server sub-case*) (**LEVEL 6 **)
   280 (*NS3, Server sub-case*) (**LEVEL 6 **)
   287 by (step_tac (!claset delrules [impCE]) 1);
   281 by (step_tac (!claset delrules [impCE]) 1);
   288 by (forward_tac [Says_imp_sees_Spy RS parts.Inj RS A_trusts_NS2] 1);
   282 by (forward_tac [Says_imp_spies RS parts.Inj RS A_trusts_NS2] 1);
   289 by (assume_tac 2);
   283 by (assume_tac 2);
   290 by (blast_tac (!claset addDs [Says_imp_sees_Spy RS analz.Inj RS
   284 by (blast_tac (!claset addDs [Says_imp_spies RS analz.Inj RS
   291 			      Crypt_Spy_analz_lost]) 1);
   285 			      Crypt_Spy_analz_bad]) 1);
   292 by (blast_tac (!claset addDs [unique_session_keys]) 1);
   286 by (blast_tac (!claset addDs [unique_session_keys]) 1);
   293 val lemma = result() RS mp RS mp RSN(2,rev_notE);
   287 val lemma = result() RS mp RS mp RSN(2,rev_notE);
   294 
   288 
   295 
   289 
   296 (*Final version: Server's message in the most abstract form*)
   290 (*Final version: Server's message in the most abstract form*)
   297 goal thy 
   291 goal thy 
   298  "!!evs. [| Says Server A                                               \
   292  "!!evs. [| Says Server A                                               \
   299 \            (Crypt K' {|NA, Agent B, Key K, X|}) : set evs;            \
   293 \            (Crypt K' {|NA, Agent B, Key K, X|}) : set evs;            \
   300 \           (ALL NB. Says A Spy {|NA, NB, Key K|} ~: set evs);          \
   294 \           (ALL NB. Says A Spy {|NA, NB, Key K|} ~: set evs);          \
   301 \           A ~: lost;  B ~: lost;  evs : ns_shared                \
   295 \           A ~: bad;  B ~: bad;  evs : ns_shared                \
   302 \        |] ==> Key K ~: analz (sees Spy evs)";
   296 \        |] ==> Key K ~: analz (spies evs)";
   303 by (forward_tac [Says_Server_message_form] 1 THEN assume_tac 1);
   297 by (forward_tac [Says_Server_message_form] 1 THEN assume_tac 1);
   304 by (blast_tac (!claset addSDs [lemma]) 1);
   298 by (blast_tac (!claset addSDs [lemma]) 1);
   305 qed "Spy_not_see_encrypted_key";
   299 qed "Spy_not_see_encrypted_key";
   306 
   300 
   307 
   301 
   310 A_trusts_NS2 RS Spy_not_see_encrypted_key;
   304 A_trusts_NS2 RS Spy_not_see_encrypted_key;
   311 
   305 
   312 
   306 
   313 (*If the encrypted message appears then it originated with the Server*)
   307 (*If the encrypted message appears then it originated with the Server*)
   314 goal thy
   308 goal thy
   315  "!!evs. [| Crypt (shrK B) {|Key K, Agent A|} : parts (sees Spy evs); \
   309  "!!evs. [| Crypt (shrK B) {|Key K, Agent A|} : parts (spies evs); \
   316 \           B ~: lost;  evs : ns_shared |]                        \
   310 \           B ~: bad;  evs : ns_shared |]                        \
   317 \         ==> EX NA. Says Server A                                     \
   311 \         ==> EX NA. Says Server A                                     \
   318 \              (Crypt (shrK A) {|NA, Agent B, Key K,                   \
   312 \              (Crypt (shrK A) {|NA, Agent B, Key K,                   \
   319 \                                Crypt (shrK B) {|Key K, Agent A|}|})  \
   313 \                                Crypt (shrK B) {|Key K, Agent A|}|})  \
   320 \             : set evs";
   314 \             : set evs";
   321 by (etac rev_mp 1);
   315 by (etac rev_mp 1);
   325 by (ALLGOALS Blast_tac);
   319 by (ALLGOALS Blast_tac);
   326 qed "B_trusts_NS3";
   320 qed "B_trusts_NS3";
   327 
   321 
   328 
   322 
   329 goal thy
   323 goal thy
   330  "!!evs. [| B ~: lost;  evs : ns_shared |]                        \
   324  "!!evs. [| B ~: bad;  evs : ns_shared |]                        \
   331 \        ==> Key K ~: analz (sees Spy evs) -->                    \
   325 \        ==> Key K ~: analz (spies evs) -->                    \
   332 \            Says Server A (Crypt (shrK A) {|NA, Agent B, Key K, X|})  \
   326 \            Says Server A (Crypt (shrK A) {|NA, Agent B, Key K, X|})  \
   333 \            : set evs -->                                             \
   327 \            : set evs -->                                             \
   334 \            Crypt K (Nonce NB) : parts (sees Spy evs) -->        \
   328 \            Crypt K (Nonce NB) : parts (spies evs) -->        \
   335 \            Says B A (Crypt K (Nonce NB)) : set evs";
   329 \            Says B A (Crypt K (Nonce NB)) : set evs";
   336 by (etac ns_shared.induct 1);
   330 by (etac ns_shared.induct 1);
   337 by (forward_tac [Says_S_message_form] 5 THEN assume_tac 5);     
   331 by (forward_tac [Says_S_message_form] 5 THEN assume_tac 5);     
   338 by (dtac NS3_msg_in_parts_sees_Spy 5);
   332 by (dtac NS3_msg_in_parts_spies 5);
   339 by (forward_tac [Oops_parts_sees_Spy] 8);
   333 by (forward_tac [Oops_parts_spies] 8);
   340 by (TRYALL (rtac impI));
   334 by (TRYALL (rtac impI));
   341 by (REPEAT_FIRST
   335 by (REPEAT_FIRST
   342     (dtac (sees_subset_sees_Says RS analz_mono RS contra_subsetD)));
   336     (dtac (spies_subset_spies_Says RS analz_mono RS contra_subsetD)));
   343 by (ALLGOALS (asm_simp_tac (!simpset addsimps [all_conj_distrib])));
   337 by (ALLGOALS (asm_simp_tac (!simpset addsimps [all_conj_distrib])));
   344 (**LEVEL 7**)
   338 (**LEVEL 7**)
   345 by (blast_tac (!claset addSDs [Crypt_Fake_parts_insert]
   339 by (blast_tac (!claset addSDs [Crypt_Fake_parts_insert]
   346                        addDs [impOfSubs analz_subset_parts]) 1);
   340                        addDs [impOfSubs analz_subset_parts]) 1);
   347 by (Blast_tac 2);
   341 by (Blast_tac 2);
   348 by (REPEAT_FIRST (rtac impI ORELSE' etac conjE ORELSE' hyp_subst_tac));
   342 by (REPEAT_FIRST (rtac impI ORELSE' etac conjE ORELSE' hyp_subst_tac));
   349 (*Subgoal 1: contradiction from the assumptions  
   343 (*Subgoal 1: contradiction from the assumptions  
   350   Key K ~: used evsa  and Crypt K (Nonce NB) : parts (sees Spy evsa) *)
   344   Key K ~: used evsa  and Crypt K (Nonce NB) : parts (spies evsa) *)
   351 by (dtac Crypt_imp_invKey_keysFor 1);
   345 by (dtac Crypt_imp_invKey_keysFor 1);
   352 (**LEVEL 11**)
   346 (**LEVEL 11**)
   353 by (Asm_full_simp_tac 1);
   347 by (Asm_full_simp_tac 1);
   354 by (rtac disjI1 1);
   348 by (rtac disjI1 1);
   355 by (thin_tac "?PP-->?QQ" 1);
   349 by (thin_tac "?PP-->?QQ" 1);
   356 by (case_tac "Ba : lost" 1);
   350 by (case_tac "Ba : bad" 1);
   357 by (blast_tac (!claset addDs [Says_imp_sees_Spy RS parts.Inj RS B_trusts_NS3, 
   351 by (blast_tac (!claset addDs [Says_imp_spies RS parts.Inj RS B_trusts_NS3, 
   358 			      unique_session_keys]) 2);
   352 			      unique_session_keys]) 2);
   359 by (blast_tac (!claset addDs [Says_imp_sees_Spy RS analz.Inj RS
   353 by (blast_tac (!claset addDs [Says_imp_spies RS analz.Inj RS
   360 			      Crypt_Spy_analz_lost]) 1);
   354 			      Crypt_Spy_analz_bad]) 1);
   361 val lemma = result();
   355 val lemma = result();
   362 
   356 
   363 goal thy
   357 goal thy
   364  "!!evs. [| Crypt K (Nonce NB) : parts (sees Spy evs);           \
   358  "!!evs. [| Crypt K (Nonce NB) : parts (spies evs);           \
   365 \           Says Server A (Crypt (shrK A) {|NA, Agent B, Key K, X|})  \
   359 \           Says Server A (Crypt (shrK A) {|NA, Agent B, Key K, X|})  \
   366 \           : set evs;                                                \
   360 \           : set evs;                                                \
   367 \           ALL NB. Says A Spy {|NA, NB, Key K|} ~: set evs;          \
   361 \           ALL NB. Says A Spy {|NA, NB, Key K|} ~: set evs;          \
   368 \           A ~: lost;  B ~: lost;  evs : ns_shared |]           \
   362 \           A ~: bad;  B ~: bad;  evs : ns_shared |]           \
   369 \        ==> Says B A (Crypt K (Nonce NB)) : set evs";
   363 \        ==> Says B A (Crypt K (Nonce NB)) : set evs";
   370 by (blast_tac (!claset addSIs [lemma RS mp RS mp RS mp]
   364 by (blast_tac (!claset addSIs [lemma RS mp RS mp RS mp]
   371                        addSEs [Spy_not_see_encrypted_key RSN (2,rev_notE)]) 1);
   365                        addSEs [Spy_not_see_encrypted_key RSN (2,rev_notE)]) 1);
   372 qed "A_trusts_NS4";
   366 qed "A_trusts_NS4";