| author | wenzelm | 
| Wed, 14 Oct 2009 23:44:37 +0200 | |
| changeset 32936 | 9491bec20595 | 
| parent 32630 | 133e4a6474e3 | 
| child 37936 | 1e4c5015a72e | 
| permissions | -rw-r--r-- | 
| 2318 | 1 | (* Title: HOL/Auth/Public | 
| 2 | Author: Lawrence C Paulson, Cambridge University Computer Laboratory | |
| 3 | Copyright 1996 University of Cambridge | |
| 4 | ||
| 3512 
9dcb4daa15e8
Moving common declarations and proofs from theories "Shared"
 paulson parents: 
3478diff
changeset | 5 | Theory of Public Keys (common to all public-key protocols) | 
| 2318 | 6 | |
| 3512 
9dcb4daa15e8
Moving common declarations and proofs from theories "Shared"
 paulson parents: 
3478diff
changeset | 7 | Private and public keys; initial states of agents | 
| 2318 | 8 | *) | 
| 9 | ||
| 32630 | 10 | theory Public | 
| 11 | imports Event | |
| 12 | begin | |
| 13922 | 13 | |
| 14207 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 14 | lemma invKey_K: "K \<in> symKeys ==> invKey K = K" | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 15 | by (simp add: symKeys_def) | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 16 | |
| 13922 | 17 | subsection{*Asymmetric Keys*}
 | 
| 2318 | 18 | |
| 18749 
31c2af8b0c60
replacement of bool by a datatype (making problems first-order). More lemma names
 paulson parents: 
18570diff
changeset | 19 | datatype keymode = Signature | Encryption | 
| 
31c2af8b0c60
replacement of bool by a datatype (making problems first-order). More lemma names
 paulson parents: 
18570diff
changeset | 20 | |
| 2318 | 21 | consts | 
| 18749 
31c2af8b0c60
replacement of bool by a datatype (making problems first-order). More lemma names
 paulson parents: 
