src/HOL/Auth/NS_Shared.thy
author paulson
Tue Apr 29 12:36:49 2003 +0200 (2003-04-29)
changeset 13935 4822d9597d1e
parent 13926 6e62e5357a10
child 13956 8fe7e12290e1
permissions -rw-r--r--
tweaks
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@13926
    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@13926
    23
  Fake: "\<lbrakk>evsf \<in> ns_shared;  X \<in> synth (analz (spies evsf))\<rbrakk>
paulson@13926
    24
	 \<Longrightarrow> Says Spy B X # evsf \<in> ns_shared"
paulson@11104
    25
paulson@11104
    26
	(*Alice initiates a protocol run, requesting to talk to any B*)
paulson@13926
    27
  NS1:  "\<lbrakk>evs1 \<in> ns_shared;  Nonce NA \<notin> used evs1\<rbrakk>
paulson@13926
    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@13926
    34
  NS2:  "\<lbrakk>evs2 \<in> ns_shared;  Key KAB \<notin> used evs2;
paulson@13926
    35
	  Says A' Server \<lbrace>Agent A, Agent B, Nonce NA\<rbrace> \<in> set evs2\<rbrakk>
paulson@13926
    36
	 \<Longrightarrow> Says Server A
paulson@11104
    37
	       (Crypt (shrK A)
paulson@13926
    38
		  \<lbrace>Nonce NA, Agent B, Key KAB,
paulson@13926
    39
		    (Crypt (shrK B) \<lbrace>Key KAB, Agent A\<rbrace>)\<rbrace>)
paulson@13926
    40
	       # evs2 \<in> ns_shared"
paulson@11104
    41
paulson@11104
    42
	 (*We can't assume S=Server.  Agent A "remembers" her nonce.
paulson@13926
    43
	   Need A \<noteq> Server because we allow messages to self.*)
paulson@13926
    44
  NS3:  "\<lbrakk>evs3 \<in> ns_shared;  A \<noteq> Server;
paulson@13926
    45
	  Says S A (Crypt (shrK A) \<lbrace>Nonce NA, Agent B, Key K, X\<rbrace>) \<in> set evs3;
paulson@13926
    46
	  Says A Server \<lbrace>Agent A, Agent B, Nonce NA\<rbrace> \<in> set evs3\<rbrakk>
paulson@13926
    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@13926
    51
  NS4:  "\<lbrakk>evs4 \<in> ns_shared;  Nonce NB \<notin> used evs4;
paulson@13926
    52
	  Says A' B (Crypt (shrK B) \<lbrace>Key K, Agent A\<rbrace>) \<in> set evs4\<rbrakk>
paulson@13926
    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@11465
    58
	  Letting the Spy add or subtract 1 lets him send all nonces.
paulson@11104
    59
	  Instead we distinguish the messages by sending the nonce twice.*)
paulson@13926
    60
  NS5:  "\<lbrakk>evs5 \<in> ns_shared;
paulson@13926
    61
	  Says B' A (Crypt K (Nonce NB)) \<in> set evs5;
paulson@13926
    62
	  Says S  A (Crypt (shrK A) \<lbrace>Nonce NA, Agent B, Key K, X\<rbrace>)
paulson@13926
    63
	    \<in> set evs5\<rbrakk>
paulson@13926
    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@13926
    69
  Oops: "\<lbrakk>evso \<in> ns_shared;  Says B A (Crypt K (Nonce NB)) \<in> set evso;
paulson@13926
    70
	  Says Server A (Crypt (shrK A) \<lbrace>Nonce NA, Agent B, Key K, X\<rbrace>)
paulson@13926
    71
	      \<in> set evso\<rbrakk>
paulson@13926
    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@11251
    77
declare Fake_parts_insert_in_Un  [dest]
paulson@11251
    78
declare analz_into_parts [dest]
paulson@11104
    79
declare image_eq_UN [simp]  (*accelerates proofs involving nested images*)
paulson@11104
    80
paulson@11104
    81
paulson@13926
    82
