src/HOL/Auth/NS_Shared.thy
author paulson
Sat Aug 17 14:55:08 2002 +0200 (2002-08-17)
changeset 13507 febb8e5d2a9d
parent 11655 923e4d0d36d5
child 13926 6e62e5357a10
permissions -rw-r--r--
tidying of Isar scripts
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@11465
    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@11465
    23
  Fake: "\\<lbrakk>evsf \\<in> ns_shared;  X \\<in> synth (analz (spies evsf))\\<rbrakk>
paulson@11465
    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@11465
    27
  NS1:  "\\<lbrakk>evs1 \\<in> ns_shared;  Nonce NA \\<notin> used evs1\\<rbrakk>
paulson@11465
    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@11465
    34
  NS2:  "\\<lbrakk>evs2 \\<in> ns_shared;  Key KAB \\<notin> used evs2;
paulson@11465
    35
	  Says A' Server \\<lbrace>Agent A, Agent B, Nonce NA\\<rbrace> \\<in> set evs2\\<rbrakk>
paulson@11465
    36
	 \\<Longrightarrow> Says Server A
paulson@11104
    37
	       (Crypt (shrK A)
paulson@11465
    38
		  \\<lbrace>Nonce NA, Agent B, Key KAB,
paulson@11465
    39
		    (Crypt (shrK B) \\<lbrace>Key KAB, Agent A\\<rbrace>)\\<rbrace>)
paulson@11465
    40
	       # evs2 \\<in> ns_shared"
paulson@11104
    41
paulson@11104
    42
	 (*We can't assume S=Server.  Agent A "remembers" her nonce.
paulson@11465
    43
	   Need A \\<noteq> Server because we allow messages to self.*)
paulson@11465
    44
  NS3:  "\\<lbrakk>evs3 \\<in> ns_shared;  A \\<noteq> Server;
paulson@11465
    45
	  Says S A (Crypt (shrK A) \\<lbrace>Nonce NA, Agent B, Key K, X\\<rbrace>) \\<in> set evs3;
paulson@11465
    46
	  Says A Server \\<lbrace>Agent A, Agent B, Nonce NA\\<rbrace> \\<in> set evs3\\<rbrakk>
paulson@11465
    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@11465
    51
  NS4:  "\\<lbrakk>evs4 \\<in> ns_shared;  Nonce NB \\<notin> used evs4;
paulson@11465
    52
	  Says A' B (Crypt (shrK B) \\<lbrace>Key K, Agent A\\<rbrace>) \\<in> set evs4\\<rbrakk>
paulson@11465
    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@11465
    60
  NS5:  "\\<lbrakk>evs5 \\<in> ns_shared;
paulson@11465
    61
	  Says B' A (Crypt K (Nonce NB)) \\<in> set evs5;
paulson@11465
    62
	  Says S  A (Crypt (shrK A) \\<lbrace>Nonce NA, Agent B, Key K, X\\<rbrace>)
paulson@11465
    63
	    \\<in> set evs5\\<rbrakk>
paulson@11465
    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@11465
    69
  Oops: "\\<lbrakk>evso \\<in> ns_shared;  Says B A (Crypt K (Nonce NB)) \\<in> set evso;
paulson@11465
    70
	  Says Server A (Crypt (shrK A) \\<lbrace>Nonce NA, Agent B, Key K, X\\<rbrace>)
paulson@11465
    71
	      \\<in> set evso\\<rbrakk>
paulson@11465
    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@11104
    82
(*A "possibility property": there are traces that reach the end*)
paulson@11465
    83
lemma "A \\<noteq> Server \\<Longrightarrow> \\<exists>N K. \\<exists>evs \\<in> ns_shared.
paulson@11465
    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@11465
    92
lemma "A \\<noteq> Server \\<Longrightarrow> \\<exists>evs \\<in> ns_shared.
paulson@11465
    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@11104
    97
(**** Inductive proofs about ns_shared ****)
paulson@11104
    98
paulson@11280
    99
(** Forwarding lemmas, to aid simplification **)
paulson@1934
   100
paulson@11104
   101
(*For reasoning about the encrypted portion of message NS3*)
paulson@11104
   102
lemma NS3_msg_in_parts_spies:
paulson@11465
   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@11104
   106
(*For reasoning about the Oops message*)
paulson@11104
   107