18570diff
changeset | 22 | publicKey :: "[keymode,agent] => key" | 
| 2318 | 23 | |
| 20768 | 24 | abbreviation | 
| 21404 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 wenzelm parents: 
20768diff
changeset | 25 | pubEK :: "agent => key" where | 
| 20768 | 26 | "pubEK == publicKey Encryption" | 
| 13922 | 27 | |
| 21404 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 wenzelm parents: 
20768diff
changeset | 28 | abbreviation | 
| 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 wenzelm parents: 
20768diff
changeset | 29 | pubSK :: "agent => key" where | 
| 20768 | 30 | "pubSK == publicKey Signature" | 
| 13922 | 31 | |
| 21404 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 wenzelm parents: 
20768diff
changeset | 32 | abbreviation | 
| 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 wenzelm parents: 
20768diff
changeset | 33 | privateKey :: "[keymode, agent] => key" where | 
| 20768 | 34 | "privateKey b A == invKey (publicKey b A)" | 
| 13922 | 35 | |
| 21404 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 wenzelm parents: 
20768diff
changeset | 36 | abbreviation | 
| 13922 | 37 | (*BEWARE!! priEK, priSK DON'T WORK with inj, range, image, etc.*) | 
| 21404 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 wenzelm parents: 
20768diff
changeset | 38 | priEK :: "agent => key" where | 
| 20768 | 39 | "priEK A == privateKey Encryption A" | 
| 21404 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 wenzelm parents: 
20768diff
changeset | 40 | |
| 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 wenzelm parents: 
20768diff
changeset | 41 | abbreviation | 
| 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 wenzelm parents: 
20768diff
changeset | 42 | priSK :: "agent => key" where | 
| 20768 | 43 | "priSK A == privateKey Signature A" | 
| 13922 | 44 | |
| 45 | ||
| 20768 | 46 | text{*These abbreviations give backward compatibility.  They represent the
 | 
| 13922 | 47 | simple situation where the signature and encryption keys are the same.*} | 
| 20768 | 48 | |
| 49 | abbreviation | |
| 21404 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 wenzelm parents: 
20768diff
changeset | 50 | pubK :: "agent => key" where | 
| 20768 | 51 | "pubK A == pubEK A" | 
| 52 | ||
| 21404 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 wenzelm parents: 
20768diff
changeset | 53 | abbreviation | 
| 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 wenzelm parents: 
20768diff
changeset | 54 | priK :: "agent => key" where | 
| 20768 | 55 | "priK A == invKey (pubEK A)" | 
| 13922 | 56 | |
| 57 | ||
| 14126 
28824746d046
Tidying and replacement of some axioms by specifications
 paulson parents: 
13956diff
changeset | 58 | text{*By freeness of agents, no two agents have the same key.  Since
 | 
| 
28824746d046
Tidying and replacement of some axioms by specifications
 paulson parents: 
13956diff
changeset | 59 |   @{term "True\<noteq>False"}, no agent has identical signing and encryption keys*}
 | 
| 
28824746d046
Tidying and replacement of some axioms by specifications
 paulson parents: 
13956diff
changeset | 60 | specification (publicKey) | 
| 13922 | 61 | injective_publicKey: | 
| 62 | "publicKey b A = publicKey c A' ==> b=c & A=A'" | |
| 18749 
31c2af8b0c60
replacement of bool by a datatype (making problems first-order). More lemma names
 paulson parents: 
18570diff
changeset | 63 | apply (rule exI [of _ | 
| 
31c2af8b0c60
replacement of bool by a datatype (making problems first-order). More lemma names
 paulson parents: 
18570diff
changeset | 64 | "%b A. 2 * agent_case 0 (\<lambda>n. n + 2) 1 A + keymode_case 0 1 b"]) | 
| 
31c2af8b0c60
replacement of bool by a datatype (making problems first-order). More lemma names
 paulson parents: 
18570diff
changeset | 65 | apply (auto simp add: inj_on_def split: agent.split keymode.split) | 
| 23315 | 66 | apply presburger | 
| 67 | apply presburger | |
| 14126 
28824746d046
Tidying and replacement of some axioms by specifications
 paulson parents: 
13956diff
changeset | 68 | done | 
| 13922 | 69 | |
| 14126 
28824746d046
Tidying and replacement of some axioms by specifications
 paulson parents: 
13956diff
changeset | 70 | |
| 
28824746d046
Tidying and replacement of some axioms by specifications
 paulson parents: 
13956diff
changeset | 71 | axioms | 
| 13922 | 72 | (*No private key equals any public key (essential to ensure that private | 
| 73 | keys are private!) *) | |
| 74 | privateKey_neq_publicKey [iff]: "privateKey b A \<noteq> publicKey c A'" | |
| 75 | ||
| 18749 
31c2af8b0c60
replacement of bool by a datatype (making problems first-order). More lemma names
 paulson parents: 
18570diff
changeset | 76 | lemmas publicKey_neq_privateKey = privateKey_neq_publicKey [THEN not_sym] | 
| 
31c2af8b0c60
replacement of bool by a datatype (making problems first-order). More lemma names
 paulson parents: 
18570diff
changeset | 77 | declare publicKey_neq_privateKey [iff] | 
| 13922 | 78 | |
| 79 | ||
| 13926 | 80 | subsection{*Basic properties of @{term pubK} and @{term priK}*}
 | 
| 13922 | 81 | |
| 18570 | 82 | lemma publicKey_inject [iff]: "(publicKey b A = publicKey c A') = (b=c & A=A')" | 
| 13922 | 83 | by (blast dest!: injective_publicKey) | 
| 84 | ||
| 85 | lemma not_symKeys_pubK [iff]: "publicKey b A \<notin> symKeys" | |
| 13926 | 86 | by (simp add: symKeys_def) | 
| 13922 | 87 | |
| 88 | lemma not_symKeys_priK [iff]: "privateKey b A \<notin> symKeys" | |
| 13926 | 89 | by (simp add: symKeys_def) | 
| 13922 | 90 | |
| 91 | lemma symKey_neq_priEK: "K \<in> symKeys ==> K \<noteq> priEK A" | |
| 92 | by auto | |
| 93 | ||
| 94 | lemma symKeys_neq_imp_neq: "(K \<in> symKeys) \<noteq> (K' \<in> symKeys) ==> K \<noteq> K'" | |
| 13926 | 95 | by blast | 
| 13922 | 96 | |
| 97 | lemma symKeys_invKey_iff [iff]: "(invKey K \<in> symKeys) = (K \<in> symKeys)" | |
| 13926 | 98 | by (unfold symKeys_def, auto) | 
| 2318 | 99 | |
| 13922 | 100 | lemma analz_symKeys_Decrypt: | 
| 101 | "[| Crypt K X \<in> analz H; K \<in> symKeys; Key K \<in> analz H |] | |
| 102 | ==> X \<in> analz H" | |
| 103 | by (auto simp add: symKeys_def) | |
| 104 | ||
| 105 | ||
| 106 | ||
| 107 | subsection{*"Image" equations that hold for injective functions*}
 | |
| 108 | ||
| 109 | lemma invKey_image_eq [simp]: "(invKey x \<in> invKey`A) = (x \<in> A)" | |
| 13926 | 110 | by auto | 
| 13922 | 111 | |
| 112 | (*holds because invKey is injective*) | |
| 113 | lemma publicKey_image_eq [simp]: | |
| 114 | "(publicKey b x \<in> publicKey c ` AA) = (b=c & x \<in> AA)" | |
| 115 | by auto | |
| 116 | ||
| 117 | lemma privateKey_notin_image_publicKey [simp]: "privateKey b x \<notin> publicKey c ` AA" | |
| 13926 | 118 | by auto | 
| 13922 | 119 | |
| 120 | lemma privateKey_image_eq [simp]: | |
| 121 | "(privateKey b A \<in> invKey ` publicKey c ` AS) = (b=c & A\<in>AS)" | |
| 122 | by auto | |
| 123 | ||
| 124 | lemma publicKey_notin_image_privateKey [simp]: "publicKey b A \<notin> invKey ` publicKey c ` AS" | |
| 13926 | 125 | by auto | 
| 13922 | 126 | |
| 127 | ||
| 128 | subsection{*Symmetric Keys*}
 | |
| 129 | ||
| 130 | text{*For some protocols, it is convenient to equip agents with symmetric as
 | |
| 131 | well as asymmetric keys.  The theory @{text Shared} assumes that all keys
 | |
| 132 | are symmetric.*} | |
| 133 | ||
| 134 | consts | |
| 135 |   shrK    :: "agent => key"    --{*long-term shared keys*}
 | |
| 136 | ||
| 14126 
28824746d046
Tidying and replacement of some axioms by specifications
 paulson parents: 
13956diff
changeset | 137 | specification (shrK) | 
| 
28824746d046
Tidying and replacement of some axioms by specifications
 paulson parents: 
13956diff
changeset | 138 | inj_shrK: "inj shrK" | 
| 
28824746d046
Tidying and replacement of some axioms by specifications
 paulson parents: 
13956diff
changeset | 139 |   --{*No two agents have the same long-term key*}
 | 
| 
28824746d046
Tidying and replacement of some axioms by specifications
 paulson parents: 
13956diff
changeset | 140 | apply (rule exI [of _ "agent_case 0 (\<lambda>n. n + 2) 1"]) | 
| 
28824746d046
Tidying and replacement of some axioms by specifications
 paulson parents: 
13956diff
changeset | 141 | apply (simp add: inj_on_def split: agent.split) | 
| 
28824746d046
Tidying and replacement of some axioms by specifications
 paulson parents: 
13956diff
changeset | 142 | done | 
| 
28824746d046
Tidying and replacement of some axioms by specifications
 paulson parents: 
13956diff
changeset | 143 | |
| 13922 | 144 | axioms | 
| 145 |   sym_shrK [iff]: "shrK X \<in> symKeys" --{*All shared keys are symmetric*}
 | |
| 146 | ||
| 18570 | 147 | text{*Injectiveness: Agents' long-term keys are distinct.*}
 | 
| 148 | lemmas shrK_injective = inj_shrK [THEN inj_eq] | |
| 149 | declare shrK_injective [iff] | |
| 13922 | 150 | |
| 14207 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 151 | lemma invKey_shrK [simp]: "invKey (shrK A) = shrK A" | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 152 | by (simp add: invKey_K) | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 153 | |
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 154 | lemma analz_shrK_Decrypt: | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 155 | "[| Crypt (shrK A) X \<in> analz H; Key(shrK A) \<in> analz H |] ==> X \<in> analz H" | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 156 | by auto | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 157 | |
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 158 | lemma analz_Decrypt': | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 159 | "[| Crypt K X \<in> analz H; K \<in> symKeys; Key K \<in> analz H |] ==> X \<in> analz H" | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 160 | by (auto simp add: invKey_K) | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 161 | |
| 13922 | 162 | lemma priK_neq_shrK [iff]: "shrK A \<noteq> privateKey b C" | 
| 13926 | 163 | by (simp add: symKeys_neq_imp_neq) | 
| 13922 | 164 | |
| 18749 
31c2af8b0c60
replacement of bool by a datatype (making problems first-order). More lemma names
 paulson parents: 
18570diff
changeset | 165 | lemmas shrK_neq_priK = priK_neq_shrK [THEN not_sym] | 
| 
31c2af8b0c60
replacement of bool by a datatype (making problems first-order). More lemma names
 paulson parents: 
18570diff
changeset | 166 | declare shrK_neq_priK [simp] | 
| 13922 | 167 | |
| 168 | lemma pubK_neq_shrK [iff]: "shrK A \<noteq> publicKey b C" | |
| 13926 | 169 | by (simp add: symKeys_neq_imp_neq) | 
| 13922 | 170 | |
| 18749 
31c2af8b0c60
replacement of bool by a datatype (making problems first-order). More lemma names
 paulson parents: 
18570diff
changeset | 171 | lemmas shrK_neq_pubK = pubK_neq_shrK [THEN not_sym] | 
| 
31c2af8b0c60
replacement of bool by a datatype (making problems first-order). More lemma names
 paulson parents: 
18570diff
changeset | 172 | declare shrK_neq_pubK [simp] | 
| 13922 | 173 | |
| 174 | lemma priEK_noteq_shrK [simp]: "priEK A \<noteq> shrK B" | |
| 175 | by auto | |
| 176 | ||
| 177 | lemma publicKey_notin_image_shrK [simp]: "publicKey b x \<notin> shrK ` AA" | |
| 178 | by auto | |
| 179 | ||
| 180 | lemma privateKey_notin_image_shrK [simp]: "privateKey b x \<notin> shrK ` AA" | |
| 181 | by auto | |
| 182 | ||
| 183 | lemma shrK_notin_image_publicKey [simp]: "shrK x \<notin> publicKey b ` AA" | |
| 184 | by auto | |
| 185 | ||
| 186 | lemma shrK_notin_image_privateKey [simp]: "shrK x \<notin> invKey ` publicKey b ` AA" | |
| 187 | by auto | |
| 188 | ||
| 189 | lemma shrK_image_eq [simp]: "(shrK x \<in> shrK ` AA) = (x \<in> AA)" | |
| 190 | by auto | |
| 191 | ||
| 14207 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 192 | text{*For some reason, moving this up can make some proofs loop!*}
 | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 193 | declare invKey_K [simp] | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 194 | |
| 13922 | 195 | |
| 196 | subsection{*Initial States of Agents*}
 | |
| 197 | ||
| 198 | text{*Note: for all practical purposes, all that matters is the initial
 | |
| 199 | knowledge of the Spy. All other agents are automata, merely following the | |
| 200 | protocol.*} | |
| 2318 | 201 | |
| 5183 | 202 | primrec | 
| 2318 | 203 | (*Agents know their private key and all public keys*) | 
| 13922 | 204 | initState_Server: | 
| 205 | "initState Server = | |
| 206 |        {Key (priEK Server), Key (priSK Server)} \<union> 
 | |
| 207 | (Key ` range pubEK) \<union> (Key ` range pubSK) \<union> (Key ` range shrK)" | |
| 208 | ||
| 209 | initState_Friend: | |
| 210 | "initState (Friend i) = | |
| 211 |        {Key (priEK(Friend i)), Key (priSK(Friend i)), Key (shrK(Friend i))} \<union> 
 | |
| 212 | (Key ` range pubEK) \<union> (Key ` range pubSK)" | |
| 213 | ||
| 214 | initState_Spy: | |
| 215 | "initState Spy = | |
| 216 | (Key ` invKey ` pubEK ` bad) \<union> (Key ` invKey ` pubSK ` bad) \<union> | |
| 217 | (Key ` shrK ` bad) \<union> | |
| 218 | (Key ` range pubEK) \<union> (Key ` range pubSK)" | |
| 219 | ||
| 220 | ||
| 221 | text{*These lemmas allow reasoning about @{term "used evs"} rather than
 | |
| 13935 | 222 |    @{term "knows Spy evs"}, which is useful when there are private Notes. 
 | 
| 223 |    Because they depend upon the definition of @{term initState}, they cannot
 | |
| 224 | be moved up.*} | |
| 13922 | 225 | |
| 226 | lemma used_parts_subset_parts [rule_format]: | |
| 227 |      "\<forall>X \<in> used evs. parts {X} \<subseteq> used evs"
 | |
| 228 | apply (induct evs) | |
| 229 | prefer 2 | |
| 230 | apply (simp add: used_Cons) | |
| 231 | apply (rule ballI) | |
| 13935 | 232 | apply (case_tac a, auto) | 
| 233 | apply (auto dest!: parts_cut) | |
| 13922 | 234 | txt{*Base case*}
 | 
| 13935 | 235 | apply (simp add: used_Nil) | 
| 13922 | 236 | done | 
| 237 | ||
| 238 | lemma MPair_used_D: "{|X,Y|} \<in> used H ==> X \<in> used H & Y \<in> used H"
 | |
| 239 | by (drule used_parts_subset_parts, simp, blast) | |
| 240 | ||
| 17990 | 241 | text{*There was a similar theorem in Event.thy, so perhaps this one can
 | 
| 242 | be moved up if proved directly by induction.*} | |
| 13922 | 243 | lemma MPair_used [elim!]: | 
| 244 |      "[| {|X,Y|} \<in> used H;
 | |
| 245 | [| X \<in> used H; Y \<in> used H |] ==> P |] | |
| 246 | ==> P" | |
| 247 | by (blast dest: MPair_used_D) | |
| 248 | ||
| 249 | ||
| 250 | text{*Rewrites should not refer to  @{term "initState(Friend i)"} because
 | |
| 251 | that expression is not in normal form.*} | |
| 252 | ||
| 253 | lemma keysFor_parts_initState [simp]: "keysFor (parts (initState C)) = {}"
 | |
| 254 | apply (unfold keysFor_def) | |
| 255 | apply (induct_tac "C") | |
| 256 | apply (auto intro: range_eqI) | |
| 257 | done | |
| 258 | ||
| 259 | lemma Crypt_notin_initState: "Crypt K X \<notin> parts (initState B)" | |
| 260 | by (induct B, auto) | |
| 261 | ||
| 13935 | 262 | lemma Crypt_notin_used_empty [simp]: "Crypt K X \<notin> used []" | 
| 263 | by (simp add: Crypt_notin_initState used_Nil) | |
| 264 | ||
| 13922 | 265 | (*** Basic properties of shrK ***) | 
| 266 | ||
| 267 | (*Agents see their own shared keys!*) | |
| 268 | lemma shrK_in_initState [iff]: "Key (shrK A) \<in> initState A" | |
| 13926 | 269 | by (induct_tac "A", auto) | 
| 13922 | 270 | |
| 271 | lemma shrK_in_knows [iff]: "Key (shrK A) \<in> knows A evs" | |
| 272 | by (simp add: initState_subset_knows [THEN subsetD]) | |
| 273 | ||
| 274 | lemma shrK_in_used [iff]: "Key (shrK A) \<in> used evs" | |
| 13926 | 275 | by (rule initState_into_used, blast) | 
| 13922 | 276 | |
| 14207 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 277 | |
| 13922 | 278 | (** Fresh keys never clash with long-term shared keys **) | 
| 279 | ||
| 280 | (*Used in parts_induct_tac and analz_Fake_tac to distinguish session keys | |
| 281 | from long-term shared keys*) | |
| 14207 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 282 | lemma Key_not_used [simp]: "Key K \<notin> used evs ==> K \<notin> range shrK" | 
| 13926 | 283 | by blast | 
| 13922 | 284 | |
| 285 | lemma shrK_neq: "Key K \<notin> used evs ==> shrK B \<noteq> K" | |
| 13926 | 286 | by blast | 
| 13922 | 287 | |
| 18749 
31c2af8b0c60
replacement of bool by a datatype (making problems first-order). More lemma names
 paulson parents: 
18570diff
changeset | 288 | lemmas neq_shrK = shrK_neq [THEN not_sym] | 
| 
31c2af8b0c60
replacement of bool by a datatype (making problems first-order). More lemma names
 paulson parents: 
18570diff
changeset | 289 | declare neq_shrK [simp] | 
| 2318 | 290 | |
| 291 | ||
| 13922 | 292 | subsection{*Function @{term spies} *}
 | 
| 293 | ||
| 18749 
31c2af8b0c60
replacement of bool by a datatype (making problems first-order). More lemma names
 paulson parents: 
18570diff
changeset | 294 | lemma not_SignatureE [elim!]: "b \<noteq> Signature \<Longrightarrow> b = Encryption" | 
| 
31c2af8b0c60
replacement of bool by a datatype (making problems first-order). More lemma names
 paulson parents: 
18570diff
changeset | 295 | by (cases b, auto) | 
| 
31c2af8b0c60
replacement of bool by a datatype (making problems first-order). More lemma names
 paulson parents: 
18570diff
changeset | 296 | |
| 13922 | 297 | text{*Agents see their own private keys!*}
 | 
| 298 | lemma priK_in_initState [iff]: "Key (privateKey b A) \<in> initState A" | |
| 18749 
31c2af8b0c60
replacement of bool by a datatype (making problems first-order). More lemma names
 paulson parents: 
18570diff
changeset | 299 | by (cases A, auto) | 
| 13922 | 300 | |
| 301 | text{*Agents see all public keys!*}
 | |
| 302 | lemma publicKey_in_initState [iff]: "Key (publicKey b A) \<in> initState B" | |
| 18749 
31c2af8b0c60
replacement of bool by a datatype (making problems first-order). More lemma names
 paulson parents: 
18570diff
changeset | 303 | by (cases B, auto) | 
| 13922 | 304 | |
| 305 | text{*All public keys are visible*}
 | |
| 306 | lemma spies_pubK [iff]: "Key (publicKey b A) \<in> spies evs" | |
| 307 | apply (induct_tac "evs") | |
| 18749 
31c2af8b0c60
replacement of bool by a datatype (making problems first-order). More lemma names
 paulson parents: 
18570diff
changeset | 308 | apply (auto simp add: imageI knows_Cons split add: event.split) | 
| 13922 | 309 | done | 
| 310 | ||
| 18749 
31c2af8b0c60
replacement of bool by a datatype (making problems first-order). More lemma names
 paulson parents: 
18570diff
changeset | 311 | lemmas analz_spies_pubK = spies_pubK [THEN analz.Inj] | 
| 
31c2af8b0c60
replacement of bool by a datatype (making problems first-order). More lemma names
 paulson parents: 
18570diff
changeset | 312 | declare analz_spies_pubK [iff] | 
| 13922 | 313 | |
| 314 | text{*Spy sees private keys of bad agents!*}
 | |
| 315 | lemma Spy_spies_bad_privateKey [intro!]: | |
| 316 | "A \<in> bad ==> Key (privateKey b A) \<in> spies evs" | |
| 317 | apply (induct_tac "evs") | |
| 18749 
31c2af8b0c60
replacement of bool by a datatype (making problems first-order). More lemma names
 paulson parents: 
18570diff
changeset | 318 | apply (auto simp add: imageI knows_Cons split add: event.split) | 
| 13922 | 319 | done | 
| 320 | ||
| 321 | text{*Spy sees long-term shared keys of bad agents!*}
 | |
| 322 | lemma Spy_spies_bad_shrK [intro!]: | |
| 323 | "A \<in> bad ==> Key (shrK A) \<in> spies evs" | |
| 324 | apply (induct_tac "evs") | |
| 325 | apply (simp_all add: imageI knows_Cons split add: event.split) | |
| 326 | done | |
| 327 | ||
| 328 | lemma publicKey_into_used [iff] :"Key (publicKey b A) \<in> used evs" | |
| 329 | apply (rule initState_into_used) | |
| 330 | apply (rule publicKey_in_initState [THEN parts.Inj]) | |
| 331 | done | |
| 332 | ||
| 333 | lemma privateKey_into_used [iff]: "Key (privateKey b A) \<in> used evs" | |
| 334 | apply(rule initState_into_used) | |
| 335 | apply(rule priK_in_initState [THEN parts.Inj]) | |
| 336 | done | |
| 337 | ||
| 14207 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 338 | (*For case analysis on whether or not an agent is compromised*) | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 339 | lemma Crypt_Spy_analz_bad: | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 340 | "[| Crypt (shrK A) X \<in> analz (knows Spy evs); A \<in> bad |] | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 341 | ==> X \<in> analz (knows Spy evs)" | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 342 | by force | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 343 | |
| 13922 | 344 | |
| 345 | subsection{*Fresh Nonces*}
 | |
| 346 | ||
| 347 | lemma Nonce_notin_initState [iff]: "Nonce N \<notin> parts (initState B)" | |
| 13926 | 348 | by (induct_tac "B", auto) | 
| 13922 | 349 | |
| 350 | lemma Nonce_notin_used_empty [simp]: "Nonce N \<notin> used []" | |
| 13926 | 351 | by (simp add: used_Nil) | 
| 13922 | 352 | |
| 11104 | 353 | |
| 13922 | 354 | subsection{*Supply fresh nonces for possibility theorems*}
 | 
| 355 | ||
| 356 | text{*In any trace, there is an upper bound N on the greatest nonce in use*}
 | |
| 357 | lemma Nonce_supply_lemma: "EX N. ALL n. N<=n --> Nonce n \<notin> used evs" | |
| 358 | apply (induct_tac "evs") | |
| 13926 | 359 | apply (rule_tac x = 0 in exI) | 
| 13922 | 360 | apply (simp_all (no_asm_simp) add: used_Cons split add: event.split) | 
| 361 | apply safe | |
| 362 | apply (rule msg_Nonce_supply [THEN exE], blast elim!: add_leE)+ | |
| 363 | done | |
| 364 | ||
| 365 | lemma Nonce_supply1: "EX N. Nonce N \<notin> used evs" | |
| 13926 | 366 | by (rule Nonce_supply_lemma [THEN exE], blast) | 
| 13922 | 367 | |
| 368 | lemma Nonce_supply: "Nonce (@ N. Nonce N \<notin> used evs) \<notin> used evs" | |
| 369 | apply (rule Nonce_supply_lemma [THEN exE]) | |
| 13926 | 370 | apply (rule someI, fast) | 
| 13922 | 371 | done | 
| 372 | ||
| 13956 | 373 | subsection{*Specialized Rewriting for Theorems About @{term analz} and Image*}
 | 
| 13922 | 374 | |
| 375 | lemma insert_Key_singleton: "insert (Key K) H = Key ` {K} Un H"
 | |
| 13926 | 376 | by blast | 
| 11104 | 377 | |
| 13922 | 378 | lemma insert_Key_image: "insert (Key K) (Key`KK \<union> C) = Key ` (insert K KK) \<union> C" | 
| 13926 | 379 | by blast | 
| 13922 | 380 | |
| 381 | ||
| 14207 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 382 | lemma Crypt_imp_keysFor :"[|Crypt K X \<in> H; K \<in> symKeys|] ==> K \<in> keysFor H" | 
| 13926 | 383 | by (drule Crypt_imp_invKey_keysFor, simp) | 
| 13922 | 384 | |
| 14207 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 385 | text{*Lemma for the trivial direction of the if-and-only-if of the 
 | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 386 | Session Key Compromise Theorem*} | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 387 | lemma analz_image_freshK_lemma: | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 388 | "(Key K \<in> analz (Key`nE \<union> H)) --> (K \<in> nE | Key K \<in> analz H) ==> | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 389 | (Key K \<in> analz (Key`nE \<union> H)) = (K \<in> nE | Key K \<in> analz H)" | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 390 | by (blast intro: analz_mono [THEN [2] rev_subsetD]) | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 391 | |
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 392 | lemmas analz_image_freshK_simps = | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 393 |        simp_thms mem_simps --{*these two allow its use with @{text "only:"}*}
 | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 394 | disj_comms | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 395 | image_insert [THEN sym] image_Un [THEN sym] empty_subsetI insert_subset | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 396 | analz_insert_eq Un_upper2 [THEN analz_mono, THEN subsetD] | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 397 | insert_Key_singleton | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 398 | Key_not_used insert_Key_image Un_assoc [THEN sym] | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 399 | |
| 21619 | 400 | ML {*
 | 
| 24122 | 401 | structure Public = | 
| 402 | struct | |
| 14207 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 403 | |
| 24122 | 404 | val analz_image_freshK_ss = @{simpset} delsimps [image_insert, image_Un]
 | 
| 405 |   delsimps [@{thm imp_disjL}]    (*reduces blow-up*)
 | |
| 406 |   addsimps @{thms analz_image_freshK_simps}
 | |
| 13922 | 407 | |
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
23315diff
changeset | 408 | (*Tactic for possibility theorems*) | 
| 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
23315diff
changeset | 409 | fun possibility_tac ctxt = | 
| 13922 | 410 | REPEAT (*omit used_Says so that Nonces start from different traces!*) | 
| 32149 
ef59550a55d3
renamed simpset_of to global_simpset_of, and local_simpset_of to simpset_of -- same for claset and clasimpset;
 wenzelm parents: 
30549diff
changeset | 411 |     (ALLGOALS (simp_tac (simpset_of ctxt delsimps [@{thm used_Says}]))
 | 
| 13922 | 412 | THEN | 
| 413 | REPEAT_FIRST (eq_assume_tac ORELSE' | |
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
23315diff
changeset | 414 |                    resolve_tac [refl, conjI, @{thm Nonce_supply}]))
 | 
| 14207 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 415 | |
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 416 | (*For harder protocols (such as Recur) where we have to set up some | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 417 | nonces and keys initially*) | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
23315diff
changeset | 418 | fun basic_possibility_tac ctxt = | 
| 14207 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 419 | REPEAT | 
| 32149 
ef59550a55d3
renamed simpset_of to global_simpset_of, and local_simpset_of to simpset_of -- same for claset and clasimpset;
 wenzelm parents: 
30549diff
changeset | 420 | (ALLGOALS (asm_simp_tac (simpset_of ctxt setSolver safe_solver)) | 
| 14207 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 421 | THEN | 
| 
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
 paulson parents: 
14200diff
changeset | 422 | REPEAT_FIRST (resolve_tac [refl, conjI])) | 
| 24122 | 423 | |
| 424 | end | |
| 13922 | 425 | *} | 
| 11104 | 426 | |
| 24122 | 427 | method_setup analz_freshK = {*
 | 
| 30549 | 428 | Scan.succeed (fn ctxt => | 
| 30510 
4120fc59dd85
unified type Proof.method and pervasive METHOD combinators;
 wenzelm parents: 
24122diff
changeset | 429 | (SIMPLE_METHOD | 
| 24122 | 430 | (EVERY [REPEAT_FIRST (resolve_tac [allI, ballI, impI]), | 
| 431 |           REPEAT_FIRST (rtac @{thm analz_image_freshK_lemma}),
 | |
| 432 | ALLGOALS (asm_simp_tac (Simplifier.context ctxt Public.analz_image_freshK_ss))]))) *} | |
| 433 | "for proving the Session Key Compromise theorem" | |
| 434 | ||
| 435 | ||
| 436 | subsection{*Specialized Methods for Possibility Theorems*}
 | |
| 437 | ||
| 11104 | 438 | method_setup possibility = {*
 | 
| 30549 | 439 | Scan.succeed (SIMPLE_METHOD o Public.possibility_tac) *} | 
| 23894 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
23315diff
changeset | 440 | "for proving possibility theorems" | 
| 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
23315diff
changeset | 441 | |
| 
1a4167d761ac
tactics: avoid dynamic reference to accidental theory context (via ML_Context.the_context etc.);
 wenzelm parents: 
23315diff
changeset | 442 | method_setup basic_possibility = {*
 | 
| 30549 | 443 | Scan.succeed (SIMPLE_METHOD o Public.basic_possibility_tac) *} | 
| 11104 | 444 | "for proving possibility theorems" | 
| 2318 | 445 | |
| 446 | end |