src/HOL/Auth/NS_Shared.thy
author paulson
Fri Feb 16 13:25:08 2001 +0100 (2001-02-16)
changeset 11150 67387142225e
parent 11117 55358999077d
child 11188 5d539f1682c3
permissions -rw-r--r--
Streamlining for the bug fix in Blast.
MPair_parts now built in using AddSEs, throughout.
paulson@1934
     1
(*  Title:      HOL/Auth/NS_Shared
paulson@1934
     2
    ID:         $Id$
paulson@1934
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@1934
     4
    Copyright   1996  University of Cambridge
paulson@1934
     5
paulson@1934
     6
Inductive relation "ns_shared" for Needham-Schroeder Shared-Key protocol.
paulson@1934
     7
paulson@1934
     8
From page 247 of
paulson@1934
     9
  Burrows, Abadi and Needham.  A Logic of Authentication.
paulson@1934
    10
  Proc. Royal Soc. 426 (1989)
paulson@1934
    11
*)
paulson@1934
    12
paulson@11104
    13
theory NS_Shared = Shared:
paulson@1934
    14
paulson@11104
    15
consts  ns_shared   :: "event list set"
paulson@3519
    16
inductive "ns_shared"
paulson@11104
    17
 intros
paulson@11104
    18
	(*Initial trace is empty*)
paulson@11104
    19
  Nil:  "[] \<in> ns_shared"
paulson@11104
    20
	(*The spy MAY say anything he CAN say.  We do not expect him to
paulson@11104
    21
	  invent new nonces here, but he can also use NS1.  Common to
paulson@11104
    22
	  all similar protocols.*)
paulson@11104
    23
  Fake: "\<lbrakk>evs \<in> ns_shared;  X \<in> synth (analz (spies evs))\<rbrakk>
paulson@11104
    24
	 \<Longrightarrow> Says Spy B X # evs \<in> ns_shared"
paulson@11104
    25
paulson@11104
    26
	(*Alice initiates a protocol run, requesting to talk to any B*)
paulson@11104
    27
  NS1:  "\<lbrakk>evs1 \<in> ns_shared;  Nonce NA \<notin> used evs1\<rbrakk>
paulson@11104
    28
	 \<Longrightarrow> Says A Server \<lbrace>Agent A, Agent B, Nonce NA\<rbrace> # evs1  \<in>  ns_shared"
paulson@11104
    29
paulson@11104
    30
	(*Server's response to Alice's message.
paulson@11104
    31
	  !! It may respond more than once to A's request !!
paulson@11104
    32
	  Server doesn't know who the true sender is, hence the A' in
paulson@11104
    33
	      the sender field.*)
paulson@11104
    34
  NS2:  "\<lbrakk>evs2 \<in> ns_shared;  Key KAB \<notin> used evs2;
paulson@11104
    35
	  Says A' Server \<lbrace>Agent A, Agent B, Nonce NA\<rbrace> \<in> set evs2\<rbrakk>
paulson@11104
    36
	 \<Longrightarrow> Says Server A 
paulson@11104
    37
	       (Crypt (shrK A)
paulson@11104
    38
		  \<lbrace>Nonce NA, Agent B, Key KAB,
paulson@11104
    39
		    (Crypt (shrK B) \<lbrace>Key KAB, Agent A\<rbrace>)\<rbrace>) 
paulson@11104
    40
	       # evs2 \<in> ns_shared"
paulson@11104
    41
paulson@11104
    42
	 (*We can't assume S=Server.  Agent A "remembers" her nonce.
paulson@11104
    43
	   Need A \<noteq> Server because we allow messages to self.*)
paulson@11104
    44
  NS3:  "\<lbrakk>evs3 \<in> ns_shared;  A \<noteq> Server;
paulson@11104
    45
	  Says S A (Crypt (shrK A) \<lbrace>Nonce NA, Agent B, Key K, X\<rbrace>) \<in> set evs3;
paulson@11104
    46
	  Says A Server \<lbrace>Agent A, Agent B, Nonce NA\<rbrace> \<in> set evs3\<rbrakk>