text{*A "possibility property": there are traces that reach the end*}
paulson@13926
    83
lemma "A \<noteq> Server \<Longrightarrow> \<exists>N K. \<exists>evs \<in> ns_shared.
paulson@13926
    84
                              Says A B (Crypt K \<lbrace>Nonce N, Nonce N\<rbrace>) \<in> set evs"
paulson@11104
    85
apply (intro exI bexI)
paulson@11104
    86
apply (rule_tac [2] ns_shared.Nil
paulson@11104
    87
       [THEN ns_shared.NS1, THEN ns_shared.NS2, THEN ns_shared.NS3,
paulson@13507
    88
	THEN ns_shared.NS4, THEN ns_shared.NS5], possibility)
paulson@11104
    89
done
paulson@11104
    90
paulson@11104
    91
(*This version is similar, while instantiating ?K and ?N to epsilon-terms
paulson@13926
    92
lemma "A \<noteq> Server \<Longrightarrow> \<exists>evs \<in> ns_shared.
paulson@13926
    93
                Says A B (Crypt ?K \<lbrace>Nonce ?N, Nonce ?N\<rbrace>) \<in> set evs"
paulson@11104
    94
*)
paulson@11104
    95
paulson@11104
    96
paulson@13926
    97
subsection{*Inductive proofs about @{term ns_shared}*}
paulson@11104
    98
paulson@13926
    99
subsubsection{*Forwarding lemmas, to aid simplification*}
paulson@1934
   100
paulson@13926
   101
text{*For reasoning about the encrypted portion of message NS3*}
paulson@11104
   102
lemma NS3_msg_in_parts_spies:
paulson@13926
   103
     "Says S A (Crypt KA \<lbrace>N, B, K, X\<rbrace>) \<in> set evs \<Longrightarrow> X \<in> parts (spies evs)"
paulson@11104
   104
by blast
paulson@11280
   105
paulson@13926
   106
text{*For reasoning about the Oops message*}
paulson@11104
   107
lemma Oops_parts_spies:
paulson@13926
   108
     "Says Server A (Crypt (shrK A) \<lbrace>NA, B, K, X\<rbrace>) \<in> set evs
paulson@13926
   109
            \<Longrightarrow> K \<in> parts (spies evs)"
paulson@11104
   110
by blast
paulson@11104
   111
paulson@13926
   112
text{*Theorems of the form @{term "X \<notin> parts (spies evs)"} imply that NOBODY
paulson@13926
   113
    sends messages containing @{term X}*}
paulson@11104
   114
paulson@13926
   115
text{*Spy never sees another agent's shared key! (unless it's bad at start)*}
paulson@11104
   116
lemma Spy_see_shrK [simp]:
paulson@13926
   117
     "evs \<in> ns_shared \<Longrightarrow> (Key (shrK A) \<in> parts (spies evs)) = (A \<in> bad)"
paulson@13507
   118
apply (erule ns_shared.induct, force, drule_tac [4] NS3_msg_in_parts_spies, simp_all, blast+)
paulson@11104
   119
done
paulson@11104
   120
paulson@11104
   121
lemma Spy_analz_shrK [simp]:
paulson@13926
   122
     "evs \<in> ns_shared \<Longrightarrow> (Key (shrK A) \<in> analz (spies evs)) = (A \<in> bad)"
paulson@11104
   123
by auto
paulson@11104
   124
paulson@11104
   125
paulson@13926
   126
text{*Nobody can have used non-existent keys!*}
paulson@11104
   127
lemma new_keys_not_used [rule_format, simp]:
paulson@13926
   128
    "evs \<in> ns_shared \<Longrightarrow> Key K \<notin> used evs \<longrightarrow> K \<notin> keysFor (parts (spies evs))"
paulson@13507
   129
apply (erule ns_shared.induct, force, drule_tac [4] NS3_msg_in_parts_spies, simp_all)
paulson@13926
   130
txt{*Fake, NS2, NS4, NS5*}
paulson@13926
   131
apply (force dest!: keysFor_parts_insert, blast+)
paulson@11104
   132
