src/HOL/Auth/NS_Shared.thy
author paulson
Fri, 26 Sep 2003 10:34:28 +0200
changeset 14207 f20fbb141673
parent 14200 d8598e24f8fa
child 16417 9bc16273c2d4
permissions -rw-r--r--
Conversion of all main protocols from "Shared" to "Public". Removal of Key_supply_ax: modifications to possibility theorems. Improved presentation.
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
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
     7
header{*The Needham-Schroeder Shared-Key Protocol*}
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
     8
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
     9
theory NS_Shared = Public:
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
    10
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
    11
text{*
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
    12
From page 247 of
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
    13
  Burrows, Abadi and Needham (1989).  A Logic of Authentication.
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
    14
  Proc. Royal Soc. 426
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
    15
*}
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    16
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    17
consts  ns_shared   :: "event list set"
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3465
diff changeset
    18
inductive "ns_shared"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    19
 intros
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    20
	(*Initial trace is empty*)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
    21
  Nil:  "[] \<in> ns_shared"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    22
	(*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
    23
	  invent new nonces here, but he can also use NS1.  Common to
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    24
	  all similar protocols.*)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
    25
  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
    26
	 \<Longrightarrow> Says Spy B X # evsf \<in> ns_shared"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    27
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    28
	(*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
    29
  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
    30
	 \<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
    31
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    32
	(*Server's response to Alice's message.
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    33
	  !! It may respond more than once to A's request !!
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    34
	  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
    35
	      the sender field.*)
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
    36
  NS2:  "\<lbrakk>evs2 \<in> ns_shared;  Key KAB \<notin> used evs2;  KAB \<in> symKeys;
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
    37
	  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
    38
	 \<Longrightarrow> Says Server A
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    39
	       (Crypt (shrK A)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
    40
		  \<lbrace>Nonce NA, Agent B, Key KAB,
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
    41
		    (Crypt (shrK B) \<lbrace>Key KAB, Agent A\<rbrace>)\<rbrace>)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
    42
	       # evs2 \<in> ns_shared"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    43
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    44
	 (*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
    45
	   Need A \<noteq> Server because we allow messages to self.*)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
    46
  NS3:  "\<lbrakk>evs3 \<in> ns_shared;  A \<noteq> Server;
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
    47
	  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
    48
	  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
    49
	 \<Longrightarrow> Says A B X # evs3 \<in> ns_shared"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    50
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    51
	(*Bob's nonce exchange.  He does not know who the message came
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    52
	  from, but responds to A because she is mentioned inside.*)
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
    53
  NS4:  "\<lbrakk>evs4 \<in> ns_shared;  Nonce NB \<notin> used evs4;  K \<in> symKeys;
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
    54
	  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
    55
	 \<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
    56
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    57
	(*Alice responds with Nonce NB if she has seen the key before.
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    58
	  Maybe should somehow check Nonce NA again.
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    59
	  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
    60
	  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
    61
	  Instead we distinguish the messages by sending the nonce twice.*)
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
    62
  NS5:  "\<lbrakk>evs5 \<in> ns_shared;  K \<in> symKeys;
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
    63
	  Says B' A (Crypt K (Nonce NB)) \<in> set evs5;
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
    64
	  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
    65
	    \<in> set evs5\<rbrakk>
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
    66
	 \<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
    67
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    68
	(*This message models possible leaks of session keys.
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    69
	  The two Nonces identify the protocol run: the rule insists upon
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    70
	  the true senders in order to make them accurate.*)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
    71
  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
    72
	  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
    73
	      \<in> set evso\<rbrakk>
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
    74
	 \<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
    75
11150
67387142225e Streamlining for the bug fix in Blast.
paulson
parents: 11117
diff changeset
    76
67387142225e Streamlining for the bug fix in Blast.
paulson
parents: 11117
diff changeset
    77
declare Says_imp_knows_Spy [THEN parts.Inj, dest]
67387142225e Streamlining for the bug fix in Blast.
paulson
parents: 11117
diff changeset
    78
declare parts.Body  [dest]
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11188
diff changeset
    79
declare Fake_parts_insert_in_Un  [dest]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11188
diff changeset
    80
declare analz_into_parts [dest]
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    81
declare image_eq_UN [simp]  (*accelerates proofs involving nested images*)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    82
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    83
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
    84
text{*A "possibility property": there are traces that reach the end*}
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
    85
lemma "[| A \<noteq> Server; Key K \<notin> used []; K \<in> symKeys |]
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 13956
diff changeset
    86
       ==> \<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
    87
                    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
    88
apply (intro exI bexI)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    89
apply (rule_tac [2] ns_shared.Nil
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    90
       [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
    91
	THEN ns_shared.NS4, THEN ns_shared.NS5])
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
    92
apply (possibility, simp add: used_Cons)
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    93
done
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
(*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
    96
lemma "A \<noteq> Server \<Longrightarrow> \<exists>evs \<in> ns_shared.
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
    97
                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
    98
*)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
    99
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
subsection{*Inductive proofs about @{term ns_shared}*}
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   102
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   103
subsubsection{*Forwarding lemmas, to aid simplification*}
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   104
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   105
text{*For reasoning about the encrypted portion of message NS3*}
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   106
lemma NS3_msg_in_parts_spies:
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   107
     "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
   108
by blast
11280
6fdc4c4ccec1 minor tweaks
paulson
parents: 11251
diff changeset
   109
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   110
text{*For reasoning about the Oops message*}
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   111
lemma Oops_parts_spies:
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   112
     "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
   113
            \<Longrightarrow> K \<in> parts (spies evs)"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   114
by blast
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   115
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   116
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
   117
    sends messages containing @{term X}*}
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   118
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   119
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
   120