paulson@11104
    47
	 \<Longrightarrow> Says A B X # evs3 \<in> ns_shared"
paulson@11104
    48
paulson@11104
    49
	(*Bob's nonce exchange.  He does not know who the message came
paulson@11104
    50
	  from, but responds to A because she is mentioned inside.*)
paulson@11104
    51
  NS4:  "\<lbrakk>evs4 \<in> ns_shared;  Nonce NB \<notin> used evs4;
paulson@11104
    52
	  Says A' B (Crypt (shrK B) \<lbrace>Key K, Agent A\<rbrace>) \<in> set evs4\<rbrakk>
paulson@11104
    53
	 \<Longrightarrow> Says B A (Crypt K (Nonce NB)) # evs4 \<in> ns_shared"
paulson@1934
    54
paulson@11104
    55
	(*Alice responds with Nonce NB if she has seen the key before.
paulson@11104
    56
	  Maybe should somehow check Nonce NA again.
paulson@11104
    57
	  We do NOT send NB-1 or similar as the Spy cannot spoof such things.
paulson@11104
    58
	  Letting the Spy add or subtract 1 lets him send \<forall>nonces.
paulson@11104
    59
	  Instead we distinguish the messages by sending the nonce twice.*)
paulson@11104
    60
  NS5:  "\<lbrakk>evs5 \<in> ns_shared;  
paulson@11104
    61
	  Says B' A (Crypt K (Nonce NB)) \<in> set evs5;
paulson@11104
    62
	  Says S  A (Crypt (shrK A) \<lbrace>Nonce NA, Agent B, Key K, X\<rbrace>)
paulson@11104
    63
	    \<in> set evs5\<rbrakk>
paulson@11104
    64
	 \<Longrightarrow> Says A B (Crypt K \<lbrace>Nonce NB, Nonce NB\<rbrace>) # evs5 \<in> ns_shared"
paulson@11104
    65
paulson@11104
    66
	(*This message models possible leaks of session keys.
paulson@11104
    67
	  The two Nonces identify the protocol run: the rule insists upon
paulson@11104
    68
	  the true senders in order to make them accurate.*)
paulson@11104
    69
  Oops: "\<lbrakk>evso \<in> ns_shared;  Says B A (Crypt K (Nonce NB)) \<in> set evso;
paulson@11104
    70
	  Says Server A (Crypt (shrK A) \<lbrace>Nonce NA, Agent B, Key K, X\<rbrace>)
paulson@11104
    71
	      \<in> set evso\<rbrakk>
paulson@11104
    72
	 \<Longrightarrow> Notes Spy \<lbrace>Nonce NA, Nonce NB, Key K\<rbrace> # evso \<in> ns_shared"
paulson@11104
    73
paulson@11150
    74
paulson@11150
    75
declare Says_imp_knows_Spy [THEN parts.Inj, dest]
paulson@11150
    76
declare parts.Body  [dest]
paulson@11150
    77
declare MPair_parts [elim!]    (*can speed up some proofs*)
paulson@11150
    78
paulson@11104
    79
declare analz_subset_parts [THEN subsetD, dest]
paulson@11150
    80
declare Fake_parts_insert  [THEN subsetD, dest]
paulson@11104
    81
declare image_eq_UN [simp]  (*accelerates proofs involving nested images*)
paulson@11104
    82
paulson@11104
    83
paulson@11104
    84
(*A "possibility property": there are traces that reach the end*)
paulson@11104
    85
lemma "A \<noteq> Server \<Longrightarrow> \<exists>N K. \<exists>evs \<in> ns_shared.
paulson@11104
    86
                              Says A B (Crypt K \<lbrace>Nonce N, Nonce N\<rbrace>) \<in> set evs"
paulson@11104
    87
apply (intro exI bexI)
paulson@11104
    88
