src/HOL/Auth/Yahalom.thy
author wenzelm
Mon Jan 11 21:21:02 2016 +0100 (2016-01-11)
changeset 62145 5b946c81dfbf
parent 61956 38b73f7940af
child 64364 464420ba7f74
permissions -rw-r--r--
eliminated old defs;
wenzelm@37936
     1
(*  Title:      HOL/Auth/Yahalom.thy
paulson@1985
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@1985
     3
    Copyright   1996  University of Cambridge
paulson@1985
     4
*)
paulson@1985
     5
wenzelm@61830
     6
section\<open>The Yahalom Protocol\<close>
paulson@13956
     7
haftmann@16417
     8
theory Yahalom imports Public begin
paulson@14207
     9
wenzelm@61830
    10
text\<open>From page 257 of
paulson@14207
    11
  Burrows, Abadi and Needham (1989).  A Logic of Authentication.
paulson@14207
    12
  Proc. Royal Soc. 426
paulson@14207
    13
paulson@14207
    14
This theory has the prototypical example of a secrecy relation, KeyCryptNonce.
wenzelm@61830
    15
\<close>
paulson@1985
    16
berghofe@23746
    17
inductive_set yahalom :: "event list set"
berghofe@23746
    18
  where
paulson@1985
    19
         (*Initial trace is empty*)
paulson@11251
    20
   Nil:  "[] \<in> yahalom"
paulson@1985
    21
paulson@2032
    22
         (*The spy MAY say anything he CAN say.  We do not expect him to
paulson@1985
    23
           invent new nonces here, but he can also use NS1.  Common to
paulson@1985
    24
           all similar protocols.*)
berghofe@23746
    25
 | Fake: "[| evsf \<in> yahalom;  X \<in> synth (analz (knows Spy evsf)) |]
paulson@11251
    26
          ==> Says Spy B X  # evsf \<in> yahalom"
paulson@1985
    27
paulson@6335
    28
         (*A message that has been sent can be received by the
paulson@6335
    29
           intended recipient.*)
berghofe@23746
    30
 | Reception: "[| evsr \<in> yahalom;  Says A B X \<in> set evsr |]
paulson@11251
    31
               ==> Gets B X # evsr \<in> yahalom"
paulson@6335
    32
paulson@1985
    33
         (*Alice initiates a protocol run*)
berghofe@23746
    34
 | YM1:  "[| evs1 \<in> yahalom;  Nonce NA \<notin> used evs1 |]
wenzelm@61956
    35
          ==> Says A B \<lbrace>Agent A, Nonce NA\<rbrace> # evs1 \<in> yahalom"
paulson@1985
    36
paulson@6335
    37
         (*Bob's response to Alice's message.*)
berghofe@23746
    38
 | YM2:  "[| evs2 \<in> yahalom;  Nonce NB \<notin> used evs2;
wenzelm@61956
    39
             Gets B \<lbrace>Agent A, Nonce NA\<rbrace> \<in> set evs2 |]
paulson@1985
    40
          ==> Says B Server 
wenzelm@61956
    41
                  \<lbrace>Agent B, Crypt (shrK B) \<lbrace>Agent A, Nonce NA, Nonce NB\<rbrace>\<rbrace>
paulson@11251
    42
                # evs2 \<in> yahalom"
paulson@1985
    43
paulson@1985
    44
         (*The Server receives Bob's message.  He responds by sending a
paulson@1985
    45
            new session key to Alice, with a packet for forwarding to Bob.*)
berghofe@23746
    46
 | YM3:  "[| evs3 \<in> yahalom;  Key KAB \<notin> used evs3;  KAB \<in> symKeys;
paulson@6335
    47
             Gets Server 
wenzelm@61956
    48
                  \<lbrace>Agent B, Crypt (shrK B) \<lbrace>Agent A, Nonce NA, Nonce NB\<rbrace>\<rbrace>
paulson@11251
    49
               \<in> set evs3 |]
paulson@1995
    50
          ==> Says Server A
wenzelm@61956
    51
                   \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key KAB, Nonce NA, Nonce NB\<rbrace>,
wenzelm@61956
    52
                     Crypt (shrK B) \<lbrace>Agent A, Key KAB\<rbrace>\<rbrace>
paulson@11251
    53
                # evs3 \<in> yahalom"
paulson@1985
    54
berghofe@23746
    55
 | YM4:  
wenzelm@61830
    56
       \<comment>\<open>Alice receives the Server's (?) message, checks her Nonce, and
paulson@3961
    57
           uses the new session key to send Bob his Nonce.  The premise
wenzelm@61830
    58
           @{term "A \<noteq> Server"} is needed for \<open>Says_Server_not_range\<close>.
wenzelm@61830
    59
           Alice can check that K is symmetric by its length.\<close>
wenzelm@32960
    60
         "[| evs4 \<in> yahalom;  A \<noteq> Server;  K \<in> symKeys;
wenzelm@61956
    61
             Gets A \<lbrace>Crypt(shrK A) \<lbrace>Agent B, Key K, Nonce NA, Nonce NB\<rbrace>, X\<rbrace>
paulson@11251
    62
                \<in> set evs4;
wenzelm@61956
    63
             Says A B \<lbrace>Agent A, Nonce NA\<rbrace> \<in> set evs4 |]
wenzelm@61956
    64
          ==> Says A B \<lbrace>X, Crypt K (Nonce NB)\<rbrace> # evs4 \<in> yahalom"
paulson@1985
    65
paulson@2110
    66
         (*This message models possible leaks of session keys.  The Nonces
paulson@2156
    67
           identify the protocol run.  Quoting Server here ensures they are
paulson@2156
    68
           correct.*)
berghofe@23746
    69
 | Oops: "[| evso \<in> yahalom;  
wenzelm@61956
    70
             Says Server A \<lbrace>Crypt (shrK A)
wenzelm@61956
    71
                                   \<lbrace>Agent B, Key K, Nonce NA, Nonce NB\<rbrace>,
wenzelm@61956
    72
                             X\<rbrace>  \<in> set evso |]
wenzelm@61956
    73
          ==> Notes Spy \<lbrace>Nonce NA, Nonce NB, Key K\<rbrace> # evso \<in> yahalom"