lemma Spy_see_shrK [simp]:
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   121
     "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
   122
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
   123
done
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   124
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   125
lemma Spy_analz_shrK [simp]:
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   126
     "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
   127
by auto
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   128
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   129
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   130
text{*Nobody can have used non-existent keys!*}
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   131
lemma new_keys_not_used [simp]:
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   132
    "[|Key K \<notin> used evs; K \<in> symKeys; evs \<in> ns_shared|]
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   133
     ==> K \<notin> keysFor (parts (spies evs))"
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   134
apply (erule rev_mp)
13507
febb8e5d2a9d tidying of Isar scripts
paulson
parents: 11655
diff changeset
   135
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
   136
txt{*Fake, NS2, NS4, NS5*}
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   137
apply (force dest!: keysFor_parts_insert, blast+)
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   138
done
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
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   141
subsubsection{*Lemmas concerning the form of items passed in messages*}
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   142
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   143
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
   144
lemma Says_Server_message_form:
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   145
     "\<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
   146
       evs \<in> ns_shared\<rbrakk>
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   147
      \<Longrightarrow> K \<notin> range shrK \<and>
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   148
          X = (Crypt (shrK B) \<lbrace>Key K, Agent A\<rbrace>) \<and>
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   149
          K' = shrK A"
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   150
by (erule rev_mp, erule ns_shared.induct, auto)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   151
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   152
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   153
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
   154
lemma A_trusts_NS2:
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   155
     "\<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
   156
       A \<notin> bad;  evs \<in> ns_shared\<rbrakk>
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   157
      \<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
   158
apply (erule rev_mp)
13507
febb8e5d2a9d tidying of Isar scripts
paulson
parents: 11655
diff changeset
   159
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
   160
done
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   161
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   162
lemma cert_A_form:
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   163
     "\<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
   164
       A \<notin> bad;  evs \<in> ns_shared\<rbrakk>
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   165
      \<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
   166