lemma Oops_parts_spies:
paulson@11465
   108
     "Says Server A (Crypt (shrK A) \\<lbrace>NA, B, K, X\\<rbrace>) \\<in> set evs
paulson@11465
   109
            \\<Longrightarrow> K \\<in> parts (spies evs)"
paulson@11104
   110
by blast
paulson@11104
   111
paulson@11465
   112
(** Theorems of the form X \\<notin> parts (spies evs) imply that NOBODY
paulson@11104
   113
    sends messages containing X! **)
paulson@11104
   114
paulson@11104
   115
(*Spy never sees another agent's shared key! (unless it's bad at start)*)
paulson@11104
   116
lemma Spy_see_shrK [simp]:
paulson@11465
   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@11465
   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@11104
   126
(*Nobody can have used non-existent keys!*)
paulson@11104
   127
lemma new_keys_not_used [rule_format, simp]:
paulson@11465
   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@11104
   130
(*Fake, NS2, NS4, NS5*)
paulson@11104
   131
apply (blast dest!: keysFor_parts_insert)+
paulson@11104
   132
done
paulson@11104
   133
paulson@11104
   134
paulson@11104
   135
(** Lemmas concerning the form of items passed in messages **)
paulson@11104
   136
paulson@11104
   137
(*Describes the form of K, X and K' when the Server sends this message.*)
paulson@11104
   138
lemma Says_Server_message_form:
paulson@11465
   139
     "\\<lbrakk>Says Server A (Crypt K' \\<lbrace>N, Agent B, Key K, X\\<rbrace>) \\<in> set evs;
paulson@11465
   140
       evs \\<in> ns_shared\\<rbrakk>
paulson@11465
   141
      \\<Longrightarrow> K \\<notin> range shrK \\<and>
paulson@11465
   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@11104
   147
(*If the encrypted message appears then it originated with the Server*)
paulson@11104
   148
lemma A_trusts_NS2:
paulson@11465
   149
     "\\<lbrakk>Crypt (shrK A) \\<lbrace>NA, Agent B, Key K, X\\<rbrace> \\<in> parts (spies evs);
paulson@11465
   150
       A \\<notin> bad;  evs \\<in> ns_shared\\<rbrakk>
paulson@11465
   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@11465
   157
     "\\<lbrakk>Crypt (shrK A) \\<lbrace>NA, Agent B, Key K, X\\<rbrace> \\<in> parts (spies evs);
paulson@11465
   158
       A \\<notin> bad;  evs \\<in> ns_shared\\<rbrakk>
paulson@11465
   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@11465
   166
     "\\<lbrakk>Says S A (Crypt (shrK A) \\<lbrace>Nonce NA, Agent B, Key K, X\\<rbrace>) \\<in> set evs;
paulson@11465
   167
       evs \\<in> ns_shared\\<rbrakk>
paulson@11465
   168
      \\<Longrightarrow> (K \\<notin> range shrK \\<and> X = (Crypt (shrK B) \\<lbrace>Key K, Agent A\\<rbrace>))
paulson@11465
   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@11465
   175
  "\\<lbrakk>Says S A (Crypt (shrK A) \\<lbrace>Nonce NA, Agent B, Key K, X\\<rbrace>) \\<in> set evs;
paulson@11465
   176
    evs \\<in> ns_shared\\<rbrakk>
paulson@11465
   177
   \\<Longrightarrow> Says Server A (Crypt (shrK A) \\<lbrace>Nonce NA, Agent B, Key K, X\\<rbrace>) \\<in> set evs
paulson@11465
   178
       \\<or> X \\<in> analz (spies evs)"
paulson@11465
   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@11465
   188
  Key K \\<in> analz (insert (Key KAB) (spies evs)) \\<Longrightarrow>
paulson@11465
   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@11104
   194
(*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@11104
   196
  We require that agents should behave like this subsequently also.*)
paulson@11465
   197
lemma  "\\<lbrakk>evs \\<in> ns_shared;  Kab \\<notin> range shrK\\<rbrakk> \\<Longrightarrow>
paulson@11465
   198
         (Crypt KAB X) \\<in> parts (spies evs) \\<and>
paulson@11465
   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@11104
   201
(*Fake*)
paulson@11104
   202
apply (blast dest: parts_insert_subset_Un)
paulson@11104
   203
(*Base, NS4 and NS5*)
paulson@11104
   204
apply auto
paulson@11104
   205
done
paulson@11104
   206
paulson@11104
   207
paulson@11104
   208
(** Session keys are not used to encrypt other session keys **)
paulson@11104
   209
paulson@11104
   210
(*The equality makes the induction hypothesis easier to apply*)
paulson@11104
   211
paulson@11104
   212
lemma analz_image_freshK [rule_format]:
paulson@11465
   213
 "evs \\<in> ns_shared \\<Longrightarrow>
paulson@11465
   214
   \\<forall>K KK. KK \\<subseteq> - (range shrK) \\<longrightarrow>
paulson@11465
   215
             (Key K \\<in> analz (Key`KK \\<union> (spies evs))) =
paulson@11465
   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@11465
   224
     "\\<lbrakk>evs \\<in> ns_shared;  KAB \\<notin> range shrK\\<rbrakk> \\<Longrightarrow>
wenzelm@11655
   225
       (Key K \\<in> analz (insert (Key KAB) (spies evs))) =
paulson@11465
   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@11104
   230
(** The session key K uniquely identifies the message **)
paulson@1934
   231
paulson@11104
   232
(*In messages of this form, the session key uniquely identifies the rest*)
paulson@11104
   233
lemma unique_session_keys:
paulson@11465
   234
     "\\<lbrakk>Says Server A (Crypt (shrK A) \\<lbrace>NA, Agent B, Key K, X\\<rbrace>) \\<in> set evs;
paulson@11465
   235
       Says Server A' (Crypt (shrK A') \\<lbrace>NA', Agent B', Key K, X'\\<rbrace>) \\<in> set evs;
paulson@11465
   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@11104
   241
(** Crucial secrecy property: Spy does not see the keys sent in msg NS2 **)
paulson@11104
   242
paulson@11150
   243
(*Beware of [rule_format] and the universal quantifier!*)
paulson@11150
   244
lemma secrecy_lemma:
paulson@11465
   245
     "\\<lbrakk>Says Server A (Crypt (shrK A) \\<lbrace>NA, Agent B, Key K,
paulson@11465
   246
                                      Crypt (shrK B) \\<lbrace>Key K, Agent A\\<rbrace>\\<rbrace>)
paulson@11465
   247
              \\<in> set evs;
paulson@11465
   248
         A \\<notin> bad;  B \\<notin> bad;  evs \\<in> ns_shared\\<rbrakk>
paulson@11465
   249
      \\<Longrightarrow> (\\<forall>NB. Notes Spy \\<lbrace>NA, NB, Key K\\<rbrace> \\<notin> set evs) \\<longrightarrow>
paulson@11465
   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@13507
   256
apply (simp_all add: analz_insert_eq analz_insert_freshK pushes split_ifs, spy_analz)  (*Fake*)
paulson@11104
   257
apply blast      (*NS2*)
paulson@11188
   258
(*NS3, Server sub-case*) (**LEVEL 8 **)
paulson@11188
   259
apply (blast dest!: Crypt_Spy_analz_bad A_trusts_NS2
paulson@11188
   260
	     dest:  Says_imp_knows_Spy analz.Inj unique_session_keys)
paulson@11280
   261
(*NS3, Spy sub-case; also Oops*)
paulson@11280
   262
apply (blast dest: unique_session_keys)+
paulson@11104
   263
done
paulson@11104
   264
paulson@11104
   265
paulson@11188
   266
paulson@11104
   267
(*Final version: Server's message in the most abstract form*)
paulson@11104
   268
lemma Spy_not_see_encrypted_key:
paulson@11465
   269
     "\\<lbrakk>Says Server A (Crypt K' \\<lbrace>NA, Agent B, Key K, X\\<rbrace>) \\<in> set evs;
paulson@11465
   270
       \\<forall>NB. Notes Spy \\<lbrace>NA, NB, Key K\\<rbrace> \\<notin> set evs;
paulson@11465
   271
       A \\<notin> bad;  B \\<notin> bad;  evs \\<in> ns_shared\\<rbrakk>
paulson@11465
   272
      \\<Longrightarrow> Key K \\<notin> analz (spies evs)"
paulson@11150
   273
by (blast dest: Says_Server_message_form secrecy_lemma)
paulson@11104
   274
paulson@11104
   275
paulson@11104
   276
(**** Guarantees available at various stages of protocol ***)
paulson@1934
   277
paulson@11104
   278
(*If the encrypted message appears then it originated with the Server*)
paulson@11104
   279
lemma B_trusts_NS3:
paulson@11465
   280
     "\\<lbrakk>Crypt (shrK B) \\<lbrace>Key K, Agent A\\<rbrace> \\<in> parts (spies evs);
paulson@11465
   281
       B \\<notin> bad;  evs \\<in> ns_shared\\<rbrakk>
paulson@11465
   282
      \\<Longrightarrow> \\<exists>NA. Says Server A
paulson@11465
   283
               (Crypt (shrK A) \\<lbrace>NA, Agent B, Key K,
paulson@11465
   284
                                 Crypt (shrK B) \\<lbrace>Key K, Agent A\\<rbrace>\\<rbrace>)
paulson@11465
   285
              \\<in> set evs"
paulson@11104
   286
apply (erule rev_mp)
paulson@13507
   287
apply (erule ns_shared.induct, force, drule_tac [4] NS3_msg_in_parts_spies, auto)
paulson@11104
   288
done
paulson@11104
   289
paulson@11104
   290
paulson@11104
   291
lemma A_trusts_NS4_lemma [rule_format]:
paulson@11465
   292
   "evs \\<in> ns_shared \\<Longrightarrow>
paulson@11465
   293
      Key K \\<notin> analz (spies evs) \\<longrightarrow>
paulson@11465
   294
      Says Server A (Crypt (shrK A) \\<lbrace>NA, Agent B, Key K, X\\<rbrace>) \\<in> set evs \\<longrightarrow>
paulson@11465
   295
      Crypt K (Nonce NB) \\<in> parts (spies evs) \\<longrightarrow>
paulson@11465
   296
      Says B A (Crypt K (Nonce NB)) \\<in> set evs"
paulson@11104
   297
apply (erule ns_shared.induct, force, drule_tac [4] NS3_msg_in_parts_spies)
paulson@13507
   298
apply (analz_mono_contra, simp_all, blast)     (*Fake*)
paulson@11280
   299
(*NS2: contradiction from the assumptions
paulson@11465
   300
  Key K \\<notin> used evs2  and Crypt K (Nonce NB) \\<in> parts (spies evs2) *)
paulson@13507
   301
apply (force dest!: Crypt_imp_keysFor, blast)     (*NS3*)
paulson@11104
   302
(*NS4*)
paulson@11150
   303
apply (blast dest!: B_trusts_NS3
paulson@11280
   304
	     dest: Says_imp_knows_Spy [THEN analz.Inj]
paulson@11150
   305
                   Crypt_Spy_analz_bad unique_session_keys)
paulson@11104
   306
done
paulson@11104
   307
paulson@11104
   308
(*This version no longer assumes that K is secure*)
paulson@11104
   309
lemma A_trusts_NS4:
paulson@11465
   310
     "\\<lbrakk>Crypt K (Nonce NB) \\<in> parts (spies evs);
paulson@11465
   311
       Crypt (shrK A) \\<lbrace>NA, Agent B, Key K, X\\<rbrace> \\<in> parts (spies evs);
paulson@11465
   312
       \\<forall>NB. Notes Spy \\<lbrace>NA, NB, Key K\\<rbrace> \\<notin> set evs;
paulson@11465
   313
       A \\<notin> bad;  B \\<notin> bad;  evs \\<in> ns_shared\\<rbrakk>
paulson@11465
   314
      \\<Longrightarrow> Says B A (Crypt K (Nonce NB)) \\<in> set evs"
paulson@11280
   315
by (blast intro: A_trusts_NS4_lemma
paulson@11104
   316
          dest: A_trusts_NS2 Spy_not_see_encrypted_key)
paulson@11104
   317
paulson@11104
   318
(*If the session key has been used in NS4 then somebody has forwarded
paulson@11280
   319
  component X in some instance of NS4.  Perhaps an interesting property,
paulson@11104
   320
  but not needed (after all) for the proofs below.*)
paulson@11104
   321
theorem NS4_implies_NS3 [rule_format]:
paulson@11465
   322
  "evs \\<in> ns_shared \\<Longrightarrow>
paulson@11465
   323
     Key K \\<notin> analz (spies evs) \\<longrightarrow>
paulson@11465
   324
     Says Server A (Crypt (shrK A) \\<lbrace>NA, Agent B, Key K, X\\<rbrace>) \\<in> set evs \\<longrightarrow>
paulson@11465
   325
     Crypt K (Nonce NB) \\<in> parts (spies evs) \\<longrightarrow>
paulson@11465
   326
     (\\<exists>A'. Says A' B X \\<in> set evs)"
paulson@13507
   327
apply (erule ns_shared.induct, force, drule_tac [4] NS3_msg_in_parts_spies, analz_mono_contra)
paulson@13507
   328
apply (simp_all add: ex_disj_distrib, blast)  (*Fake*)
paulson@11104
   329
apply (blast dest!: new_keys_not_used Crypt_imp_keysFor)  (*NS2*)
paulson@11104
   330
apply blast  (*NS3*)
paulson@11104
   331
(*NS4*)
paulson@11150
   332
apply (blast dest!: B_trusts_NS3
paulson@11280
   333
	     dest: Says_imp_knows_Spy [THEN analz.Inj]
paulson@11150
   334
                   unique_session_keys Crypt_Spy_analz_bad)
paulson@11104
   335
done
paulson@11104
   336
paulson@11104
   337
paulson@11104
   338
lemma B_trusts_NS5_lemma [rule_format]:
paulson@11465
   339
  "\\<lbrakk>B \\<notin> bad;  evs \\<in> ns_shared\\<rbrakk> \\<Longrightarrow>
paulson@11465
   340
     Key K \\<notin> analz (spies evs) \\<longrightarrow>
paulson@11104
   341
     Says Server A
paulson@11465
   342
	  (Crypt (shrK A) \\<lbrace>NA, Agent B, Key K,
paulson@11465
   343
			    Crypt (shrK B) \\<lbrace>Key K, Agent A\\<rbrace>\\<rbrace>) \\<in> set evs \\<longrightarrow>
paulson@11465
   344
     Crypt K \\<lbrace>Nonce NB, Nonce NB\\<rbrace> \\<in> parts (spies evs) \\<longrightarrow>
paulson@11465
   345
     Says A B (Crypt K \\<lbrace>Nonce NB, Nonce NB\\<rbrace>) \\<in> set evs"
paulson@13507
   346
apply (erule ns_shared.induct, force, drule_tac [4] NS3_msg_in_parts_spies, analz_mono_contra, simp_all, blast)  (*Fake*)
paulson@11104
   347
apply (blast dest!: new_keys_not_used Crypt_imp_keysFor)  (*NS2*)
paulson@11104
   348
apply (blast dest!: cert_A_form) (*NS3*)
paulson@11104
   349
(*NS5*)
paulson@11150
   350
apply (blast dest!: A_trusts_NS2
paulson@11280
   351
	     dest: Says_imp_knows_Spy [THEN analz.Inj]
paulson@11150
   352
                   unique_session_keys Crypt_Spy_analz_bad)
paulson@11104
   353
done
paulson@11104
   354
paulson@11104
   355
paulson@11104
   356
(*Very strong Oops condition reveals protocol's weakness*)
paulson@11104
   357
lemma B_trusts_NS5:
paulson@11465
   358
     "\\<lbrakk>Crypt K \\<lbrace>Nonce NB, Nonce NB\\<rbrace> \\<in> parts (spies evs);
paulson@11465
   359
       Crypt (shrK B) \\<lbrace>Key K, Agent A\\<rbrace> \\<in> parts (spies evs);
paulson@11465
   360
       \\<forall>NA NB. Notes Spy \\<lbrace>NA, NB, Key K\\<rbrace> \\<notin> set evs;
paulson@11465
   361
       A \\<notin> bad;  B \\<notin> bad;  evs \\<in> ns_shared\\<rbrakk>
paulson@11465
   362
      \\<Longrightarrow> Says A B (Crypt K \\<lbrace>Nonce NB, Nonce NB\\<rbrace>) \\<in> set evs"
paulson@11280
   363
by (blast intro: B_trusts_NS5_lemma
paulson@11150
   364
          dest: B_trusts_NS3 Spy_not_see_encrypted_key)
paulson@1934
   365
paulson@1934
   366
end