apply (rule_tac [2] ns_shared.Nil
paulson@11104
    89
       [THEN ns_shared.NS1, THEN ns_shared.NS2, THEN ns_shared.NS3,
paulson@11104
    90
	THEN ns_shared.NS4, THEN ns_shared.NS5])
paulson@11104
    91
apply possibility
paulson@11104
    92
done
paulson@11104
    93
paulson@11104
    94
(*This version is similar, while instantiating ?K and ?N to epsilon-terms
paulson@11104
    95
lemma "A \<noteq> Server \<Longrightarrow> \<exists>evs \<in> ns_shared.
paulson@11104
    96
                Says A B (Crypt ?K \<lbrace>Nonce ?N, Nonce ?N\<rbrace>) \<in> set evs"
paulson@11104
    97
*)
paulson@11104
    98
paulson@11104
    99
paulson@11104
   100
(**** Inductive proofs about ns_shared ****)
paulson@11104
   101
paulson@11104
   102
(*Forwarding lemmas, to aid simplification*)
paulson@1934
   103
paulson@11104
   104
(*For reasoning about the encrypted portion of message NS3*)
paulson@11104
   105
lemma NS3_msg_in_parts_spies:
paulson@11104
   106
     "Says S A (Crypt KA \<lbrace>N, B, K, X\<rbrace>) \<in> set evs \<Longrightarrow> X \<in> parts (spies evs)"
paulson@11104
   107
by blast
paulson@11104
   108
                              
paulson@11104
   109
(*For reasoning about the Oops message*)
paulson@11104
   110
lemma Oops_parts_spies:
paulson@11104
   111
     "Says Server A (Crypt (shrK A) \<lbrace>NA, B, K, X\<rbrace>) \<in> set evs
paulson@11104
   112
            \<Longrightarrow> K \<in> parts (spies evs)"
paulson@11104
   113
by blast
paulson@11104
   114
paulson@11104
   115
(** Theorems of the form X \<notin> parts (spies evs) imply that NOBODY
paulson@11104
   116
    sends messages containing X! **)
paulson@11104
   117
paulson@11104
   118
(*Spy never sees another agent's shared key! (unless it's bad at start)*)
paulson@11104
   119
lemma Spy_see_shrK [simp]:
paulson@11104
   120
     "evs \<in> ns_shared \<Longrightarrow> (Key (shrK A) \<in> parts (spies evs)) = (A \<in> bad)"
paulson@11104
   121
apply (erule ns_shared.induct, force, frule_tac [4] NS3_msg_in_parts_spies)
paulson@11104
   122
apply simp_all
paulson@11104
   123
apply blast+;
paulson@11104
   124
done
paulson@11104
   125
paulson@11104
   126
paulson@11104
   127
lemma Spy_analz_shrK [simp]:
paulson@11104
   128
     "evs \<in> ns_shared \<Longrightarrow> (Key (shrK A) \<in> analz (spies evs)) = (A \<in> bad)"
paulson@11104
   129
by auto
paulson@11104
   130
paulson@11104
   131
paulson@11104
   132
(*Nobody can have used non-existent keys!*)
paulson@11104
   133
lemma new_keys_not_used [rule_format, simp]:
paulson@11104
   134
    "evs \<in> ns_shared \<Longrightarrow> Key K \<notin> used evs \<longrightarrow> K \<notin> keysFor (parts (spies evs))"
paulson@11104
   135
apply (erule ns_shared.induct, force, frule_tac [4] NS3_msg_in_parts_spies)
paulson@11104
   136
apply simp_all
paulson@11104
   137
(*Fake, NS2, NS4, NS5*)
paulson@11104
   138
apply (blast dest!: keysFor_parts_insert)+
paulson@11104
   139
done
paulson@11104
   140
paulson@11104
   141
paulson@11104
   142
(** Lemmas concerning the form of items passed in messages **)
paulson@11104
   143
paulson@11104
   144