paulson@2110
    74
paulson@3447
    75
haftmann@35416
    76
definition KeyWithNonce :: "[key, nat, event list] => bool" where
paulson@3447
    77
  "KeyWithNonce K NB evs ==
paulson@11251
    78
     \<exists>A B na X. 
wenzelm@61956
    79
       Says Server A \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, na, Nonce NB\<rbrace>, X\<rbrace>
paulson@11251
    80
         \<in> set evs"
paulson@11251
    81
paulson@11251
    82
paulson@18570
    83
declare Says_imp_analz_Spy [dest]
paulson@11251
    84
declare parts.Body  [dest]
paulson@11251
    85
declare Fake_parts_insert_in_Un  [dest]
paulson@11251
    86
declare analz_into_parts [dest]
paulson@11251
    87
wenzelm@61830
    88
text\<open>A "possibility property": there are traces that reach the end\<close>
paulson@14207
    89
lemma "[| A \<noteq> Server; K \<in> symKeys; Key K \<notin> used [] |]
paulson@14207
    90
      ==> \<exists>X NB. \<exists>evs \<in> yahalom.
wenzelm@61956
    91
             Says A B \<lbrace>X, Crypt K (Nonce NB)\<rbrace> \<in> set evs"
paulson@11251
    92
apply (intro exI bexI)
paulson@11251
    93
apply (rule_tac [2] yahalom.Nil
paulson@14207
    94
                    [THEN yahalom.YM1, THEN yahalom.Reception,
paulson@14207
    95
                     THEN yahalom.YM2, THEN yahalom.Reception,
paulson@14207
    96
                     THEN yahalom.YM3, THEN yahalom.Reception,
paulson@14200
    97
                     THEN yahalom.YM4])
paulson@14207
    98
apply (possibility, simp add: used_Cons)
paulson@11251
    99
done
paulson@11251
   100
paulson@14207
   101
wenzelm@61830
   102
subsection\<open>Regularity Lemmas for Yahalom\<close>
paulson@14207
   103
paulson@11251
   104
lemma Gets_imp_Says:
paulson@11251
   105
     "[| Gets B X \<in> set evs; evs \<in> yahalom |] ==> \<exists>A. Says A B X \<in> set evs"
paulson@11251
   106
by (erule rev_mp, erule yahalom.induct, auto)
paulson@11251
   107
wenzelm@61830
   108
text\<open>Must be proved separately for each protocol\<close>
paulson@11251
   109
lemma Gets_imp_knows_Spy:
paulson@11251
   110
     "[| Gets B X \<in> set evs; evs \<in> yahalom |]  ==> X \<in> knows Spy evs"
paulson@11251
   111
by (blast dest!: Gets_imp_Says Says_imp_knows_Spy)
paulson@11251
   112
paulson@18570
   113
lemmas Gets_imp_analz_Spy = Gets_imp_knows_Spy [THEN analz.Inj]
paulson@18570
   114
declare Gets_imp_analz_Spy [dest]
paulson@11251
   115
paulson@11251
   116
wenzelm@61830
   117
text\<open>Lets us treat YM4 using a similar argument as for the Fake case.\<close>
paulson@11251
   118
lemma YM4_analz_knows_Spy:
wenzelm@61956
   119
     "[| Gets A \<lbrace>Crypt (shrK A) Y, X\<rbrace> \<in> set evs;  evs \<in> yahalom |]
paulson@11251
   120
      ==> X \<in> analz (knows Spy evs)"
paulson@11251
   121
by blast
paulson@11251
   122
paulson@14207
   123
lemmas YM4_parts_knows_Spy =
wenzelm@45605
   124
       YM4_analz_knows_Spy [THEN analz_into_parts]
paulson@11251
   125
wenzelm@61830
   126
text\<open>For Oops\<close>
paulson@11251
   127
lemma YM4_Key_parts_knows_Spy:
wenzelm@61956
   128
     "Says Server A \<lbrace>Crypt (shrK A) \<lbrace>B,K,NA,NB\<rbrace>, X\<rbrace> \<in> set evs
paulson@11251
   129
      ==> K \<in> parts (knows Spy evs)"
paulson@32367
   130
  by (metis parts.Body parts.Fst parts.Snd  Says_imp_knows_Spy parts.Inj)
paulson@11251
   131
wenzelm@61830
   132
text\<open>Theorems of the form @{term "X \<notin> parts (knows Spy evs)"} imply 
wenzelm@61830
   133
that NOBODY sends messages containing X!\<close>
paulson@11251
   134
wenzelm@61830
   135
text\<open>Spy never sees a good agent's shared key!\<close>
paulson@11251
   136
lemma Spy_see_shrK [simp]:
paulson@11251
   137
     "evs \<in> yahalom ==> (Key (shrK A) \<in> parts (knows Spy evs)) = (A \<in> bad)"
paulson@14207
   138
by (erule yahalom.induct, force,
paulson@14207
   139
    drule_tac [6] YM4_parts_knows_Spy, simp_all, blast+)
paulson@11251
   140
paulson@11251
   141
lemma Spy_analz_shrK [simp]:
paulson@11251
   142
     "evs \<in> yahalom ==> (Key (shrK A) \<in> analz (knows Spy evs)) = (A \<in> bad)"
paulson@11251
   143
by auto
paulson@11251
   144
paulson@11251
   145
lemma Spy_see_shrK_D [dest!]:
paulson@11251
   146
     "[|Key (shrK A) \<in> parts (knows Spy evs);  evs \<in> yahalom|] ==> A \<in> bad"
paulson@11251
   147
by (blast dest: Spy_see_shrK)
paulson@11251
   148
wenzelm@61830
   149
text\<open>Nobody can have used non-existent keys!
wenzelm@61830
   150
    Needed to apply \<open>analz_insert_Key\<close>\<close>
paulson@14207
   151
lemma new_keys_not_used [simp]:
paulson@14207
   152
    "[|Key K \<notin> used evs; K \<in> symKeys; evs \<in> yahalom|]
paulson@14207
   153
     ==> K \<notin> keysFor (parts (spies evs))"
paulson@14207
   154
apply (erule rev_mp)
paulson@14207
   155
