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