(*Describes the form of K, X and K' when the Server sends this message.*)
paulson@11104
   145
lemma Says_Server_message_form:
paulson@11104
   146
     "\<lbrakk>Says Server A (Crypt K' \<lbrace>N, Agent B, Key K, X\<rbrace>) \<in> set evs;
paulson@11104
   147
       evs \<in> ns_shared\<rbrakk>
paulson@11104
   148
      \<Longrightarrow> K \<notin> range shrK \<and>
paulson@11104
   149
          X = (Crypt (shrK B) \<lbrace>Key K, Agent A\<rbrace>) \<and>
paulson@11104
   150
          K' = shrK A"
paulson@11104
   151
by (erule rev_mp, erule ns_shared.induct, auto)
paulson@11104
   152
paulson@1934
   153
paulson@11104
   154
(*If the encrypted message appears then it originated with the Server*)
paulson@11104
   155
lemma A_trusts_NS2:
paulson@11104
   156
     "\<lbrakk>Crypt (shrK A) \<lbrace>NA, Agent B, Key K, X\<rbrace> \<in> parts (spies evs);
paulson@11104
   157
       A \<notin> bad;  evs \<in> ns_shared\<rbrakk>
paulson@11104
   158
      \<Longrightarrow> Says Server A (Crypt (shrK A) \<lbrace>NA, Agent B, Key K, X\<rbrace>) \<in> set evs"
paulson@11104
   159
apply (erule rev_mp)
paulson@11104
   160
apply (erule ns_shared.induct, force, drule_tac [4] NS3_msg_in_parts_spies)
paulson@11104
   161
apply auto
paulson@11104
   162
done
paulson@11104
   163
paulson@11104
   164
lemma cert_A_form:
paulson@11104
   165
     "\<lbrakk>Crypt (shrK A) \<lbrace>NA, Agent B, Key K, X\<rbrace> \<in> parts (spies evs);
paulson@11104
   166
       A \<notin> bad;  evs \<in> ns_shared\<rbrakk>
paulson@11104
   167
      \<Longrightarrow> K \<notin> range shrK \<and>  X = (Crypt (shrK B) \<lbrace>Key K, Agent A\<rbrace>)"
paulson@11104
   168
by (blast dest!: A_trusts_NS2 Says_Server_message_form)
paulson@11104
   169
paulson@11104
   170
(*EITHER describes the form of X when the following message is sent,
paulson@11104
   171
  OR     reduces it to the Fake case.
paulson@11104
   172
  Use Says_Server_message_form if applicable.*)
paulson@11104
   173
lemma Says_S_message_form:
paulson@11104
   174
     "\<lbrakk>Says S A (Crypt (shrK A) \<lbrace>Nonce NA, Agent B, Key K, X\<rbrace>) \<in> set evs;
paulson@11104
   175
       evs \<in> ns_shared\<rbrakk>
paulson@11104
   176
      \<Longrightarrow> (K \<notin> range shrK \<and> X = (Crypt (shrK B) \<lbrace>Key K, Agent A\<rbrace>))
paulson@11104
   177
          \<or> X \<in> analz (spies evs)"
paulson@11150
   178
by (blast dest: Says_imp_knows_Spy cert_A_form analz.Inj)
paulson@11150
   179
paulson@11104
   180
paulson@11104
   181
(*Alternative version also provable
paulson@11104
   182
lemma Says_S_message_form2:
paulson@11104
   183
  "\<lbrakk>Says S A (Crypt (shrK A) \<lbrace>Nonce NA, Agent B, Key K, X\<rbrace>) \<in> set evs;
paulson@11104
   184
    evs \<in> ns_shared\<rbrakk>
paulson@11104
   185
   \<Longrightarrow> Says Server A (Crypt (shrK A) \<lbrace>Nonce NA, Agent B, Key K, X\<rbrace>) \<in> set evs
paulson@11104
   186
       \<or> X \<in> analz (spies evs)"
paulson@11104
   187
apply (case_tac "A \<in> bad")
paulson@11104
   188
apply (force dest!: Says_imp_knows_Spy [THEN analz.Inj]);
paulson@11104
   189
by (blast dest!: A_trusts_NS2 Says_Server_message_form)
paulson@11104
   190
*)
paulson@11104
   191
paulson@11104
   192
paulson@11104
   193
(****
paulson@11104
   194
 SESSION KEY COMPROMISE THEOREM.  To prove theorems of the form
paulson@11104
   195
paulson@11104
   196
  Key K \<in> analz (insert (Key KAB) (spies evs)) \<Longrightarrow>
paulson@11104
   197
  Key K \<in> analz (spies evs)
paulson@11104
   198
paulson@11104
   199
 A more general formula must be proved inductively.
paulson@11104
   200
****)
paulson@1934
   201
paulson@11104
   202
(*NOT useful in this form, but it says that session keys are not used
paulson@11104
   203
  to encrypt messages containing other keys, in the actual protocol.
paulson@11104
   204
  We require that agents should behave like this subsequently also.*)
paulson@11104
   205
lemma  "\<lbrakk>evs \<in> ns_shared;  Kab \<notin> range shrK\<rbrakk> \<Longrightarrow>
paulson@11104
   206
         (Crypt KAB X) \<in> parts (spies evs) \<and>
paulson@11104
   207
         Key K \<in> parts {X} \<longrightarrow> Key K \<in> parts (spies evs)"
paulson@11104
   208
apply (erule ns_shared.induct, force, frule_tac [4] NS3_msg_in_parts_spies)
paulson@11104
   209
apply simp_all
paulson@11104
   210
(*Fake*)
paulson@11104
   211
apply (blast dest: parts_insert_subset_Un)
paulson@11104
   212
(*Base, NS4 and NS5*)
paulson@11104
   213
apply auto
paulson@11104
   214
done
paulson@11104
   215
paulson@11104
   216
paulson@11104
   217
(** Session keys are not used to encrypt other session keys **)
paulson@11104
   218
paulson@11104
   219
(*The equality makes the induction hypothesis easier to apply*)
paulson@11104
   220
paulson@11104
   221
lemma analz_image_freshK [rule_format]:
paulson@11104
   222
 "evs \<in> ns_shared \<Longrightarrow>
paulson@11104
   223
   \<forall>K KK. KK \<subseteq> - (range shrK) \<longrightarrow>
paulson@11104
   224
             (Key K \<in> analz (Key`KK \<union> (spies evs))) =
paulson@11104
   225
             (K \<in> KK \<or> Key K \<in> analz (spies evs))"
paulson@11104
   226
apply (erule ns_shared.induct, force)
paulson@11104
   227
apply (frule_tac [7] Says_Server_message_form)
paulson@11104
   228
apply (erule_tac [4] Says_S_message_form [THEN disjE])
paulson@11117
   229
apply analz_freshK
paulson@11117
   230
apply spy_analz
paulson@11104
   231
done
paulson@11104
   232
paulson@11104
   233
paulson@11104
   234
lemma analz_insert_freshK:
paulson@11104
   235
     "\<lbrakk>evs \<in> ns_shared;  KAB \<notin> range shrK\<rbrakk> \<Longrightarrow>
paulson@11104
   236
       Key K \<in> analz (insert (Key KAB) (spies evs)) =
paulson@11104
   237
       (K = KAB \<or> Key K \<in> analz (spies evs))"
paulson@11104
   238
by (simp only: analz_image_freshK analz_image_freshK_simps)
paulson@11104
   239
paulson@11104
   240
paulson@11104
   241
(** The session key K uniquely identifies the message **)
paulson@1934
   242
paulson@11104
   243
(*In messages of this form, the session key uniquely identifies the rest*)
paulson@11104
   244
lemma unique_session_keys:
paulson@11104
   245
     "\<lbrakk>Says Server A (Crypt (shrK A) \<lbrace>NA, Agent B, Key K, X\<rbrace>) \<in> set evs;
paulson@11104
   246
       Says Server A' (Crypt (shrK A') \<lbrace>NA', Agent B', Key K, X'\<rbrace>) \<in> set evs;
paulson@11104
   247
       evs \<in> ns_shared\<rbrakk> \<Longrightarrow> A=A' \<and> NA=NA' \<and> B=B' \<and> X = X'"
paulson@11104
   248
apply (erule rev_mp, erule rev_mp, erule ns_shared.induct)
paulson@11104
   249
apply simp_all
paulson@11104
   250
apply blast+
paulson@11104
   251
done
paulson@11104
   252
paulson@11104
   253
paulson@11104
   254
(** Crucial secrecy property: Spy does not see the keys sent in msg NS2 **)
paulson@11104
   255
paulson@11150
   256
(*Beware of [rule_format] and the universal quantifier!*)
paulson@11150
   257
lemma secrecy_lemma:
paulson@11104
   258
     "\<lbrakk>Says Server A (Crypt (shrK A) \<lbrace>NA, Agent B, Key K,
paulson@11104
   259
                                      Crypt (shrK B) \<lbrace>Key K, Agent A\<rbrace>\<rbrace>)
paulson@11104
   260
              \<in> set evs;
paulson@11104
   261
         A \<notin> bad;  B \<notin> bad;  evs \<in> ns_shared\<rbrakk>
paulson@11104
   262
      \<Longrightarrow> (\<forall>NB. Notes Spy \<lbrace>NA, NB, Key K\<rbrace> \<notin> set evs) \<longrightarrow>
paulson@11104
   263
         Key K \<notin> analz (spies evs)"
paulson@11104
   264
apply (erule rev_mp)
paulson@11104
   265
apply (erule ns_shared.induct, force)
paulson@11104
   266
apply (frule_tac [7] Says_Server_message_form)
paulson@11104
   267
apply (frule_tac [4] Says_S_message_form)
paulson@11104
   268
apply (erule_tac [5] disjE)
paulson@11104
   269
apply (simp_all add: analz_insert_eq analz_insert_freshK pushes split_ifs)
paulson@11104
   270
apply spy_analz  (*Fake*) 
paulson@11104
   271
apply blast      (*NS2*)
paulson@11104
   272
(*NS3, Server sub-case*) (**LEVEL 6 **)
paulson@11104
   273
apply clarify
paulson@11104
   274
apply (frule Says_imp_knows_Spy [THEN parts.Inj, THEN A_trusts_NS2])
paulson@11150
   275
apply (blast dest: Says_imp_knows_Spy analz.Inj Crypt_Spy_analz_bad)
paulson@11104
   276
apply assumption
paulson@11104
   277
apply (blast dest: unique_session_keys)+ (*also proves Oops*)
paulson@11104
   278
done
paulson@11104
   279
paulson@11104
   280
paulson@11104
   281
(*Final version: Server's message in the most abstract form*)
paulson@11104
   282
lemma Spy_not_see_encrypted_key:
paulson@11104
   283
     "\<lbrakk>Says Server A (Crypt K' \<lbrace>NA, Agent B, Key K, X\<rbrace>) \<in> set evs;
paulson@11104
   284
       \<forall>NB. Notes Spy \<lbrace>NA, NB, Key K\<rbrace> \<notin> set evs;
paulson@11104
   285
       A \<notin> bad;  B \<notin> bad;  evs \<in> ns_shared\<rbrakk>
paulson@11104
   286
      \<Longrightarrow> Key K \<notin> analz (spies evs)"
paulson@11150
   287
by (blast dest: Says_Server_message_form secrecy_lemma)
paulson@11104
   288
paulson@11104
   289
paulson@11104
   290
(**** Guarantees available at various stages of protocol ***)
paulson@1934
   291
paulson@11104
   292
(*If the encrypted message appears then it originated with the Server*)
paulson@11104
   293
lemma B_trusts_NS3:
paulson@11104
   294
     "\<lbrakk>Crypt (shrK B) \<lbrace>Key K, Agent A\<rbrace> \<in> parts (spies evs);
paulson@11150
   295
       B \<notin> bad;  evs \<in> ns_shared\<rbrakk>
paulson@11150
   296
      \<Longrightarrow> \<exists>NA. Says Server A
paulson@11104
   297
               (Crypt (shrK A) \<lbrace>NA, Agent B, Key K,
paulson@11104
   298
                                 Crypt (shrK B) \<lbrace>Key K, Agent A\<rbrace>\<rbrace>)
paulson@11104
   299
              \<in> set evs"
paulson@11104
   300
apply (erule rev_mp)
paulson@11104
   301
apply (erule ns_shared.induct, force, drule_tac [4] NS3_msg_in_parts_spies)
paulson@11104
   302
apply auto
paulson@11104
   303
done
paulson@11104
   304
paulson@11104
   305
paulson@11104
   306
lemma A_trusts_NS4_lemma [rule_format]:
paulson@11104
   307
   "evs \<in> ns_shared \<Longrightarrow>
paulson@11104
   308
      Key K \<notin> analz (spies evs) \<longrightarrow>
paulson@11104
   309
      Says Server A (Crypt (shrK A) \<lbrace>NA, Agent B, Key K, X\<rbrace>) \<in> set evs \<longrightarrow>
paulson@11104
   310
      Crypt K (Nonce NB) \<in> parts (spies evs) \<longrightarrow>
paulson@11104
   311
      Says B A (Crypt K (Nonce NB)) \<in> set evs"
paulson@11104
   312
apply (erule ns_shared.induct, force, drule_tac [4] NS3_msg_in_parts_spies)
paulson@11104
   313
apply analz_mono_contra
paulson@11104
   314
apply simp_all
paulson@11104
   315
apply blast     (*Fake*)
paulson@11104
   316
(*NS2: contradiction from the assumptions  
paulson@11104
   317
  Key K \<notin> used evs2  and Crypt K (Nonce NB) \<in> parts (spies evs2) *)
paulson@11104
   318
apply (force dest!: Crypt_imp_keysFor) 
paulson@11104
   319
apply blast     (*NS3*)
paulson@11104
   320
(*NS4*)
paulson@11150
   321
apply (blast dest!: B_trusts_NS3
paulson@11150
   322
	     dest: Says_imp_knows_Spy [THEN analz.Inj] 
paulson@11150
   323
                   Crypt_Spy_analz_bad unique_session_keys)
paulson@11104
   324
done
paulson@11104
   325
paulson@11104
   326
(*This version no longer assumes that K is secure*)
paulson@11104
   327
lemma A_trusts_NS4:
paulson@11104
   328
     "\<lbrakk>Crypt K (Nonce NB) \<in> parts (spies evs);
paulson@11104
   329
       Crypt (shrK A) \<lbrace>NA, Agent B, Key K, X\<rbrace> \<in> parts (spies evs);
paulson@11104
   330
       \<forall>NB. Notes Spy \<lbrace>NA, NB, Key K\<rbrace> \<notin> set evs;
paulson@11104
   331
       A \<notin> bad;  B \<notin> bad;  evs \<in> ns_shared\<rbrakk>
paulson@11104
   332
      \<Longrightarrow> Says B A (Crypt K (Nonce NB)) \<in> set evs"
paulson@11104
   333
by (blast intro: A_trusts_NS4_lemma 
paulson@11104
   334
          dest: A_trusts_NS2 Spy_not_see_encrypted_key)
paulson@11104
   335
paulson@11104
   336
(*If the session key has been used in NS4 then somebody has forwarded
paulson@11104
   337
  component X in some instance of NS4.  Perhaps an interesting property, 
paulson@11104
   338
  but not needed (after all) for the proofs below.*)
paulson@11104
   339
theorem NS4_implies_NS3 [rule_format]:
paulson@11104
   340
  "evs \<in> ns_shared \<Longrightarrow> 
paulson@11104
   341
     Key K \<notin> analz (spies evs) \<longrightarrow>
paulson@11104
   342
     Says Server A (Crypt (shrK A) \<lbrace>NA, Agent B, Key K, X\<rbrace>) \<in> set evs \<longrightarrow>
paulson@11104
   343
     Crypt K (Nonce NB) \<in> parts (spies evs) \<longrightarrow>
paulson@11104
   344
     (\<exists>A'. Says A' B X \<in> set evs)"
paulson@11104
   345
apply (erule ns_shared.induct, force, drule_tac [4] NS3_msg_in_parts_spies)
paulson@11104
   346
apply analz_mono_contra
paulson@11104
   347
apply (simp_all add: ex_disj_distrib)
paulson@11104
   348
apply blast  (*Fake*)
paulson@11104
   349
apply (blast dest!: new_keys_not_used Crypt_imp_keysFor)  (*NS2*)
paulson@11104
   350
apply blast  (*NS3*)
paulson@11104
   351
(*NS4*)
paulson@11150
   352
apply (blast dest!: B_trusts_NS3
paulson@11150
   353
	     dest: Says_imp_knows_Spy [THEN analz.Inj] 
paulson@11150
   354
                   unique_session_keys Crypt_Spy_analz_bad)
paulson@11104
   355
done
paulson@11104
   356
paulson@11104
   357
paulson@11104
   358
lemma B_trusts_NS5_lemma [rule_format]:
paulson@11104
   359
  "\<lbrakk>B \<notin> bad;  evs \<in> ns_shared\<rbrakk> \<Longrightarrow>
paulson@11104
   360
     Key K \<notin> analz (spies evs) \<longrightarrow>
paulson@11104
   361
     Says Server A
paulson@11104
   362
	  (Crypt (shrK A) \<lbrace>NA, Agent B, Key K,
paulson@11104
   363
			    Crypt (shrK B) \<lbrace>Key K, Agent A\<rbrace>\<rbrace>) \<in> set evs \<longrightarrow>
paulson@11104
   364
     Crypt K \<lbrace>Nonce NB, Nonce NB\<rbrace> \<in> parts (spies evs) \<longrightarrow>
paulson@11104
   365
     Says A B (Crypt K \<lbrace>Nonce NB, Nonce NB\<rbrace>) \<in> set evs"
paulson@11104
   366
apply (erule ns_shared.induct, force, drule_tac [4] NS3_msg_in_parts_spies)
paulson@11104
   367
apply analz_mono_contra
paulson@11104
   368
apply simp_all 
paulson@11104
   369
apply blast  (*Fake*)
paulson@11104
   370
apply (blast dest!: new_keys_not_used Crypt_imp_keysFor)  (*NS2*)
paulson@11104
   371
apply (blast dest!: cert_A_form) (*NS3*)
paulson@11104
   372
(*NS5*)
paulson@11150
   373
apply (blast dest!: A_trusts_NS2
paulson@11150
   374
	     dest: Says_imp_knows_Spy [THEN analz.Inj] 
paulson@11150
   375
                   unique_session_keys Crypt_Spy_analz_bad)
paulson@11104
   376
done
paulson@11104
   377
paulson@11104
   378
paulson@11104
   379
(*Very strong Oops condition reveals protocol's weakness*)
paulson@11104
   380
lemma B_trusts_NS5:
paulson@11104
   381
     "\<lbrakk>Crypt K \<lbrace>Nonce NB, Nonce NB\<rbrace> \<in> parts (spies evs);
paulson@11104
   382
       Crypt (shrK B) \<lbrace>Key K, Agent A\<rbrace> \<in> parts (spies evs);
paulson@11104
   383
       \<forall>NA NB. Notes Spy \<lbrace>NA, NB, Key K\<rbrace> \<notin> set evs;
paulson@11104
   384
       A \<notin> bad;  B \<notin> bad;  evs \<in> ns_shared\<rbrakk>
paulson@11104
   385
      \<Longrightarrow> Says A B (Crypt K \<lbrace>Nonce NB, Nonce NB\<rbrace>) \<in> set evs"
paulson@11150
   386
by (blast intro: B_trusts_NS5_lemma 
paulson@11150
   387
          dest: B_trusts_NS3 Spy_not_see_encrypted_key)
paulson@1934
   388
paulson@1934
   389
end