apply (erule yahalom.induct, force,
paulson@11251
   156
       frule_tac [6] YM4_parts_knows_Spy, simp_all)
wenzelm@61830
   157
txt\<open>Fake\<close>
paulson@14207
   158
apply (force dest!: keysFor_parts_insert, auto)
paulson@11251
   159
done
paulson@11251
   160
paulson@11251
   161
wenzelm@61830
   162
text\<open>Earlier, all protocol proofs declared this theorem.
wenzelm@61830
   163
  But only a few proofs need it, e.g. Yahalom and Kerberos IV.\<close>
paulson@11251
   164
lemma new_keys_not_analzd:
paulson@14207
   165
 "[|K \<in> symKeys; evs \<in> yahalom; Key K \<notin> used evs|]
paulson@14207
   166
  ==> K \<notin> keysFor (analz (knows Spy evs))"
paulson@14207
   167
by (blast dest: new_keys_not_used intro: keysFor_mono [THEN subsetD])
paulson@11251
   168
paulson@11251
   169
wenzelm@61830
   170
text\<open>Describes the form of K when the Server sends this message.  Useful for
wenzelm@61830
   171
  Oops as well as main secrecy property.\<close>
paulson@11251
   172
lemma Says_Server_not_range [simp]:
wenzelm@61956
   173
     "[| Says Server A \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, na, nb\<rbrace>, X\<rbrace>
paulson@14207
   174
           \<in> set evs;   evs \<in> yahalom |]
paulson@11251
   175
      ==> K \<notin> range shrK"
nipkow@17778
   176
by (erule rev_mp, erule yahalom.induct, simp_all)
paulson@11251
   177
paulson@11251
   178
wenzelm@61830
   179
subsection\<open>Secrecy Theorems\<close>
paulson@11251
   180
paulson@11251
   181
(****
paulson@11251
   182
 The following is to prove theorems of the form
paulson@11251
   183
paulson@11251
   184
  Key K \<in> analz (insert (Key KAB) (knows Spy evs)) ==>
paulson@11251
   185
  Key K \<in> analz (knows Spy evs)
paulson@11251
   186
paulson@11251
   187
 A more general formula must be proved inductively.
paulson@11251
   188
****)
paulson@11251
   189
wenzelm@61830
   190
text\<open>Session keys are not used to encrypt other session keys\<close>
paulson@11251
   191
paulson@11251
   192
lemma analz_image_freshK [rule_format]:
paulson@14207
   193
 "evs \<in> yahalom ==>
paulson@14207
   194
   \<forall>K KK. KK <= - (range shrK) -->
