src/HOL/Auth/Yahalom2.thy
changeset 11251 a6816d47f41d
parent 11185 1b737b4c2108
child 11655 923e4d0d36d5
     1.1 --- a/src/HOL/Auth/Yahalom2.thy	Wed Apr 11 11:53:54 2001 +0200
     1.2 +++ b/src/HOL/Auth/Yahalom2.thy	Thu Apr 12 12:45:05 2001 +0200
     1.3 @@ -13,64 +13,389 @@
     1.4    Proc. Royal Soc. 426 (1989)
     1.5  *)
     1.6  
     1.7 -Yahalom2 = Shared + 
     1.8 +theory Yahalom2 = Shared:
     1.9  
    1.10 -consts  yahalom   :: event list set
    1.11 +consts  yahalom   :: "event list set"
    1.12  inductive "yahalom"
    1.13 -  intrs 
    1.14 +  intros
    1.15           (*Initial trace is empty*)
    1.16 -    Nil  "[] \\<in> yahalom"
    1.17 +   Nil:  "[] \<in> yahalom"
    1.18  
    1.19           (*The spy MAY say anything he CAN say.  We do not expect him to
    1.20             invent new nonces here, but he can also use NS1.  Common to
    1.21             all similar protocols.*)
    1.22 -    Fake "[| evsf \\<in> yahalom;  X \\<in> synth (analz (knows Spy evsf)) |]
    1.23 -          ==> Says Spy B X  # evsf \\<in> yahalom"
    1.24 +   Fake: "[| evsf \<in> yahalom;  X \<in> synth (analz (knows Spy evsf)) |]
    1.25 +          ==> Says Spy B X  # evsf \<in> yahalom"
    1.26  
    1.27           (*A message that has been sent can be received by the
    1.28             intended recipient.*)
    1.29 -    Reception "[| evsr \\<in> yahalom;  Says A B X \\<in> set evsr |]
    1.30 -               ==> Gets B X # evsr \\<in> yahalom"
    1.31 +   Reception: "[| evsr \<in> yahalom;  Says A B X \<in> set evsr |]
    1.32 +               ==> Gets B X # evsr \<in> yahalom"
    1.33  
    1.34           (*Alice initiates a protocol run*)
    1.35 -    YM1  "[| evs1 \\<in> yahalom;  Nonce NA \\<notin> used evs1 |]
    1.36 -          ==> Says A B {|Agent A, Nonce NA|} # evs1 \\<in> yahalom"
    1.37 +   YM1:  "[| evs1 \<in> yahalom;  Nonce NA \<notin> used evs1 |]
    1.38 +          ==> Says A B {|Agent A, Nonce NA|} # evs1 \<in> yahalom"
    1.39  
    1.40           (*Bob's response to Alice's message.*)
    1.41 -    YM2  "[| evs2 \\<in> yahalom;  Nonce NB \\<notin> used evs2;
    1.42 -             Gets B {|Agent A, Nonce NA|} \\<in> set evs2 |]
    1.43 -          ==> Says B Server 
    1.44 +   YM2:  "[| evs2 \<in> yahalom;  Nonce NB \<notin> used evs2;
    1.45 +             Gets B {|Agent A, Nonce NA|} \<in> set evs2 |]
    1.46 +          ==> Says B Server
    1.47                    {|Agent B, Nonce NB, Crypt (shrK B) {|Agent A, Nonce NA|}|}
    1.48 -                # evs2 \\<in> yahalom"
    1.49 +                # evs2 \<in> yahalom"
    1.50  
    1.51           (*The Server receives Bob's message.  He responds by sending a
    1.52             new session key to Alice, with a certificate for forwarding to Bob.
    1.53             Both agents are quoted in the 2nd certificate to prevent attacks!*)
    1.54 -    YM3  "[| evs3 \\<in> yahalom;  Key KAB \\<notin> used evs3;
    1.55 +   YM3:  "[| evs3 \<in> yahalom;  Key KAB \<notin> used evs3;
    1.56               Gets Server {|Agent B, Nonce NB,
    1.57  			   Crypt (shrK B) {|Agent A, Nonce NA|}|}
    1.58 -               \\<in> set evs3 |]
    1.59 +               \<in> set evs3 |]
    1.60            ==> Says Server A
    1.61 -               {|Nonce NB, 
    1.62 +               {|Nonce NB,
    1.63                   Crypt (shrK A) {|Agent B, Key KAB, Nonce NA|},
    1.64                   Crypt (shrK B) {|Agent A, Agent B, Key KAB, Nonce NB|}|}
    1.65 -                 # evs3 \\<in> yahalom"
    1.66 +                 # evs3 \<in> yahalom"
    1.67  
    1.68           (*Alice receives the Server's (?) message, checks her Nonce, and
    1.69             uses the new session key to send Bob his Nonce.*)
    1.70 -    YM4  "[| evs4 \\<in> yahalom;  
    1.71 +   YM4:  "[| evs4 \<in> yahalom;
    1.72               Gets A {|Nonce NB, Crypt (shrK A) {|Agent B, Key K, Nonce NA|},
    1.73 -                      X|}  \\<in> set evs4;
    1.74 -             Says A B {|Agent A, Nonce NA|} \\<in> set evs4 |]
    1.75 -          ==> Says A B {|X, Crypt K (Nonce NB)|} # evs4 \\<in> yahalom"
    1.76 +                      X|}  \<in> set evs4;
    1.77 +             Says A B {|Agent A, Nonce NA|} \<in> set evs4 |]
    1.78 +          ==> Says A B {|X, Crypt K (Nonce NB)|} # evs4 \<in> yahalom"
    1.79  
    1.80           (*This message models possible leaks of session keys.  The nonces
    1.81             identify the protocol run.  Quoting Server here ensures they are
    1.82             correct. *)
    1.83 -    Oops "[| evso \\<in> yahalom;  
    1.84 -             Says Server A {|Nonce NB, 
    1.85 +   Oops: "[| evso \<in> yahalom;
    1.86 +             Says Server A {|Nonce NB,
    1.87                               Crypt (shrK A) {|Agent B, Key K, Nonce NA|},
    1.88 -                             X|}  \\<in> set evso |]
    1.89 -          ==> Notes Spy {|Nonce NA, Nonce NB, Key K|} # evso \\<in> yahalom"
    1.90 +                             X|}  \<in> set evso |]
    1.91 +          ==> Notes Spy {|Nonce NA, Nonce NB, Key K|} # evso \<in> yahalom"
    1.92 +
    1.93 +
    1.94 +declare Says_imp_knows_Spy [THEN analz.Inj, dest]
    1.95 +declare parts.Body  [dest]
    1.96 +declare Fake_parts_insert_in_Un  [dest]
    1.97 +declare analz_into_parts [dest]
    1.98 +
    1.99 +(*A "possibility property": there are traces that reach the end*)
   1.100 +lemma "\<exists>X NB K. \<exists>evs \<in> yahalom.
   1.101 +             Says A B {|X, Crypt K (Nonce NB)|} \<in> set evs"
   1.102 +apply (intro exI bexI)
   1.103 +apply (rule_tac [2] yahalom.Nil
   1.104 +                    [THEN yahalom.YM1, THEN yahalom.Reception,
   1.105 +                     THEN yahalom.YM2, THEN yahalom.Reception,
   1.106 +                     THEN yahalom.YM3, THEN yahalom.Reception,
   1.107 +                     THEN yahalom.YM4])
   1.108 +apply possibility
   1.109 +done
   1.110 +
   1.111 +lemma Gets_imp_Says:
   1.112 +     "[| Gets B X \<in> set evs; evs \<in> yahalom |] ==> \<exists>A. Says A B X \<in> set evs"
   1.113 +by (erule rev_mp, erule yahalom.induct, auto)
   1.114 +
   1.115 +(*Must be proved separately for each protocol*)
   1.116 +lemma Gets_imp_knows_Spy:
   1.117 +     "[| Gets B X \<in> set evs; evs \<in> yahalom |]  ==> X \<in> knows Spy evs"
   1.118 +by (blast dest!: Gets_imp_Says Says_imp_knows_Spy)
   1.119 +
   1.120 +declare Gets_imp_knows_Spy [THEN analz.Inj, dest]
   1.121 +
   1.122 +
   1.123 +(**** Inductive proofs about yahalom ****)
   1.124 +
   1.125 +(** For reasoning about the encrypted portion of messages **)
   1.126 +
   1.127 +(*Lets us treat YM4 using a similar argument as for the Fake case.*)
   1.128 +lemma YM4_analz_knows_Spy:
   1.129 +     "[| Gets A {|NB, Crypt (shrK A) Y, X|} \<in> set evs;  evs \<in> yahalom |]
   1.130 +      ==> X \<in> analz (knows Spy evs)"
   1.131 +by blast
   1.132 +
   1.133 +lemmas YM4_parts_knows_Spy =
   1.134 +       YM4_analz_knows_Spy [THEN analz_into_parts, standard]
   1.135 +
   1.136 +
   1.137 +(** Theorems of the form X \<notin> parts (knows Spy evs) imply that NOBODY
   1.138 +    sends messages containing X! **)
   1.139 +
   1.140 +(*Spy never sees a good agent's shared key!*)
   1.141 +lemma Spy_see_shrK [simp]:
   1.142 +     "evs \<in> yahalom ==> (Key (shrK A) \<in> parts (knows Spy evs)) = (A \<in> bad)"
   1.143 +apply (erule yahalom.induct, force,
   1.144 +       drule_tac [6] YM4_parts_knows_Spy, simp_all)
   1.145 +apply blast+
   1.146 +done
   1.147 +
   1.148 +lemma Spy_analz_shrK [simp]:
   1.149 +     "evs \<in> yahalom ==> (Key (shrK A) \<in> analz (knows Spy evs)) = (A \<in> bad)"
   1.150 +by auto
   1.151 +
   1.152 +lemma Spy_see_shrK_D [dest!]:
   1.153 +     "[|Key (shrK A) \<in> parts (knows Spy evs);  evs \<in> yahalom|] ==> A \<in> bad"
   1.154 +by (blast dest: Spy_see_shrK)
   1.155 +
   1.156 +(*Nobody can have used non-existent keys!  Needed to apply analz_insert_Key*)
   1.157 +lemma new_keys_not_used [rule_format, simp]:
   1.158 + "evs \<in> yahalom ==> Key K \<notin> used evs --> K \<notin> keysFor (parts (knows Spy evs))"
   1.159 +apply (erule yahalom.induct, force,
   1.160 +       frule_tac [6] YM4_parts_knows_Spy, simp_all)
   1.161 +(*Fake, YM3, YM4*)
   1.162 +apply (blast dest!: keysFor_parts_insert)+
   1.163 +done
   1.164 +
   1.165 +
   1.166 +(*Describes the form of K when the Server sends this message.  Useful for
   1.167 +  Oops as well as main secrecy property.*)
   1.168 +lemma Says_Server_message_form:
   1.169 +     "[| Says Server A {|nb', Crypt (shrK A) {|Agent B, Key K, na|}, X|}
   1.170 +          \<in> set evs;  evs \<in> yahalom |]
   1.171 +      ==> K \<notin> range shrK"
   1.172 +by (erule rev_mp, erule yahalom.induct, simp_all)
   1.173 +
   1.174 +
   1.175 +(****
   1.176 + The following is to prove theorems of the form
   1.177 +
   1.178 +          Key K \<in> analz (insert (Key KAB) (knows Spy evs)) ==>
   1.179 +          Key K \<in> analz (knows Spy evs)
   1.180 +
   1.181 + A more general formula must be proved inductively.
   1.182 +****)
   1.183 +
   1.184 +(** Session keys are not used to encrypt other session keys **)
   1.185 +
   1.186 +lemma analz_image_freshK [rule_format]:
   1.187 + "evs \<in> yahalom ==>
   1.188 +   \<forall>K KK. KK <= - (range shrK) -->
   1.189 +          (Key K \<in> analz (Key`KK Un (knows Spy evs))) =
   1.190 +          (K \<in> KK | Key K \<in> analz (knows Spy evs))"
   1.191 +apply (erule yahalom.induct, force, frule_tac [7] Says_Server_message_form,
   1.192 +       drule_tac [6] YM4_analz_knows_Spy)
   1.193 +apply analz_freshK
   1.194 +apply spy_analz
   1.195 +done
   1.196 +
   1.197 +lemma analz_insert_freshK:
   1.198 +     "[| evs \<in> yahalom;  KAB \<notin> range shrK |] ==>
   1.199 +      Key K \<in> analz (insert (Key KAB) (knows Spy evs)) =
   1.200 +      (K = KAB | Key K \<in> analz (knows Spy evs))"
   1.201 +by (simp only: analz_image_freshK analz_image_freshK_simps)
   1.202 +
   1.203 +
   1.204 +(*** The Key K uniquely identifies the Server's  message. **)
   1.205 +
   1.206 +lemma unique_session_keys:
   1.207 +     "[| Says Server A
   1.208 +          {|nb, Crypt (shrK A) {|Agent B, Key K, na|}, X|} \<in> set evs;
   1.209 +        Says Server A'
   1.210 +          {|nb', Crypt (shrK A') {|Agent B', Key K, na'|}, X'|} \<in> set evs;
   1.211 +        evs \<in> yahalom |]
   1.212 +     ==> A=A' & B=B' & na=na' & nb=nb'"
   1.213 +apply (erule rev_mp, erule rev_mp)
   1.214 +apply (erule yahalom.induct, simp_all)
   1.215 +(*YM3, by freshness*)
   1.216 +apply blast
   1.217 +done
   1.218 +
   1.219 +
   1.220 +(** Crucial secrecy property: Spy does not see the keys sent in msg YM3 **)
   1.221 +
   1.222 +lemma secrecy_lemma:
   1.223 +     "[| A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
   1.224 +      ==> Says Server A
   1.225 +            {|nb, Crypt (shrK A) {|Agent B, Key K, na|},
   1.226 +                  Crypt (shrK B) {|Agent A, Agent B, Key K, nb|}|}
   1.227 +           \<in> set evs -->
   1.228 +          Notes Spy {|na, nb, Key K|} \<notin> set evs -->
   1.229 +          Key K \<notin> analz (knows Spy evs)"
   1.230 +apply (erule yahalom.induct, force, frule_tac [7] Says_Server_message_form,
   1.231 +       drule_tac [6] YM4_analz_knows_Spy)
   1.232 +apply (simp_all add: pushes analz_insert_eq analz_insert_freshK)
   1.233 +apply spy_analz  (*Fake*)
   1.234 +apply (blast dest: unique_session_keys)+  (*YM3, Oops*)
   1.235 +done
   1.236 +
   1.237 +
   1.238 +(*Final version*)
   1.239 +lemma Spy_not_see_encrypted_key:
   1.240 +     "[| Says Server A
   1.241 +            {|nb, Crypt (shrK A) {|Agent B, Key K, na|},
   1.242 +                  Crypt (shrK B) {|Agent A, Agent B, Key K, nb|}|}
   1.243 +         \<in> set evs;
   1.244 +         Notes Spy {|na, nb, Key K|} \<notin> set evs;
   1.245 +         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
   1.246 +      ==> Key K \<notin> analz (knows Spy evs)"
   1.247 +by (blast dest: secrecy_lemma Says_Server_message_form)
   1.248 +
   1.249 +
   1.250 +(** Security Guarantee for A upon receiving YM3 **)
   1.251 +
   1.252 +(*If the encrypted message appears then it originated with the Server.
   1.253 +  May now apply Spy_not_see_encrypted_key, subject to its conditions.*)
   1.254 +lemma A_trusts_YM3:
   1.255 +     "[| Crypt (shrK A) {|Agent B, Key K, na|} \<in> parts (knows Spy evs);
   1.256 +         A \<notin> bad;  evs \<in> yahalom |]
   1.257 +      ==> \<exists>nb. Says Server A
   1.258 +                    {|nb, Crypt (shrK A) {|Agent B, Key K, na|},
   1.259 +                          Crypt (shrK B) {|Agent A, Agent B, Key K, nb|}|}
   1.260 +                  \<in> set evs"
   1.261 +apply (erule rev_mp)
   1.262 +apply (erule yahalom.induct, force,
   1.263 +       frule_tac [6] YM4_parts_knows_Spy, simp_all)
   1.264 +(*Fake, YM3*)
   1.265 +apply blast+
   1.266 +done
   1.267 +
   1.268 +(*The obvious combination of A_trusts_YM3 with Spy_not_see_encrypted_key*)
   1.269 +lemma A_gets_good_key:
   1.270 +     "[| Crypt (shrK A) {|Agent B, Key K, na|} \<in> parts (knows Spy evs);
   1.271 +         \<forall>nb. Notes Spy {|na, nb, Key K|} \<notin> set evs;
   1.272 +         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
   1.273 +      ==> Key K \<notin> analz (knows Spy evs)"
   1.274 +by (blast dest!: A_trusts_YM3 Spy_not_see_encrypted_key)
   1.275 +
   1.276 +
   1.277 +(** Security Guarantee for B upon receiving YM4 **)
   1.278 +
   1.279 +(*B knows, by the first part of A's message, that the Server distributed
   1.280 +  the key for A and B, and has associated it with NB.*)
   1.281 +lemma B_trusts_YM4_shrK:
   1.282 +     "[| Crypt (shrK B) {|Agent A, Agent B, Key K, Nonce NB|}
   1.283 +           \<in> parts (knows Spy evs);
   1.284 +         B \<notin> bad;  evs \<in> yahalom |]
   1.285 +  ==> \<exists>NA. Says Server A
   1.286 +             {|Nonce NB,
   1.287 +               Crypt (shrK A) {|Agent B, Key K, Nonce NA|},
   1.288 +               Crypt (shrK B) {|Agent A, Agent B, Key K, Nonce NB|}|}
   1.289 +             \<in> set evs"
   1.290 +apply (erule rev_mp)
   1.291 +apply (erule yahalom.induct, force,
   1.292 +       frule_tac [6] YM4_parts_knows_Spy, simp_all)
   1.293 +(*Fake, YM3*)
   1.294 +apply blast+
   1.295 +done
   1.296 +
   1.297 +
   1.298 +(*With this protocol variant, we don't need the 2nd part of YM4 at all:
   1.299 +  Nonce NB is available in the first part.*)
   1.300 +
   1.301 +(*What can B deduce from receipt of YM4?  Stronger and simpler than Yahalom
   1.302 +  because we do not have to show that NB is secret. *)
   1.303 +lemma B_trusts_YM4:
   1.304 +     "[| Gets B {|Crypt (shrK B) {|Agent A, Agent B, Key K, Nonce NB|},  X|}
   1.305 +           \<in> set evs;
   1.306 +         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
   1.307 +  ==> \<exists>NA. Says Server A
   1.308 +             {|Nonce NB,
   1.309 +               Crypt (shrK A) {|Agent B, Key K, Nonce NA|},
   1.310 +               Crypt (shrK B) {|Agent A, Agent B, Key K, Nonce NB|}|}
   1.311 +            \<in> set evs"
   1.312 +by (blast dest!: B_trusts_YM4_shrK)
   1.313 +
   1.314 +
   1.315 +(*The obvious combination of B_trusts_YM4 with Spy_not_see_encrypted_key*)
   1.316 +lemma B_gets_good_key:
   1.317 +     "[| Gets B {|Crypt (shrK B) {|Agent A, Agent B, Key K, Nonce NB|}, X|}
   1.318 +           \<in> set evs;
   1.319 +         \<forall>na. Notes Spy {|na, Nonce NB, Key K|} \<notin> set evs;
   1.320 +         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
   1.321 +      ==> Key K \<notin> analz (knows Spy evs)"
   1.322 +by (blast dest!: B_trusts_YM4 Spy_not_see_encrypted_key)
   1.323 +
   1.324 +
   1.325 +(*** Authenticating B to A ***)
   1.326 +
   1.327 +(*The encryption in message YM2 tells us it cannot be faked.*)
   1.328 +lemma B_Said_YM2:
   1.329 +     "[| Crypt (shrK B) {|Agent A, Nonce NA|} \<in> parts (knows Spy evs);
   1.330 +         B \<notin> bad;  evs \<in> yahalom |]
   1.331 +      ==> \<exists>NB. Says B Server {|Agent B, Nonce NB,
   1.332 +                               Crypt (shrK B) {|Agent A, Nonce NA|}|}
   1.333 +                      \<in> set evs"
   1.334 +apply (erule rev_mp)
   1.335 +apply (erule yahalom.induct, force,
   1.336 +       frule_tac [6] YM4_parts_knows_Spy, simp_all)
   1.337 +(*Fake, YM2*)
   1.338 +apply blast+
   1.339 +done
   1.340 +
   1.341 +
   1.342 +(*If the server sends YM3 then B sent YM2, perhaps with a different NB*)
   1.343 +lemma YM3_auth_B_to_A_lemma:
   1.344 +     "[| Says Server A {|nb, Crypt (shrK A) {|Agent B, Key K, Nonce NA|}, X|}
   1.345 +           \<in> set evs;
   1.346 +         B \<notin> bad;  evs \<in> yahalom |]
   1.347 +      ==> \<exists>nb'. Says B Server {|Agent B, nb',
   1.348 +                                   Crypt (shrK B) {|Agent A, Nonce NA|}|}
   1.349 +                       \<in> set evs"
   1.350 +apply (erule rev_mp)
   1.351 +apply (erule yahalom.induct, simp_all)
   1.352 +(*Fake, YM2, YM3*)
   1.353 +apply (blast dest!: B_Said_YM2)+
   1.354 +done
   1.355 +
   1.356 +(*If A receives YM3 then B has used nonce NA (and therefore is alive)*)
   1.357 +lemma YM3_auth_B_to_A:
   1.358 +     "[| Gets A {|nb, Crypt (shrK A) {|Agent B, Key K, Nonce NA|}, X|}
   1.359 +           \<in> set evs;
   1.360 +         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
   1.361 + ==> \<exists>nb'. Says B Server
   1.362 +                  {|Agent B, nb', Crypt (shrK B) {|Agent A, Nonce NA|}|}
   1.363 +               \<in> set evs"
   1.364 +by (blast dest!: A_trusts_YM3 YM3_auth_B_to_A_lemma)
   1.365 +
   1.366 +
   1.367 +
   1.368 +(*** Authenticating A to B using the certificate Crypt K (Nonce NB) ***)
   1.369 +
   1.370 +(*Assuming the session key is secure, if both certificates are present then
   1.371 +  A has said NB.  We can't be sure about the rest of A's message, but only
   1.372 +  NB matters for freshness.  Note that  Key K \<notin> analz (knows Spy evs)  must be
   1.373 +  the FIRST antecedent of the induction formula.*)
   1.374 +
   1.375 +(*This lemma allows a use of unique_session_keys in the next proof,
   1.376 +  which otherwise is extremely slow.*)
   1.377 +lemma secure_unique_session_keys:
   1.378 +     "[| Crypt (shrK A) {|Agent B, Key K, na|} \<in> analz (spies evs);
   1.379 +         Crypt (shrK A') {|Agent B', Key K, na'|} \<in> analz (spies evs);
   1.380 +         Key K \<notin> analz (knows Spy evs);  evs \<in> yahalom |]
   1.381 +     ==> A=A' & B=B'"
   1.382 +by (blast dest!: A_trusts_YM3 dest: unique_session_keys Crypt_Spy_analz_bad)
   1.383 +
   1.384 +
   1.385 +lemma Auth_A_to_B_lemma [rule_format]:
   1.386 +     "evs \<in> yahalom
   1.387 +      ==> Key K \<notin> analz (knows Spy evs) -->
   1.388 +          Crypt K (Nonce NB) \<in> parts (knows Spy evs) -->
   1.389 +          Crypt (shrK B) {|Agent A, Agent B, Key K, Nonce NB|}
   1.390 +            \<in> parts (knows Spy evs) -->
   1.391 +          B \<notin> bad -->
   1.392 +          (\<exists>X. Says A B {|X, Crypt K (Nonce NB)|} \<in> set evs)"
   1.393 +apply (erule yahalom.induct, force,
   1.394 +       frule_tac [6] YM4_parts_knows_Spy)
   1.395 +apply (analz_mono_contra, simp_all)
   1.396 +(*Fake*)
   1.397 +apply blast
   1.398 +(*YM3: by new_keys_not_used we note that Crypt K (Nonce NB) could not exist*)
   1.399 +apply (force dest!: Crypt_imp_keysFor)
   1.400 +(*YM4: was Crypt K (Nonce NB) the very last message?  If so, apply unicity
   1.401 +  of session keys; if not, use ind. hyp.*)
   1.402 +apply (blast dest!: B_trusts_YM4_shrK dest: secure_unique_session_keys  )
   1.403 +done
   1.404 +
   1.405 +
   1.406 +(*If B receives YM4 then A has used nonce NB (and therefore is alive).
   1.407 +  Moreover, A associates K with NB (thus is talking about the same run).
   1.408 +  Other premises guarantee secrecy of K.*)
   1.409 +lemma YM4_imp_A_Said_YM3 [rule_format]:
   1.410 +     "[| Gets B {|Crypt (shrK B) {|Agent A, Agent B, Key K, Nonce NB|},
   1.411 +                  Crypt K (Nonce NB)|} \<in> set evs;
   1.412 +         (\<forall>NA. Notes Spy {|Nonce NA, Nonce NB, Key K|} \<notin> set evs);
   1.413 +         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
   1.414 +      ==> \<exists>X. Says A B {|X, Crypt K (Nonce NB)|} \<in> set evs"
   1.415 +by (blast intro: Auth_A_to_B_lemma
   1.416 +          dest: Spy_not_see_encrypted_key B_trusts_YM4_shrK)
   1.417  
   1.418  end