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