paulson@14207
   195
          (Key K \<in> analz (Key`KK Un (knows Spy evs))) =
paulson@11251
   196
          (K \<in> KK | Key K \<in> analz (knows Spy evs))"
paulson@14207
   197
apply (erule yahalom.induct,
paulson@14207
   198
       drule_tac [7] YM4_analz_knows_Spy, analz_freshK, spy_analz, blast)
paulson@11251
   199
apply (simp only: Says_Server_not_range analz_image_freshK_simps)
haftmann@38795
   200
apply safe
paulson@11251
   201
done
paulson@11251
   202
paulson@11251
   203
lemma analz_insert_freshK:
paulson@14207
   204
     "[| evs \<in> yahalom;  KAB \<notin> range shrK |] ==>
wenzelm@11655
   205
      (Key K \<in> analz (insert (Key KAB) (knows Spy evs))) =
paulson@11251
   206
      (K = KAB | Key K \<in> analz (knows Spy evs))"
paulson@11251
   207
by (simp only: analz_image_freshK analz_image_freshK_simps)
paulson@11251
   208
paulson@11251
   209
wenzelm@61830
   210
text\<open>The Key K uniquely identifies the Server's  message.\<close>
paulson@11251
   211
lemma unique_session_keys:
paulson@14207
   212
     "[| Says Server A
wenzelm@61956
   213
          \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, na, nb\<rbrace>, X\<rbrace> \<in> set evs;
paulson@14207
   214
        Says Server A'
wenzelm@61956
   215
          \<lbrace>Crypt (shrK A') \<lbrace>Agent B', Key K, na', nb'\<rbrace>, X'\<rbrace> \<in> set evs;
paulson@14207
   216
        evs \<in> yahalom |]
paulson@11251
   217
     ==> A=A' & B=B' & na=na' & nb=nb'"
paulson@11251
   218
apply (erule rev_mp, erule rev_mp)
paulson@11251
   219
apply (erule yahalom.induct, simp_all)
wenzelm@61830
   220
txt\<open>YM3, by freshness, and YM4\<close>
paulson@11251
   221
apply blast+
paulson@11251
   222
done
paulson@11251
   223
paulson@11251
   224
wenzelm@61830
   225
text\<open>Crucial secrecy property: Spy does not see the keys sent in msg YM3\<close>
paulson@11251
   226
lemma secrecy_lemma:
paulson@14207
   227
     "[| A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
paulson@14207
   228
      ==> Says Server A
wenzelm@61956
   229
            \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, na, nb\<rbrace>,
wenzelm@61956
   230
              Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>\<rbrace>
paulson@14207
   231
           \<in> set evs -->
wenzelm@61956
   232
          Notes Spy \<lbrace>na, nb, Key K\<rbrace> \<notin> set evs -->
paulson@11251
   233
          Key K \<notin> analz (knows Spy evs)"
paulson@14207
   234
apply (erule yahalom.induct, force,
paulson@11251
   235
       drule_tac [6] YM4_analz_knows_Spy)
wenzelm@61830
   236
apply (simp_all add: pushes analz_insert_eq analz_insert_freshK, spy_analz)   \<comment>\<open>Fake\<close>
wenzelm@61830
   237
apply (blast dest: unique_session_keys)+  \<comment>\<open>YM3, Oops\<close>
paulson@11251
   238
done
paulson@11251
   239
wenzelm@61830
   240
text\<open>Final version\<close>
paulson@11251
   241
lemma Spy_not_see_encrypted_key:
paulson@14207
   242
     "[| Says Server A
wenzelm@61956
   243
            \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, na, nb\<rbrace>,
wenzelm@61956
   244
              Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>\<rbrace>
paulson@14207
   245
           \<in> set evs;
wenzelm@61956
   246
         Notes Spy \<lbrace>na, nb, Key K\<rbrace> \<notin> set evs;
paulson@14207
   247
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
paulson@11251
   248
      ==> Key K \<notin> analz (knows Spy evs)"
paulson@11251
   249
by (blast dest: secrecy_lemma)
paulson@11251
   250
paulson@11251
   251
wenzelm@61830
   252
subsubsection\<open>Security Guarantee for A upon receiving YM3\<close>
paulson@11251
   253
wenzelm@61830
   254
text\<open>If the encrypted message appears then it originated with the Server\<close>
paulson@11251
   255
lemma A_trusts_YM3:
wenzelm@61956
   256
     "[| Crypt (shrK A) \<lbrace>Agent B, Key K, na, nb\<rbrace> \<in> parts (knows Spy evs);
paulson@14207
   257
         A \<notin> bad;  evs \<in> yahalom |]
paulson@14207
   258
       ==> Says Server A
wenzelm@61956
   259
            \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, na, nb\<rbrace>,
wenzelm@61956
   260
              Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>\<rbrace>
paulson@11251
   261
           \<in> set evs"
paulson@11251
   262
apply (erule rev_mp)
paulson@14207
   263
apply (erule yahalom.induct, force,
paulson@11251
   264
       frule_tac [6] YM4_parts_knows_Spy, simp_all)
wenzelm@61830
   265
txt\<open>Fake, YM3\<close>
paulson@11251
   266
apply blast+
paulson@11251
   267
done
paulson@11251
   268
wenzelm@61830
   269
text\<open>The obvious combination of \<open>A_trusts_YM3\<close> with
wenzelm@61830
   270
  \<open>Spy_not_see_encrypted_key\<close>\<close>
paulson@11251
   271
lemma A_gets_good_key:
wenzelm@61956
   272
     "[| Crypt (shrK A) \<lbrace>Agent B, Key K, na, nb\<rbrace> \<in> parts (knows Spy evs);
wenzelm@61956
   273
         Notes Spy \<lbrace>na, nb, Key K\<rbrace> \<notin> set evs;
paulson@14207
   274
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
paulson@11251
   275
      ==> Key K \<notin> analz (knows Spy evs)"
paulson@32367
   276
  by (metis A_trusts_YM3 secrecy_lemma)
paulson@11251
   277
paulson@14207
   278
wenzelm@61830
   279
subsubsection\<open>Security Guarantees for B upon receiving YM4\<close>
paulson@11251
   280
wenzelm@61830
   281
text\<open>B knows, by the first part of A's message, that the Server distributed
wenzelm@61830
   282
  the key for A and B.  But this part says nothing about nonces.\<close>
paulson@11251
   283
lemma B_trusts_YM4_shrK:
wenzelm@61956
   284
     "[| Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace> \<in> parts (knows Spy evs);
paulson@14207
   285
         B \<notin> bad;  evs \<in> yahalom |]
paulson@14207
   286
      ==> \<exists>NA NB. Says Server A
wenzelm@61956
   287
                      \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K,
wenzelm@61956
   288
                                         Nonce NA, Nonce NB\<rbrace>,
wenzelm@61956
   289
                        Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>\<rbrace>
paulson@11251
   290
                     \<in> set evs"
paulson@11251
   291
apply (erule rev_mp)
paulson@14207
   292
apply (erule yahalom.induct, force,
paulson@11251
   293
       frule_tac [6] YM4_parts_knows_Spy, simp_all)
wenzelm@61830
   294
txt\<open>Fake, YM3\<close>
paulson@11251
   295
apply blast+
paulson@11251
   296
done
paulson@11251
   297
wenzelm@61830
   298
text\<open>B knows, by the second part of A's message, that the Server
wenzelm@17411
   299
  distributed the key quoting nonce NB.  This part says nothing about
wenzelm@17411
   300
  agent names.  Secrecy of NB is crucial.  Note that @{term "Nonce NB
wenzelm@17411
   301
  \<notin> analz(knows Spy evs)"} must be the FIRST antecedent of the
wenzelm@61830
   302
  induction formula.\<close>
wenzelm@17411
   303
paulson@14207
   304
lemma B_trusts_YM4_newK [rule_format]:
paulson@11251
   305
     "[|Crypt K (Nonce NB) \<in> parts (knows Spy evs);
paulson@11251
   306
        Nonce NB \<notin> analz (knows Spy evs);  evs \<in> yahalom|]
paulson@14207
   307
      ==> \<exists>A B NA. Says Server A
wenzelm@61956
   308
                      \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, Nonce NA, Nonce NB\<rbrace>,
wenzelm@61956
   309
                        Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>\<rbrace>
paulson@11251
   310
                     \<in> set evs"
paulson@11251
   311
apply (erule rev_mp, erule rev_mp)
paulson@14207
   312
apply (erule yahalom.induct, force,
paulson@11251
   313
       frule_tac [6] YM4_parts_knows_Spy)
paulson@11251
   314
apply (analz_mono_contra, simp_all)
wenzelm@61830
   315
txt\<open>Fake, YM3\<close>
paulson@11251
   316
apply blast
paulson@11251
   317
apply blast
wenzelm@61830
   318
txt\<open>YM4.  A is uncompromised because NB is secure
wenzelm@61830
   319
  A's certificate guarantees the existence of the Server message\<close>
paulson@14207
   320
apply (blast dest!: Gets_imp_Says Crypt_Spy_analz_bad
paulson@14207
   321
             dest: Says_imp_spies
paulson@11251
   322
                   parts.Inj [THEN parts.Fst, THEN A_trusts_YM3])
paulson@11251
   323
done
paulson@11251
   324
paulson@11251
   325
wenzelm@61830
   326
subsubsection\<open>Towards proving secrecy of Nonce NB\<close>
paulson@11251
   327
wenzelm@61830
   328
text\<open>Lemmas about the predicate KeyWithNonce\<close>
paulson@11251
   329
paulson@14207
   330
lemma KeyWithNonceI:
paulson@14207
   331
 "Says Server A
wenzelm@61956
   332
          \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, na, Nonce NB\<rbrace>, X\<rbrace>
paulson@11251
   333
        \<in> set evs ==> KeyWithNonce K NB evs"
paulson@11251
   334
by (unfold KeyWithNonce_def, blast)
paulson@11251
   335
paulson@14207
   336
lemma KeyWithNonce_Says [simp]:
paulson@14207
   337
   "KeyWithNonce K NB (Says S A X # evs) =
paulson@11251
   338
      (Server = S &
wenzelm@61956
   339
       (\<exists>B n X'. X = \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, n, Nonce NB\<rbrace>, X'\<rbrace>)
paulson@11251
   340
      | KeyWithNonce K NB evs)"
paulson@11251
   341
by (simp add: KeyWithNonce_def, blast)
paulson@11251
   342
paulson@11251
   343
paulson@14207
   344
lemma KeyWithNonce_Notes [simp]:
paulson@11251
   345
   "KeyWithNonce K NB (Notes A X # evs) = KeyWithNonce K NB evs"
paulson@11251
   346
by (simp add: KeyWithNonce_def)
paulson@11251
   347
paulson@14207
   348
lemma KeyWithNonce_Gets [simp]:
paulson@11251
   349
   "KeyWithNonce K NB (Gets A X # evs) = KeyWithNonce K NB evs"
paulson@11251
   350
by (simp add: KeyWithNonce_def)
paulson@11251
   351
wenzelm@61830
   352
text\<open>A fresh key cannot be associated with any nonce
wenzelm@61830
   353
  (with respect to a given trace).\<close>
paulson@14207
   354
lemma fresh_not_KeyWithNonce:
paulson@14207
   355
     "Key K \<notin> used evs ==> ~ KeyWithNonce K NB evs"
paulson@11251
   356
by (unfold KeyWithNonce_def, blast)
paulson@11251
   357
wenzelm@61830
   358
text\<open>The Server message associates K with NB' and therefore not with any
wenzelm@61830
   359
  other nonce NB.\<close>
paulson@14207
   360
lemma Says_Server_KeyWithNonce:
wenzelm@61956
   361
 "[| Says Server A \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, na, Nonce NB'\<rbrace>, X\<rbrace>
paulson@14207
   362
       \<in> set evs;
paulson@14207
   363
     NB \<noteq> NB';  evs \<in> yahalom |]
paulson@11251
   364
  ==> ~ KeyWithNonce K NB evs"
paulson@11251
   365
by (unfold KeyWithNonce_def, blast dest: unique_session_keys)
paulson@11251
   366
paulson@11251
   367
wenzelm@61830
   368
text\<open>The only nonces that can be found with the help of session keys are
paulson@11251
   369
  those distributed as nonce NB by the Server.  The form of the theorem
wenzelm@61830
   370
  recalls \<open>analz_image_freshK\<close>, but it is much more complicated.\<close>
paulson@11251
   371
paulson@11251
   372
wenzelm@61830
   373
text\<open>As with \<open>analz_image_freshK\<close>, we take some pains to express the 
wenzelm@61830
   374
  property as a logical equivalence so that the simplifier can apply it.\<close>
paulson@11251
   375
lemma Nonce_secrecy_lemma:
paulson@14207
   376
     "P --> (X \<in> analz (G Un H)) --> (X \<in> analz H)  ==>
paulson@11251
   377
      P --> (X \<in> analz (G Un H)) = (X \<in> analz H)"
paulson@11251
   378
by (blast intro: analz_mono [THEN subsetD])
paulson@11251
   379
paulson@11251
   380
lemma Nonce_secrecy:
paulson@14207
   381
     "evs \<in> yahalom ==>
paulson@14207
   382
      (\<forall>KK. KK <= - (range shrK) -->
paulson@14207
   383
           (\<forall>K \<in> KK. K \<in> symKeys --> ~ KeyWithNonce K NB evs)   -->
paulson@14207
   384
           (Nonce NB \<in> analz (Key`KK Un (knows Spy evs))) =