done
paulson@11104
   133
paulson@11104
   134
paulson@13926
   135
subsubsection{*Lemmas concerning the form of items passed in messages*}
paulson@11104
   136
paulson@13926
   137
text{*Describes the form of K, X and K' when the Server sends this message.*}
paulson@11104
   138
lemma Says_Server_message_form:
paulson@13926
   139
     "\<lbrakk>Says Server A (Crypt K' \<lbrace>N, Agent B, Key K, X\<rbrace>) \<in> set evs;
paulson@13926
   140
       evs \<in> ns_shared\<rbrakk>
paulson@13926
   141
      \<Longrightarrow> K \<notin> range shrK \<and>
paulson@13926
   142
          X = (Crypt (shrK B) \<lbrace>Key K, Agent A\<rbrace>) \<and>
paulson@11104
   143
          K' = shrK A"
paulson@11104
   144
by (erule rev_mp, erule ns_shared.induct, auto)
paulson@11104
   145
paulson@1934
   146
paulson@13926
   147
text{*If the encrypted message appears then it originated with the Server*}
paulson@11104
   148
lemma A_trusts_NS2:
paulson@13926
   149
     "\<lbrakk>Crypt (shrK A) \<lbrace>NA, Agent B, Key K, X\<rbrace> \<in> parts (spies evs);
paulson@13926
   150
       A \<notin> bad;  evs \<in> ns_shared\<rbrakk>
paulson@13926
   151
      \<Longrightarrow> Says Server A (Crypt (shrK A) \<lbrace>NA, Agent B, Key K, X\<rbrace>) \<in> set evs"
paulson@11104
   152
apply (erule rev_mp)
paulson@13507
   153
apply (erule ns_shared.induct, force, drule_tac [4] NS3_msg_in_parts_spies, auto)
paulson@11104
   154
done
paulson@11104
   155
paulson@11104
   156
lemma cert_A_form:
paulson@13926
   157
     "\<lbrakk>Crypt (shrK A) \<lbrace>NA, Agent B, Key K, X\<rbrace> \<in> parts (spies evs);
paulson@13926
   158
       A \<notin> bad;  evs \<in> ns_shared\<rbrakk>
paulson@13926
   159
      \<Longrightarrow> K \<notin> range shrK \<and>  X = (Crypt (shrK B) \<lbrace>Key K, Agent A\<rbrace>)"
paulson@11104
   160
by (blast dest!: A_trusts_NS2 Says_Server_message_form)
paulson@11104
   161
paulson@11104
   162
(*EITHER describes the form of X when the following message is sent,
paulson@11104
   163
  OR     reduces it to the Fake case.
paulson@11104
   164
  Use Says_Server_message_form if applicable.*)
paulson@11104
   165
lemma Says_S_message_form:
paulson@13926
   166
     "\<lbrakk>Says S A (Crypt (shrK A) \<lbrace>Nonce NA, Agent B, Key K, X\<rbrace>) \<in> set evs;
paulson@13926
   167
       evs \<in> ns_shared\<rbrakk>
paulson@13926
   168
      \<Longrightarrow> (K \<notin> range shrK \<and> X = (Crypt (shrK B) \<lbrace>Key K, Agent A\<rbrace>))
paulson@13926
   169
          \<or> X \<in> analz (spies evs)"
paulson@11150
   170
by (blast dest: Says_imp_knows_Spy cert_A_form analz.Inj)
paulson@11150
   171
paulson@11104
   172
paulson@11104
   173
(*Alternative version also provable
paulson@11104
   174
lemma Says_S_message_form2:
paulson@13926
   175
  "\<lbrakk>Says S A (Crypt (shrK A) \<lbrace>Nonce NA, Agent B, Key K, X\<rbrace>) \<in> set evs;
paulson@13926
   176
    evs \<in> ns_shared\<rbrakk>
paulson@13926
   177
   \<Longrightarrow> Says Server A (Crypt (shrK A) \<lbrace>Nonce NA, Agent B, Key K, X\<rbrace>) \<in> set evs
paulson@13926
   178
       \<or> X \<in> analz (spies evs)"
paulson@13926
   179
apply (case_tac "A \<in> bad")
paulson@13507
   180
apply (force dest!: Says_imp_knows_Spy [THEN analz.Inj])
paulson@11104
   181
by (blast dest!: A_trusts_NS2 Says_Server_message_form)
paulson@11104
   182
*)
paulson@11104
   183
paulson@11104
   184
paulson@11104
   185
(****
paulson@11104
   186
 SESSION KEY COMPROMISE THEOREM.  To prove theorems of the form
paulson@11104
   187
paulson@13926
   188
  Key K \<in> analz (insert (Key KAB) (spies evs)) \<Longrightarrow>
paulson@13926
   189
  Key K \<in> analz (spies evs)
paulson@11104
   190
paulson@11104
   191
 A more general formula must be proved inductively.
paulson@11104
   192
****)
paulson@1934
   193
paulson@13926
   194
text{*NOT useful in this form, but it says that session keys are not used
paulson@11104
   195
  to encrypt messages containing other keys, in the actual protocol.
paulson@13926
   196
  We require that agents should behave like this subsequently also.*}
paulson@13926
   197
lemma  "\<lbrakk>evs \<in> ns_shared;  Kab \<notin> range shrK\<rbrakk> \<Longrightarrow>
paulson@13926
   198
         (Crypt KAB X) \<in> parts (spies evs) \<and>
paulson@13926
   199
         Key K \<in> parts {X} \<longrightarrow> Key K \<in> parts (spies evs)"
paulson@13507
   200
apply (erule ns_shared.induct, force, drule_tac [4] NS3_msg_in_parts_spies, simp_all)
paulson@13926
   201
txt{*Fake*}
paulson@11104
   202
apply (blast dest: parts_insert_subset_Un)
paulson@13926
   203
txt{*Base, NS4 and NS5*}
paulson@11104
   204
apply auto
paulson@11104
   205
done
paulson@11104
   206
paulson@11104
   207
paulson@13926
   208
subsubsection{*Session keys are not used to encrypt other session keys*}
paulson@11104
   209
paulson@13926
   210
text{*The equality makes the induction hypothesis easier to apply*}
paulson@11104
   211
paulson@11104
   212
lemma analz_image_freshK [rule_format]:
paulson@13926
   213
 "evs \<in> ns_shared \<Longrightarrow>
paulson@13926
   214
   \<forall>K KK. KK \<subseteq> - (range shrK) \<longrightarrow>
paulson@13926
   215
             (Key K \<in> analz (Key`KK \<union> (spies evs))) =
paulson@13926
   216
             (K \<in> KK \<or> Key K \<in> analz (spies evs))"
paulson@11104
   217
apply (erule ns_shared.induct, force)
paulson@11280
   218
apply (drule_tac [7] Says_Server_message_form)
paulson@13507
   219
apply (erule_tac [4] Says_S_message_form [THEN disjE], analz_freshK, spy_analz)
paulson@11104
   220
done
paulson@11104
   221
paulson@11104
   222
paulson@11104
   223
lemma analz_insert_freshK:
paulson@13926
   224
     "\<lbrakk>evs \<in> ns_shared;  KAB \<notin> range shrK\<rbrakk> \<Longrightarrow>
paulson@13926
   225
       (Key K \<in> analz (insert (Key KAB) (spies evs))) =
paulson@13926
   226
       (K = KAB \<or> Key K \<in> analz (spies evs))"
paulson@11104
   227
by (simp only: analz_image_freshK analz_image_freshK_simps)
paulson@11104
   228
paulson@11104
   229
paulson@13926
   230
subsubsection{*The session key K uniquely identifies the message*}
paulson@1934
   231
paulson@13926
   232
text{*In messages of this form, the session key uniquely identifies the rest*}
paulson@11104
   233
lemma unique_session_keys:
paulson@13926
   234
     "\<lbrakk>Says Server A (Crypt (shrK A) \<lbrace>NA, Agent B, Key K, X\<rbrace>) \<in> set evs;
paulson@13926
   235
       Says Server A' (Crypt (shrK A') \<lbrace>NA', Agent B', Key K, X'\<rbrace>) \<in> set evs;
paulson@13926
   236
       evs \<in> ns_shared\<rbrakk> \<Longrightarrow> A=A' \<and> NA=NA' \<and> B=B' \<and> X = X'"
paulson@13507
   237
apply (erule rev_mp, erule rev_mp, erule ns_shared.induct, simp_all, blast+)
paulson@11104
   238
done
paulson@11104
   239
paulson@11104
   240
paulson@13926
   241
subsubsection{*Crucial secrecy property: Spy does not see the keys sent in msg NS2*}
paulson@11104
   242
paulson@13926
   243
text{*Beware of [rule_format] and the universal quantifier!*}
paulson@11150
   244
lemma secrecy_lemma:
paulson@13926
   245
     "\<lbrakk>Says Server A (Crypt (shrK A) \<lbrace>NA, Agent B, Key K,
paulson@13926
   246
                                      Crypt (shrK B) \<lbrace>Key K, Agent A\<rbrace>\<rbrace>)
paulson@13926
   247
              \<in> set evs;
paulson@13926
   248
         A \<notin> bad;  B \<notin> bad;  evs \<in> ns_shared\<rbrakk>
paulson@13926
   249
      \<Longrightarrow> (\<forall>NB. Notes Spy \<lbrace>NA, NB, Key K\<rbrace> \<notin> set evs) \<longrightarrow>
paulson@13926
   250
         Key K \<notin> analz (spies evs)"
paulson@11104
   251
apply (erule rev_mp)
paulson@11104
   252
apply (erule ns_shared.induct, force)
paulson@11104
   253
apply (frule_tac [7] Says_Server_message_form)
paulson@11104
   254
apply (frule_tac [4] Says_S_message_form)
paulson@11104
   255
apply (erule_tac [5] disjE)
paulson@13926
   256
apply (simp_all add: analz_insert_eq analz_insert_freshK pushes split_ifs, spy_analz)  
paulson@13926
   257
txt{*NS2*}
paulson@13926
   258
apply blast
paulson@13926
   259
txt{*NS3, Server sub-case*} 
paulson@11188
   260
apply (blast dest!: Crypt_Spy_analz_bad A_trusts_NS2
paulson@11188
   261
	     dest:  Says_imp_knows_Spy analz.Inj unique_session_keys)
paulson@13926
   262
txt{*NS3, Spy sub-case; also Oops*}
paulson@11280
   263
apply (blast dest: unique_session_keys)+
paulson@11104
   264
done
paulson@11104
   265
paulson@11104
   266
paulson@11188
   267
paulson@13926
   268
text{*Final version: Server's message in the most abstract form*}
paulson@11104
   269
lemma Spy_not_see_encrypted_key:
paulson@13926
   270
     "\<lbrakk>Says Server A (Crypt K' \<lbrace>NA, Agent B, Key K, X\<rbrace>) \<in> set evs;
paulson@13926
   271
       \<forall>NB. Notes Spy \<lbrace>NA, NB, Key K\<rbrace> \<notin> set evs;
paulson@13926
   272
       A \<notin> bad;  B \<notin> bad;  evs \<in> ns_shared\<rbrakk>
paulson@13926
   273
      \<Longrightarrow> Key K \<notin> analz (spies evs)"
paulson@11150
   274
by (blast dest: Says_Server_message_form secrecy_lemma)
paulson@11104
   275
paulson@11104
   276
paulson@13926
   277
subsection{*Guarantees available at various stages of protocol*}
paulson@1934
   278
paulson@13926
   279
text{*If the encrypted message appears then it originated with the Server*}
paulson@11104
   280
lemma B_trusts_NS3:
paulson@13926
   281
     "\<lbrakk>Crypt (shrK B) \<lbrace>Key K, Agent A\<rbrace> \<in> parts (spies evs);
paulson@13926
   282
       B \<notin> bad;  evs \<in> ns_shared\<rbrakk>
paulson@13926
   283
      \<Longrightarrow> \<exists>NA. Says Server A
paulson@13926
   284
               (Crypt (shrK A) \<lbrace>NA, Agent B, Key K,
paulson@13926
   285
                                 Crypt (shrK B) \<lbrace>Key K, Agent A\<rbrace>\<rbrace>)
paulson@13926
   286
              \<in> set evs"
paulson@11104
   287
apply (erule rev_mp)
paulson@13507
   288
apply (erule ns_shared.induct, force, drule_tac [4] NS3_msg_in_parts_spies, auto)
paulson@11104
   289
done
paulson@11104
   290
paulson@11104
   291
paulson@11104
   292
lemma A_trusts_NS4_lemma [rule_format]:
paulson@13926
   293
   "evs \<in> ns_shared \<Longrightarrow>
paulson@13926
   294
      Key K \<notin> analz (spies evs) \<longrightarrow>
paulson@13926
   295
      Says Server A (Crypt (shrK A) \<lbrace>NA, Agent B, Key K, X\<rbrace>) \<in> set evs \<longrightarrow>
paulson@13926
   296
      Crypt K (Nonce NB) \<in> parts (spies evs) \<longrightarrow>
paulson@13926
   297
      Says B A (Crypt K (Nonce NB)) \<in> set evs"
paulson@11104
   298
apply (erule ns_shared.induct, force, drule_tac [4] NS3_msg_in_parts_spies)
paulson@13926
   299
apply (analz_mono_contra, simp_all, blast) 
paulson@11280
   300
(*NS2: contradiction from the assumptions
paulson@13926
   301
  Key K \<notin> used evs2  and Crypt K (Nonce NB) \<in> parts (spies evs2) *)
paulson@13926
   302
apply (force dest!: Crypt_imp_keysFor)     
paulson@13926
   303
txt{*NS3*}
paulson@13926
   304
apply blast 
paulson@13935
   305
txt{*NS4*} 
paulson@13935
   306
apply (blast dest: B_trusts_NS3
paulson@13935
   307
	           Says_imp_knows_Spy [THEN analz.Inj]
paulson@11150
   308
                   Crypt_Spy_analz_bad unique_session_keys)
paulson@11104
   309
done
paulson@11104
   310
paulson@13926
   311
text{*This version no longer assumes that K is secure*}
paulson@11104
   312
lemma A_trusts_NS4:
paulson@13926
   313
     "\<lbrakk>Crypt K (Nonce NB) \<in> parts (spies evs);
paulson@13926
   314
       Crypt (shrK A) \<lbrace>NA, Agent B, Key K, X\<rbrace> \<in> parts (spies evs);
paulson@13926
   315
       \<forall>NB. Notes Spy \<lbrace>NA, NB, Key K\<rbrace> \<notin> set evs;
paulson@13926
   316
       A \<notin> bad;  B \<notin> bad;  evs \<in> ns_shared\<rbrakk>
paulson@13926
   317
      \<Longrightarrow> Says B A (Crypt K (Nonce NB)) \<in> set evs"
paulson@11280
   318
by (blast intro: A_trusts_NS4_lemma
paulson@11104
   319
          dest: A_trusts_NS2 Spy_not_see_encrypted_key)
paulson@11104
   320
paulson@11104
   321
(*If the session key has been used in NS4 then somebody has forwarded
paulson@11280
   322
  component X in some instance of NS4.  Perhaps an interesting property,
paulson@11104
   323
  but not needed (after all) for the proofs below.*)
paulson@11104
   324
theorem NS4_implies_NS3 [rule_format]:
paulson@13926
   325
  "evs \<in> ns_shared \<Longrightarrow>
paulson@13926
   326
     Key K \<notin> analz (spies evs) \<longrightarrow>
paulson@13926
   327
     Says Server A (Crypt (shrK A) \<lbrace>NA, Agent B, Key K, X\<rbrace>) \<in> set evs \<longrightarrow>
paulson@13926
   328
     Crypt K (Nonce NB) \<in> parts (spies evs) \<longrightarrow>
paulson@13926
   329
     (\<exists>A'. Says A' B X \<in> set evs)"
paulson@13507
   330
apply (erule ns_shared.induct, force, drule_tac [4] NS3_msg_in_parts_spies, analz_mono_contra)
paulson@13926
   331
apply (simp_all add: ex_disj_distrib, blast)
paulson@13926
   332
txt{*NS2*}
paulson@13926
   333
apply (blast dest!: new_keys_not_used Crypt_imp_keysFor)  
paulson@13926
   334
txt{*NS3*}
paulson@13926
   335
apply blast
paulson@13926
   336
txt{*NS4*}
paulson@13935
   337
apply (blast dest: B_trusts_NS3
paulson@11280
   338
	     dest: Says_imp_knows_Spy [THEN analz.Inj]
paulson@11150
   339
                   unique_session_keys Crypt_Spy_analz_bad)
paulson@11104
   340
done
paulson@11104
   341
paulson@11104
   342
paulson@11104
   343
lemma B_trusts_NS5_lemma [rule_format]:
paulson@13926
   344
  "\<lbrakk>B \<notin> bad;  evs \<in> ns_shared\<rbrakk> \<Longrightarrow>
paulson@13926
   345
     Key K \<notin> analz (spies evs) \<longrightarrow>
paulson@11104
   346
     Says Server A
paulson@13926
   347
	  (Crypt (shrK A) \<lbrace>NA, Agent B, Key K,
paulson@13926
   348
			    Crypt (shrK B) \<lbrace>Key K, Agent A\<rbrace>\<rbrace>) \<in> set evs \<longrightarrow>
paulson@13926
   349
     Crypt K \<lbrace>Nonce NB, Nonce NB\<rbrace> \<in> parts (spies evs) \<longrightarrow>
paulson@13926
   350
     Says A B (Crypt K \<lbrace>Nonce NB, Nonce NB\<rbrace>) \<in> set evs"
paulson@13926
   351
apply (erule ns_shared.induct, force, drule_tac [4] NS3_msg_in_parts_spies, analz_mono_contra, simp_all, blast)
paulson@13926
   352
txt{*NS2*}
paulson@13926
   353
apply (blast dest!: new_keys_not_used Crypt_imp_keysFor)  
paulson@13926
   354
txt{*NS3*}
paulson@13926
   355
apply (blast dest!: cert_A_form) 
paulson@13926
   356
txt{*NS5*}
paulson@11150
   357
apply (blast dest!: A_trusts_NS2
paulson@11280
   358
	     dest: Says_imp_knows_Spy [THEN analz.Inj]
paulson@11150
   359
                   unique_session_keys Crypt_Spy_analz_bad)
paulson@11104
   360
done
paulson@11104
   361
paulson@11104
   362
paulson@13926
   363
text{*Very strong Oops condition reveals protocol's weakness*}
paulson@11104
   364
lemma B_trusts_NS5:
paulson@13926
   365
     "\<lbrakk>Crypt K \<lbrace>Nonce NB, Nonce NB\<rbrace> \<in> parts (spies evs);
paulson@13926
   366
       Crypt (shrK B) \<lbrace>Key K, Agent A\<rbrace> \<in> parts (spies evs);
paulson@13926
   367
       \<forall>NA NB. Notes Spy \<lbrace>NA, NB, Key K\<rbrace> \<notin> set evs;
paulson@13926
   368
       A \<notin> bad;  B \<notin> bad;  evs \<in> ns_shared\<rbrakk>
paulson@13926
   369
      \<Longrightarrow> Says A B (Crypt K \<lbrace>Nonce NB, Nonce NB\<rbrace>) \<in> set evs"
paulson@11280
   370
by (blast intro: B_trusts_NS5_lemma
paulson@11150
   371
          dest: B_trusts_NS3 Spy_not_see_encrypted_key)
paulson@1934
   372
paulson@1934
   373
end