by (blast dest!: A_trusts_NS2 Says_Server_message_form)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   167
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   168
text{*EITHER describes the form of X when the following message is sent,
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   169
  OR     reduces it to the Fake case.
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   170
  Use @{text Says_Server_message_form} if applicable.*}
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   171
lemma Says_S_message_form:
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   172
     "\<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
   173
       evs \<in> ns_shared\<rbrakk>
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   174
      \<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
   175
          \<or> X \<in> analz (spies evs)"
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   176
by (blast dest: Says_imp_knows_Spy analz_shrK_Decrypt cert_A_form analz.Inj)
11150
67387142225e Streamlining for the bug fix in Blast.
paulson
parents: 11117
diff changeset
   177
11104
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:
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   181
  "\<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
   182
    evs \<in> ns_shared\<rbrakk>
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   183
   \<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
   184
       \<or> X \<in> analz (spies evs)"
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   185
apply (case_tac "A \<in> bad")
13507
febb8e5d2a9d tidying of Isar scripts
paulson
parents: 11655
diff changeset
   186
apply (force dest!: Says_imp_knows_Spy [THEN analz.Inj])
11104
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
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   194
  Key K \<in> analz (insert (Key KAB) (spies evs)) \<Longrightarrow>
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   195
  Key K \<in> analz (spies evs)
11104
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
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   200
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
   201
  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
   202
  We require that agents should behave like this subsequently also.*}
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   203
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
   204
         (Crypt KAB X) \<in> parts (spies evs) \<and>
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   205
         Key K \<in> parts {X} \<longrightarrow> Key K \<in> parts (spies evs)"
13507
febb8e5d2a9d tidying of Isar scripts
paulson
parents: 11655
diff changeset
   206
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
   207