paulson@11251
   385
           (Nonce NB \<in> analz (knows Spy evs)))"
paulson@14207
   386
apply (erule yahalom.induct,
paulson@14207
   387
       frule_tac [7] YM4_analz_knows_Spy)
paulson@11251
   388
apply (safe del: allI impI intro!: Nonce_secrecy_lemma [THEN impI, THEN allI])
paulson@14207
   389
apply (simp_all del: image_insert image_Un
paulson@11251
   390
       add: analz_image_freshK_simps split_ifs
paulson@14207
   391
            all_conj_distrib ball_conj_distrib
paulson@11251
   392
            analz_image_freshK fresh_not_KeyWithNonce
paulson@11251
   393
            imp_disj_not1               (*Moves NBa\<noteq>NB to the front*)
paulson@11251
   394
            Says_Server_KeyWithNonce)
wenzelm@61830
   395
txt\<open>For Oops, simplification proves @{prop "NBa\<noteq>NB"}.  By
wenzelm@17411
   396
  @{term Says_Server_KeyWithNonce}, we get @{prop "~ KeyWithNonce K NB
wenzelm@17411
   397
  evs"}; then simplification can apply the induction hypothesis with
wenzelm@61830
   398
  @{term "KK = {K}"}.\<close>
wenzelm@61830
   399
txt\<open>Fake\<close>
paulson@11251
   400
apply spy_analz
wenzelm@61830
   401
txt\<open>YM2\<close>
paulson@14207
   402
apply blast
wenzelm@61830
   403
txt\<open>YM3\<close>
paulson@14207
   404
apply blast
wenzelm@61830
   405
txt\<open>YM4\<close>
wenzelm@59807
   406
apply (erule_tac V = "\<forall>KK. P KK" for P in thin_rl, clarify)
wenzelm@61830
   407
txt\<open>If @{prop "A \<in> bad"} then @{term NBa} is known, therefore
wenzelm@17411
   408
  @{prop "NBa \<noteq> NB"}.  Previous two steps make the next step
wenzelm@61830
   409
  faster.\<close>
paulson@32367
   410
apply (metis A_trusts_YM3 Gets_imp_analz_Spy Gets_imp_knows_Spy KeyWithNonce_def
paulson@32367
   411
      Spy_analz_shrK analz.Fst analz.Snd analz_shrK_Decrypt parts.Fst parts.Inj)
paulson@11251
   412
done
paulson@11251
   413
paulson@11251
   414
wenzelm@61830
   415
text\<open>Version required below: if NB can be decrypted using a session key then
paulson@14207
   416
   it was distributed with that key.  The more general form above is required
wenzelm@61830
   417
   for the induction to carry through.\<close>
paulson@11251
   418
lemma single_Nonce_secrecy:
paulson@14207
   419
     "[| Says Server A
wenzelm@61956
   420
          \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key KAB, na, Nonce NB'\<rbrace>, X\<rbrace>
paulson@14207
   421
         \<in> set evs;
paulson@14207
   422
         NB \<noteq> NB';  KAB \<notin> range shrK;  evs \<in> yahalom |]
paulson@14207
   423
      ==> (Nonce NB \<in> analz (insert (Key KAB) (knows Spy evs))) =
paulson@11251
   424
          (Nonce NB \<in> analz (knows Spy evs))"
paulson@11251
   425
by (simp_all del: image_insert image_Un imp_disjL
paulson@11251
   426
             add: analz_image_freshK_simps split_ifs
paulson@13507
   427
                  Nonce_secrecy Says_Server_KeyWithNonce)
paulson@11251
   428
paulson@11251
   429
wenzelm@61830
   430
subsubsection\<open>The Nonce NB uniquely identifies B's message.\<close>
paulson@11251
   431
paulson@11251
   432
lemma unique_NB:
wenzelm@61956
   433
     "[| Crypt (shrK B) \<lbrace>Agent A, Nonce NA, nb\<rbrace> \<in> parts (knows Spy evs);
wenzelm@61956
   434
         Crypt (shrK B') \<lbrace>Agent A', Nonce NA', nb\<rbrace> \<in> parts (knows Spy evs);
paulson@14207
   435
        evs \<in> yahalom;  B \<notin> bad;  B' \<notin> bad |]
paulson@11251
   436
      ==> NA' = NA & A' = A & B' = B"
paulson@11251
   437
apply (erule rev_mp, erule rev_mp)
paulson@14207
   438
apply (erule yahalom.induct, force,
paulson@11251
   439
       frule_tac [6] YM4_parts_knows_Spy, simp_all)
wenzelm@61830
   440
txt\<open>Fake, and YM2 by freshness\<close>
paulson@11251
   441
apply blast+
paulson@11251
   442
done
paulson@11251
   443
paulson@11251
   444
wenzelm@61830
   445
text\<open>Variant useful for proving secrecy of NB.  Because nb is assumed to be
wenzelm@61830
   446
  secret, we no longer must assume B, B' not bad.\<close>
paulson@11251
   447
lemma Says_unique_NB:
wenzelm@61956
   448
     "[| Says C S   \<lbrace>X,  Crypt (shrK B) \<lbrace>Agent A, Nonce NA, nb\<rbrace>\<rbrace>
paulson@14207
   449
           \<in> set evs;
wenzelm@61956
   450
         Gets S' \<lbrace>X', Crypt (shrK B') \<lbrace>Agent A', Nonce NA', nb\<rbrace>\<rbrace>
paulson@14207
   451
           \<in> set evs;
paulson@14207
   452
         nb \<notin> analz (knows Spy evs);  evs \<in> yahalom |]
paulson@11251
   453
      ==> NA' = NA & A' = A & B' = B"
paulson@14207
   454
by (blast dest!: Gets_imp_Says Crypt_Spy_analz_bad
paulson@11251
   455
          dest: Says_imp_spies unique_NB parts.Inj analz.Inj)
paulson@11251
   456
paulson@11251
   457
wenzelm@61830
   458
subsubsection\<open>A nonce value is never used both as NA and as NB\<close>
paulson@11251
   459
paulson@11251
   460
lemma no_nonce_YM1_YM2:
wenzelm@61956
   461
     "[|Crypt (shrK B') \<lbrace>Agent A', Nonce NB, nb'\<rbrace> \<in> parts(knows Spy evs);
paulson@11251
   462
        Nonce NB \<notin> analz (knows Spy evs);  evs \<in> yahalom|]
wenzelm@61956
   463
  ==> Crypt (shrK B)  \<lbrace>Agent A, na, Nonce NB\<rbrace> \<notin> parts(knows Spy evs)"
paulson@11251
   464
apply (erule rev_mp, erule rev_mp)
paulson@14207
   465
apply (erule yahalom.induct, force,
paulson@11251
   466
       frule_tac [6] YM4_parts_knows_Spy)
paulson@11251
   467
apply (analz_mono_contra, simp_all)
wenzelm@61830
   468
txt\<open>Fake, YM2\<close>
paulson@11251
   469
apply blast+
paulson@11251
   470
done
paulson@11251
   471
wenzelm@61830
   472
text\<open>The Server sends YM3 only in response to YM2.\<close>
paulson@11251
   473
lemma Says_Server_imp_YM2:
wenzelm@61956
   474
     "[| Says Server A \<lbrace>Crypt (shrK A) \<lbrace>Agent B, k, na, nb\<rbrace>, X\<rbrace> \<in> set evs;
paulson@14207
   475
         evs \<in> yahalom |]
wenzelm@61956
   476
      ==> Gets Server \<lbrace>Agent B, Crypt (shrK B) \<lbrace>Agent A, na, nb\<rbrace>\<rbrace>
paulson@11251
   477
             \<in> set evs"
paulson@14207
   478
by (erule rev_mp, erule yahalom.induct, auto)
paulson@11251
   479
wenzelm@61830
   480
text\<open>A vital theorem for B, that nonce NB remains secure from the Spy.\<close>
paulson@11251
   481
lemma Spy_not_see_NB :
paulson@14207
   482
     "[| Says B Server
wenzelm@61956
   483
                \<lbrace>Agent B, Crypt (shrK B) \<lbrace>Agent A, Nonce NA, Nonce NB\<rbrace>\<rbrace>
wenzelm@32960
   484
           \<in> set evs;
wenzelm@61956
   485
         (\<forall>k. Notes Spy \<lbrace>Nonce NA, Nonce NB, k\<rbrace> \<notin> set evs);
paulson@14207
   486
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
paulson@11251
   487
      ==> Nonce NB \<notin> analz (knows Spy evs)"
paulson@11251
   488
apply (erule rev_mp, erule rev_mp)
paulson@14207
   489
apply (erule yahalom.induct, force,
paulson@11251
   490
       frule_tac [6] YM4_analz_knows_Spy)