txt{*Fake*}
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   208
apply (blast dest: parts_insert_subset_Un)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   209
txt{*Base, NS4 and NS5*}
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   210
apply auto
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   211
done
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   212
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   213
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   214
subsubsection{*Session keys are not used to encrypt other session keys*}
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   215
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   216
text{*The equality makes the induction hypothesis easier to apply*}
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   217
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   218
lemma analz_image_freshK [rule_format]:
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   219
 "evs \<in> ns_shared \<Longrightarrow>
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   220
   \<forall>K KK. KK \<subseteq> - (range shrK) \<longrightarrow>
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   221
             (Key K \<in> analz (Key`KK \<union> (spies evs))) =
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   222
             (K \<in> KK \<or> Key K \<in> analz (spies evs))"
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   223
apply (erule ns_shared.induct)
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   224
apply (drule_tac [8] Says_Server_message_form)
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   225
apply (erule_tac [5] Says_S_message_form [THEN disjE], analz_freshK, spy_analz)
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   226
txt{*NS2, NS3*}
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   227
apply blast+; 
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   228
done
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   229
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
lemma analz_insert_freshK:
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   232
     "\<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
   233
       (Key K \<in> analz (insert (Key KAB) (spies evs))) =
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   234
       (K = KAB \<or> Key K \<in> analz (spies evs))"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   235
by (simp only: analz_image_freshK analz_image_freshK_simps)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   236
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   237
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   238
subsubsection{*The session key K uniquely identifies the message*}
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   239
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   240
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
   241
lemma unique_session_keys:
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   242
     "\<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
   243
       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
   244
       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
   245
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
   246
done
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   247
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   248
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   249
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
   250
13956
8fe7e12290e1 improved presentation of HOL/Auth theories
paulson
parents: 13935
diff changeset
   251
text{*Beware of @{text "[rule_format]"} and the universal quantifier!*}
11150
67387142225e Streamlining for the bug fix in Blast.
paulson
parents: 11117
diff changeset
   252
lemma secrecy_lemma:
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   253
     "\<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
   254
                                      Crypt (shrK B) \<lbrace>Key K, Agent A\<rbrace>\<rbrace>)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   255
              \<in> set evs;
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   256
         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
   257
      \<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
   258
         Key K \<notin> analz (spies evs)"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   259
apply (erule rev_mp)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   260
apply (erule ns_shared.induct, force)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   261
apply (frule_tac [7] Says_Server_message_form)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   262
apply (frule_tac [4] Says_S_message_form)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   263
apply (erule_tac [5] disjE)
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   264
apply (simp_all add: analz_insert_eq analz_insert_freshK pushes split_ifs, spy_analz)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   265
txt{*NS2*}
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   266
apply blast
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   267
txt{*NS3, Server sub-case*}
11188
5d539f1682c3 streamlined a proof
paulson
parents: 11150
diff changeset
   268
apply (blast dest!: Crypt_Spy_analz_bad A_trusts_NS2
5d539f1682c3 streamlined a proof
paulson
parents: 11150
diff changeset
   269
	     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
   270
txt{*NS3, Spy sub-case; also Oops*}
11280
6fdc4c4ccec1 minor tweaks
paulson
parents: 11251
diff changeset
   271
apply (blast dest: unique_session_keys)+
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   272
done
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   273
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   274
11188
5d539f1682c3 streamlined a proof
paulson
parents: 11150
diff changeset
   275
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   276
text{*Final version: Server's message in the most abstract form*}
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   277
lemma Spy_not_see_encrypted_key:
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   278
     "\<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
   279
       \<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
   280
       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
   281
      \<Longrightarrow> Key K \<notin> analz (spies evs)"
11150
67387142225e Streamlining for the bug fix in Blast.
paulson
parents: 11117
diff changeset
   282
by (blast dest: Says_Server_message_form secrecy_lemma)
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   283
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   284
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   285
subsection{*Guarantees available at various stages of protocol*}
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   286
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   287
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
   288
lemma B_trusts_NS3:
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   289
     "\<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
   290
       B \<notin> bad;  evs \<in> ns_shared\<rbrakk>
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   291
      \<Longrightarrow> \<exists>NA. Says Server A
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   292
               (Crypt (shrK A) \<lbrace>NA, Agent B, Key K,
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   293
                                 Crypt (shrK B) \<lbrace>Key K, Agent A\<rbrace>\<rbrace>)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   294
              \<in> set evs"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   295
apply (erule rev_mp)
13507
febb8e5d2a9d tidying of Isar scripts
paulson
parents: 11655
diff changeset
   296
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
   297
done
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   298
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   299
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   300
lemma A_trusts_NS4_lemma [rule_format]:
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   301
   "evs \<in> ns_shared \<Longrightarrow>
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   302
      Key K \<notin> analz (spies evs) \<longrightarrow>
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   303
      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
   304
      Crypt K (Nonce NB) \<in> parts (spies evs) \<longrightarrow>
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   305
      Says B A (Crypt K (Nonce NB)) \<in> set evs"
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   306
apply (erule ns_shared.induct, force, drule_tac [4] NS3_msg_in_parts_spies)
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   307
apply (analz_mono_contra, simp_all, blast)
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   308
txt{*NS2: contradiction from the assumptions @{term "Key K \<notin> used evs2"} and
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   309
    @{term "Crypt K (Nonce NB) \<in> parts (spies evs2)"} *} 
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   310
apply (force dest!: Crypt_imp_keysFor)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   311
txt{*NS3*}
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   312
apply blast
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   313
txt{*NS4*}
13935
paulson
parents: 13926
diff changeset
   314
apply (blast dest: B_trusts_NS3
paulson
parents: 13926
diff changeset
   315
	           Says_imp_knows_Spy [THEN analz.Inj]
11150
67387142225e Streamlining for the bug fix in Blast.
paulson
parents: 11117
diff changeset
   316
                   Crypt_Spy_analz_bad unique_session_keys)
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   317
done
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   318
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   319
text{*This version no longer assumes that K is secure*}
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   320
lemma A_trusts_NS4:
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   321
     "\<lbrakk>Crypt K (Nonce NB) \<in> parts (spies evs);
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   322
       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
   323
       \<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
   324
       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
   325
      \<Longrightarrow> Says B A (Crypt K (Nonce NB)) \<in> set evs"
11280
6fdc4c4ccec1 minor tweaks
paulson
parents: 11251
diff changeset
   326
by (blast intro: A_trusts_NS4_lemma
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   327
          dest: A_trusts_NS2 Spy_not_see_encrypted_key)
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   328
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   329
text{*If the session key has been used in NS4 then somebody has forwarded
11280
6fdc4c4ccec1 minor tweaks
paulson
parents: 11251
diff changeset
   330
  component X in some instance of NS4.  Perhaps an interesting property,
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   331
  but not needed (after all) for the proofs below.*}
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   332
theorem NS4_implies_NS3 [rule_format]:
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   333
  "evs \<in> ns_shared \<Longrightarrow>
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   334
     Key K \<notin> analz (spies evs) \<longrightarrow>
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   335
     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
   336
     Crypt K (Nonce NB) \<in> parts (spies evs) \<longrightarrow>
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   337
     (\<exists>A'. Says A' B X \<in> set evs)"
13507
febb8e5d2a9d tidying of Isar scripts
paulson
parents: 11655
diff changeset
   338
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
   339
apply (simp_all add: ex_disj_distrib, blast)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   340
txt{*NS2*}
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   341
apply (blast dest!: new_keys_not_used Crypt_imp_keysFor)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   342
txt{*NS3*}
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   343
apply blast
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   344
txt{*NS4*}
13935
paulson
parents: 13926
diff changeset
   345
apply (blast dest: B_trusts_NS3
11280
6fdc4c4ccec1 minor tweaks
paulson
parents: 11251
diff changeset
   346
	     dest: Says_imp_knows_Spy [THEN analz.Inj]
11150
67387142225e Streamlining for the bug fix in Blast.
paulson
parents: 11117
diff changeset
   347
                   unique_session_keys Crypt_Spy_analz_bad)
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   348
done
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   349
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   350
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   351
lemma B_trusts_NS5_lemma [rule_format]:
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   352
  "\<lbrakk>B \<notin> bad;  evs \<in> ns_shared\<rbrakk> \<Longrightarrow>
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   353
     Key K \<notin> analz (spies evs) \<longrightarrow>
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   354
     Says Server A
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   355
	  (Crypt (shrK A) \<lbrace>NA, Agent B, Key K,
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   356
			    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
   357
     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
   358
     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
   359
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
   360
txt{*NS2*}
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   361
apply (blast dest!: new_keys_not_used Crypt_imp_keysFor)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   362
txt{*NS3*}
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   363
apply (blast dest!: cert_A_form)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   364
txt{*NS5*}
11150
67387142225e Streamlining for the bug fix in Blast.
paulson
parents: 11117
diff changeset
   365
apply (blast dest!: A_trusts_NS2
11280
6fdc4c4ccec1 minor tweaks
paulson
parents: 11251
diff changeset
   366
	     dest: Says_imp_knows_Spy [THEN analz.Inj]
11150
67387142225e Streamlining for the bug fix in Blast.
paulson
parents: 11117
diff changeset
   367
                   unique_session_keys Crypt_Spy_analz_bad)
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   368
done
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   369
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   370
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   371
text{*Very strong Oops condition reveals protocol's weakness*}
11104
f2024fed9f0c partial conversion to Isar script style
paulson
parents: 5434
diff changeset
   372
lemma B_trusts_NS5:
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   373
     "\<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
   374
       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
   375
       \<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
   376
       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
   377
      \<Longrightarrow> Says A B (Crypt K \<lbrace>Nonce NB, Nonce NB\<rbrace>) \<in> set evs"
11280
6fdc4c4ccec1 minor tweaks
paulson
parents: 11251
diff changeset
   378
by (blast intro: B_trusts_NS5_lemma
11150
67387142225e Streamlining for the bug fix in Blast.
paulson
parents: 11117
diff changeset
   379
          dest: B_trusts_NS3 Spy_not_see_encrypted_key)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   380
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   381
end