paulson@11251
   491
apply (simp_all add: split_ifs pushes new_keys_not_analzd analz_insert_eq
paulson@11251
   492
                     analz_insert_freshK)
wenzelm@61830
   493
txt\<open>Fake\<close>
paulson@11251
   494
apply spy_analz
wenzelm@61830
   495
txt\<open>YM1: NB=NA is impossible anyway, but NA is secret because it is fresh!\<close>
paulson@11251
   496
apply blast
wenzelm@61830
   497
txt\<open>YM2\<close>
paulson@11251
   498
apply blast
wenzelm@61830
   499
txt\<open>Prove YM3 by showing that no NB can also be an NA\<close>
paulson@11251
   500
apply (blast dest!: no_nonce_YM1_YM2 dest: Gets_imp_Says Says_unique_NB)
wenzelm@61830
   501
txt\<open>LEVEL 7: YM4 and Oops remain\<close>
paulson@11251
   502
apply (clarify, simp add: all_conj_distrib)
wenzelm@61830
   503
txt\<open>YM4: key K is visible to Spy, contradicting session key secrecy theorem\<close>
wenzelm@61830
   504
txt\<open>Case analysis on Aa:bad; PROOF FAILED problems
wenzelm@61830
   505
  use \<open>Says_unique_NB\<close> to identify message components: @{term "Aa=A"}, @{term "Ba=B"}\<close>
paulson@14207
   506
apply (blast dest!: Says_unique_NB analz_shrK_Decrypt
paulson@14207
   507
                    parts.Inj [THEN parts.Fst, THEN A_trusts_YM3]
paulson@11251
   508
             dest: Gets_imp_Says Says_imp_spies Says_Server_imp_YM2
paulson@11251
   509
                   Spy_not_see_encrypted_key)
wenzelm@61830
   510
txt\<open>Oops case: if the nonce is betrayed now, show that the Oops event is
wenzelm@61830
   511
  covered by the quantified Oops assumption.\<close>
paulson@11251
   512
apply (clarify, simp add: all_conj_distrib)
paulson@11251
   513
apply (frule Says_Server_imp_YM2, assumption)
paulson@32367
   514
apply (metis Gets_imp_Says Says_Server_not_range Says_unique_NB no_nonce_YM1_YM2 parts.Snd single_Nonce_secrecy spies_partsEs(1))
paulson@11251
   515
done
paulson@11251
   516
paulson@11251
   517
wenzelm@61830
   518
text\<open>B's session key guarantee from YM4.  The two certificates contribute to a
paulson@11251
   519
  single conclusion about the Server's message.  Note that the "Notes Spy"
wenzelm@61830
   520
  assumption must quantify over \<open>\<forall>\<close> POSSIBLE keys instead of our particular K.
paulson@11251
   521
  If this run is broken and the spy substitutes a certificate containing an
wenzelm@61830
   522
  old key, B has no means of telling.\<close>
paulson@11251
   523
lemma B_trusts_YM4:
wenzelm@61956
   524
     "[| Gets B \<lbrace>Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>,
wenzelm@61956
   525
                  Crypt K (Nonce NB)\<rbrace> \<in> set evs;
paulson@14207
   526
         Says B Server
wenzelm@61956
   527
           \<lbrace>Agent B, Crypt (shrK B) \<lbrace>Agent A, Nonce NA, Nonce NB\<rbrace>\<rbrace>
paulson@14207
   528
           \<in> set evs;
wenzelm@61956
   529
         \<forall>k. Notes Spy \<lbrace>Nonce NA, Nonce NB, k\<rbrace> \<notin> set evs;
paulson@14207
   530
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
paulson@14207
   531
       ==> Says Server A
wenzelm@61956
   532
                   \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K,
wenzelm@61956
   533
                             Nonce NA, Nonce NB\<rbrace>,
wenzelm@61956
   534
                     Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>\<rbrace>
paulson@11251
   535
             \<in> set evs"
paulson@14207
   536
by (blast dest: Spy_not_see_NB Says_unique_NB
paulson@11251
   537
                Says_Server_imp_YM2 B_trusts_YM4_newK)
paulson@11251
   538
paulson@11251
   539
paulson@11251
   540
wenzelm@61830
   541
text\<open>The obvious combination of \<open>B_trusts_YM4\<close> with 
wenzelm@61830
   542
  \<open>Spy_not_see_encrypted_key\<close>\<close>
paulson@11251
   543
lemma B_gets_good_key:
wenzelm@61956
   544
     "[| Gets B \<lbrace>Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>,
wenzelm@61956
   545
                  Crypt K (Nonce NB)\<rbrace> \<in> set evs;
paulson@14207
   546
         Says B Server
wenzelm@61956
   547
           \<lbrace>Agent B, Crypt (shrK B) \<lbrace>Agent A, Nonce NA, Nonce NB\<rbrace>\<rbrace>
paulson@14207
   548
           \<in> set evs;
wenzelm@61956
   549
         \<forall>k. Notes Spy \<lbrace>Nonce NA, Nonce NB, k\<rbrace> \<notin> set evs;
paulson@14207
   550
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
paulson@11251
   551
      ==> Key K \<notin> analz (knows Spy evs)"
paulson@32367
   552
  by (metis B_trusts_YM4 Spy_not_see_encrypted_key)
paulson@11251
   553
paulson@11251
   554
wenzelm@61830
   555
subsection\<open>Authenticating B to A\<close>
paulson@11251
   556
wenzelm@61830
   557
text\<open>The encryption in message YM2 tells us it cannot be faked.\<close>
paulson@11251
   558
lemma B_Said_YM2 [rule_format]:
wenzelm@61956
   559
     "[|Crypt (shrK B) \<lbrace>Agent A, Nonce NA, nb\<rbrace> \<in> parts (knows Spy evs);
paulson@11251
   560
        evs \<in> yahalom|]
paulson@11251
   561
      ==> B \<notin> bad -->
wenzelm@61956
   562
          Says B Server \<lbrace>Agent B, Crypt (shrK B) \<lbrace>Agent A, Nonce NA, nb\<rbrace>\<rbrace>
paulson@11251
   563
            \<in> set evs"
paulson@14207
   564
apply (erule rev_mp, erule yahalom.induct, force,
paulson@11251
   565
       frule_tac [6] YM4_parts_knows_Spy, simp_all)
wenzelm@61830
   566
txt\<open>Fake\<close>
paulson@11251
   567
apply blast
paulson@11251
   568
done
paulson@11251
   569
wenzelm@61830
   570
text\<open>If the server sends YM3 then B sent YM2\<close>
paulson@11251
   571
lemma YM3_auth_B_to_A_lemma:
wenzelm@61956
   572
     "[|Says Server A \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, Nonce NA, nb\<rbrace>, X\<rbrace>
paulson@11251
   573
       \<in> set evs;  evs \<in> yahalom|]
paulson@14207
   574
      ==> B \<notin> bad -->
wenzelm@61956
   575
          Says B Server \<lbrace>Agent B, Crypt (shrK B) \<lbrace>Agent A, Nonce NA, nb\<rbrace>\<rbrace>
paulson@11251
   576
            \<in> set evs"
paulson@11251
   577
apply (erule rev_mp, erule yahalom.induct, simp_all)
wenzelm@61830
   578
txt\<open>YM3, YM4\<close>
paulson@11251
   579
apply (blast dest!: B_Said_YM2)+
paulson@11251
   580
done
paulson@11251
   581
wenzelm@61830
   582
text\<open>If A receives YM3 then B has used nonce NA (and therefore is alive)\<close>
paulson@11251
   583
lemma YM3_auth_B_to_A:
wenzelm@61956
   584
     "[| Gets A \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, Nonce NA, nb\<rbrace>, X\<rbrace>
paulson@14207
   585
           \<in> set evs;
paulson@14207
   586
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
wenzelm@61956
   587
      ==> Says B Server \<lbrace>Agent B, Crypt (shrK B) \<lbrace>Agent A, Nonce NA, nb\<rbrace>\<rbrace>
paulson@11251
   588
       \<in> set evs"
paulson@32367
   589
  by (metis A_trusts_YM3 Gets_imp_analz_Spy YM3_auth_B_to_A_lemma analz.Fst
paulson@32367
   590
         not_parts_not_analz)
paulson@11251
   591
paulson@11251
   592
wenzelm@61830
   593
subsection\<open>Authenticating A to B using the certificate 
wenzelm@61830
   594
  @{term "Crypt K (Nonce NB)"}\<close>
paulson@11251
   595
wenzelm@61830
   596
text\<open>Assuming the session key is secure, if both certificates are present then
paulson@11251
   597
  A has said NB.  We can't be sure about the rest of A's message, but only
wenzelm@61830
   598
  NB matters for freshness.\<close>
paulson@11251
   599
lemma A_Said_YM3_lemma [rule_format]:
paulson@11251
   600
     "evs \<in> yahalom
paulson@11251
   601
      ==> Key K \<notin> analz (knows Spy evs) -->
paulson@11251
   602
          Crypt K (Nonce NB) \<in> parts (knows Spy evs) -->
wenzelm@61956
   603
          Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace> \<in> parts (knows Spy evs) -->
paulson@11251
   604
          B \<notin> bad -->
wenzelm@61956
   605
          (\<exists>X. Says A B \<lbrace>X, Crypt K (Nonce NB)\<rbrace> \<in> set evs)"
paulson@14207
   606
apply (erule yahalom.induct, force,
paulson@11251
   607
       frule_tac [6] YM4_parts_knows_Spy)
paulson@11251
   608
apply (analz_mono_contra, simp_all)
wenzelm@61830
   609
txt\<open>Fake\<close>
paulson@11251
   610
apply blast
wenzelm@61830
   611
txt\<open>YM3: by \<open>new_keys_not_used\<close>, the message
wenzelm@61830
   612
   @{term "Crypt K (Nonce NB)"} could not exist\<close>
paulson@11251
   613
apply (force dest!: Crypt_imp_keysFor)
wenzelm@61830
   614
txt\<open>YM4: was @{term "Crypt K (Nonce NB)"} the very last message?
wenzelm@61830
   615
    If not, use the induction hypothesis\<close>
paulson@11251
   616
apply (simp add: ex_disj_distrib)
wenzelm@61830
   617
txt\<open>yes: apply unicity of session keys\<close>
paulson@11251
   618
apply (blast dest!: Gets_imp_Says A_trusts_YM3 B_trusts_YM4_shrK
paulson@14207
   619
                    Crypt_Spy_analz_bad
paulson@11251
   620
             dest: Says_imp_knows_Spy [THEN parts.Inj] unique_session_keys)
paulson@11251
   621
done
paulson@11251
   622
wenzelm@61830
   623
text\<open>If B receives YM4 then A has used nonce NB (and therefore is alive).
paulson@11251
   624
  Moreover, A associates K with NB (thus is talking about the same run).
wenzelm@61830
   625
  Other premises guarantee secrecy of K.\<close>
paulson@11251
   626
lemma YM4_imp_A_Said_YM3 [rule_format]:
wenzelm@61956
   627
     "[| Gets B \<lbrace>Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>,
wenzelm@61956
   628
                  Crypt K (Nonce NB)\<rbrace> \<in> set evs;
paulson@11251
   629
         Says B Server
wenzelm@61956
   630
           \<lbrace>Agent B, Crypt (shrK B) \<lbrace>Agent A, Nonce NA, Nonce NB\<rbrace>\<rbrace>
paulson@11251
   631
           \<in> set evs;
wenzelm@61956
   632
         (\<forall>NA k. Notes Spy \<lbrace>Nonce NA, Nonce NB, k\<rbrace> \<notin> set evs);
paulson@11251
   633
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
wenzelm@61956
   634
      ==> \<exists>X. Says A B \<lbrace>X, Crypt K (Nonce NB)\<rbrace> \<in> set evs"
paulson@32367
   635
by (metis A_Said_YM3_lemma B_gets_good_key Gets_imp_analz_Spy YM4_parts_knows_Spy analz.Fst not_parts_not_analz)
paulson@1985
   636
end