author | paulson |
Wed, 25 Sep 1996 17:15:18 +0200 | |
changeset 2026 | 0df5a96bf77e |
parent 2012 | 1b234f1fd9c7 |
child 2032 | 1bbf1bdcaf56 |
permissions | -rw-r--r-- |
1934 | 1 |
(* Title: HOL/Auth/Message |
2 |
ID: $Id$ |
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
|
4 |
Copyright 1996 University of Cambridge |
|
5 |
||
6 |
Theory of Shared Keys (common to all symmetric-key protocols) |
|
7 |
||
8 |
Server keys; initial states of agents; new nonces and keys; function "sees" |
|
9 |
||
10 |
||
11 |
*) |
|
12 |
||
13 |
Addsimps [parts_cut_eq]; |
|
14 |
||
2000 | 15 |
(*GOALS.ML??*) |
16 |
fun prlim n = (goals_limit:=n; pr()); |
|
17 |
||
1934 | 18 |
(*FUN.ML?? WE NEED A NOTION OF INVERSE IMAGE, OR GRAPH!!*) |
19 |
goal Set.thy "!!f. B <= range f = (B = f`` {x. f x: B})"; |
|
20 |
by (fast_tac (!claset addEs [equalityE]) 1); |
|
21 |
val subset_range_iff = result(); |
|
22 |
||
23 |
||
24 |
open Shared; |
|
25 |
||
1964 | 26 |
(*Holds because Friend is injective: thus cannot prove for all f*) |
27 |
goal thy "(Friend x : Friend``A) = (x:A)"; |
|
28 |
by (Auto_tac()); |
|
29 |
qed "Friend_image_eq"; |
|
30 |
Addsimps [Friend_image_eq]; |
|
31 |
||
1934 | 32 |
Addsimps [Un_insert_left, Un_insert_right]; |
33 |
||
34 |
(*By default only o_apply is built-in. But in the presence of eta-expansion |
|
35 |
this means that some terms displayed as (f o g) will be rewritten, and others |
|
36 |
will not!*) |
|
37 |
Addsimps [o_def]; |
|
38 |
||
1943 | 39 |
(*** Basic properties of shrK and newK ***) |
1934 | 40 |
|
1943 | 41 |
(* invKey (shrK A) = shrK A *) |
42 |
bind_thm ("invKey_shrK", rewrite_rule [isSymKey_def] isSym_shrK); |
|
1934 | 43 |
|
44 |
(* invKey (newK evs) = newK evs *) |
|
45 |
bind_thm ("invKey_newK", rewrite_rule [isSymKey_def] isSym_newK); |
|
1943 | 46 |
Addsimps [invKey_shrK, invKey_newK]; |
1934 | 47 |
|
48 |
||
1993 | 49 |
(*Injectiveness and freshness of new keys and nonces*) |
50 |
AddIffs [inj_shrK RS inj_eq, inj_newN RS inj_eq, inj_newK RS inj_eq, |
|
51 |
fresh_newN, fresh_newK]; |
|
1934 | 52 |
|
53 |
(** Rewrites should not refer to initState(Friend i) |
|
54 |
-- not in normal form! **) |
|
55 |
||
1943 | 56 |
goal thy "newK evs ~= shrK B"; |
57 |
by (subgoal_tac "newK evs = shrK B --> \ |
|
1934 | 58 |
\ Key (newK evs) : parts (initState B)" 1); |
59 |
by (Fast_tac 1); |
|
60 |
by (agent.induct_tac "B" 1); |
|
1967 | 61 |
by (auto_tac (!claset addIs [range_eqI], !simpset addsimps [bad_def])); |
1943 | 62 |
qed "newK_neq_shrK"; |
1934 | 63 |
|
1943 | 64 |
Addsimps [newK_neq_shrK, newK_neq_shrK RS not_sym]; |
1934 | 65 |
|
66 |
(*Good for talking about Server's initial state*) |
|
67 |
goal thy "!!H. H <= Key``E ==> parts H = H"; |
|
68 |
by (Auto_tac ()); |
|
69 |
be parts.induct 1; |
|
70 |
by (ALLGOALS (fast_tac (!claset addss (!simpset)))); |
|
71 |
qed "parts_image_subset"; |
|
72 |
||
73 |
bind_thm ("parts_image_Key", subset_refl RS parts_image_subset); |
|
74 |
||
75 |
goal thy "!!H. H <= Key``E ==> analz H = H"; |
|
76 |
by (Auto_tac ()); |
|
77 |
be analz.induct 1; |
|
78 |
by (ALLGOALS (fast_tac (!claset addss (!simpset)))); |
|
79 |
qed "analz_image_subset"; |
|
80 |
||
81 |
bind_thm ("analz_image_Key", subset_refl RS analz_image_subset); |
|
82 |
||
83 |
Addsimps [parts_image_Key, analz_image_Key]; |
|
84 |
||
85 |
goalw thy [keysFor_def] "keysFor (parts (initState C)) = {}"; |
|
86 |
by (agent.induct_tac "C" 1); |
|
1993 | 87 |
by (auto_tac (!claset addIs [range_eqI], !simpset)); |
1934 | 88 |
qed "keysFor_parts_initState"; |
89 |
Addsimps [keysFor_parts_initState]; |
|
90 |
||
91 |
goalw thy [keysFor_def] "keysFor (Key``E) = {}"; |
|
92 |
by (Auto_tac ()); |
|
93 |
qed "keysFor_image_Key"; |
|
94 |
Addsimps [keysFor_image_Key]; |
|
95 |
||
1943 | 96 |
goal thy "shrK A ~: newK``E"; |
1934 | 97 |
by (agent.induct_tac "A" 1); |
98 |
by (Auto_tac ()); |
|
1943 | 99 |
qed "shrK_notin_image_newK"; |
100 |
Addsimps [shrK_notin_image_newK]; |
|
1934 | 101 |
|
1964 | 102 |
(*Agents see their own shared keys!*) |
103 |
goal thy "Key (shrK A) : sees A evs"; |
|
1934 | 104 |
by (list.induct_tac "evs" 1); |
105 |
by (agent.induct_tac "A" 1); |
|
1967 | 106 |
by (auto_tac (!claset, !simpset addsimps [bad_def])); |
1964 | 107 |
qed "sees_own_shrK"; |
1934 | 108 |
|
1967 | 109 |
(*Enemy sees shared keys of bad agents!*) |
110 |
goal thy "!!i. A: bad ==> Key (shrK A) : sees Enemy evs"; |
|
1964 | 111 |
by (list.induct_tac "evs" 1); |
1967 | 112 |
by (auto_tac (!claset, !simpset addsimps [bad_def])); |
113 |
qed "Enemy_sees_bad"; |
|
1934 | 114 |
|
1967 | 115 |
AddSIs [sees_own_shrK, Enemy_sees_bad]; |
1934 | 116 |
|
1993 | 117 |
goal thy "Enemy: bad"; |
118 |
by (simp_tac (!simpset addsimps [bad_def]) 1); |
|
119 |
qed "Enemy_in_bad"; |
|
120 |
||
121 |
AddIffs [Enemy_in_bad]; |
|
1934 | 122 |
|
2026
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2012
diff
changeset
|
123 |
goal thy "!!A. A ~: bad ==> A ~= Enemy"; |
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2012
diff
changeset
|
124 |
by (Fast_tac 1); |
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2012
diff
changeset
|
125 |
qed "not_bad_imp_not_Enemy"; |
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2012
diff
changeset
|
126 |
|
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2012
diff
changeset
|
127 |
AddIffs [Enemy_in_bad]; |
0df5a96bf77e
Last working version prior to introduction of "lost"
paulson
parents:
2012
diff
changeset
|
128 |
|
1934 | 129 |
(** Specialized rewrite rules for (sees A (Says...#evs)) **) |
130 |
||
131 |
goal thy "sees A (Says A B X # evs) = insert X (sees A evs)"; |
|
132 |
by (Simp_tac 1); |
|
133 |
qed "sees_own"; |
|
134 |
||
135 |
goal thy "!!A. Server ~= A ==> \ |
|
136 |
\ sees Server (Says A B X # evs) = sees Server evs"; |
|
137 |
by (Asm_simp_tac 1); |
|
138 |
qed "sees_Server"; |
|
139 |
||
140 |
goal thy "!!A. Friend i ~= A ==> \ |
|
141 |
\ sees (Friend i) (Says A B X # evs) = sees (Friend i) evs"; |
|
142 |
by (Asm_simp_tac 1); |
|
143 |
qed "sees_Friend"; |
|
144 |
||
145 |
goal thy "sees Enemy (Says A B X # evs) = insert X (sees Enemy evs)"; |
|
146 |
by (Simp_tac 1); |
|
147 |
qed "sees_Enemy"; |
|
148 |
||
149 |
goal thy "sees A (Says A' B X # evs) <= insert X (sees A evs)"; |
|
150 |
by (simp_tac (!simpset setloop split_tac [expand_if]) 1); |
|
151 |
by (Fast_tac 1); |
|
152 |
qed "sees_Says_subset_insert"; |
|
153 |
||
154 |
goal thy "sees A evs <= sees A (Says A' B X # evs)"; |
|
155 |
by (simp_tac (!simpset setloop split_tac [expand_if]) 1); |
|
156 |
by (Fast_tac 1); |
|
157 |
qed "sees_subset_sees_Says"; |
|
158 |
||
159 |
(*Pushing Unions into parts; one of the A's equals B, and thus sees Y*) |
|
160 |
goal thy "(UN A. parts (sees A (Says B C Y # evs))) = \ |
|
161 |
\ parts {Y} Un (UN A. parts (sees A evs))"; |
|
162 |
by (Step_tac 1); |
|
163 |
be rev_mp 1; (*for some reason, split_tac does not work on assumptions*) |
|
164 |
val ss = (!simpset addsimps [parts_Un, sees_Cons] |
|
165 |
setloop split_tac [expand_if]); |
|
166 |
by (ALLGOALS (fast_tac (!claset addss ss))); |
|
167 |
qed "UN_parts_sees_Says"; |
|
168 |
||
169 |
goal thy "Says A B X : set_of_list evs --> X : sees Enemy evs"; |
|
170 |
by (list.induct_tac "evs" 1); |
|
171 |
by (Auto_tac ()); |
|
172 |
qed_spec_mp "Says_imp_sees_Enemy"; |
|
173 |
||
174 |
Addsimps [Says_imp_sees_Enemy]; |
|
175 |
AddIs [Says_imp_sees_Enemy]; |
|
176 |
||
1943 | 177 |
goal thy "initState C <= Key `` range shrK"; |
1934 | 178 |
by (agent.induct_tac "C" 1); |
179 |
by (Auto_tac ()); |
|
180 |
qed "initState_subset"; |
|
181 |
||
182 |
goal thy "X : sees C evs --> \ |
|
183 |
\ (EX A B. Says A B X : set_of_list evs) | \ |
|
1943 | 184 |
\ (EX A. X = Key (shrK A))"; |
1934 | 185 |
by (list.induct_tac "evs" 1); |
186 |
by (ALLGOALS Asm_simp_tac); |
|
187 |
by (fast_tac (!claset addDs [impOfSubs initState_subset]) 1); |
|
188 |
br conjI 1; |
|
189 |
by (Fast_tac 2); |
|
190 |
by (event.induct_tac "a" 1); |
|
191 |
by (ALLGOALS (asm_simp_tac (!simpset addsimps [mem_if]))); |
|
192 |
by (ALLGOALS Fast_tac); |
|
193 |
qed_spec_mp "seesD"; |
|
194 |
||
195 |
||
196 |
Addsimps [UN_parts_sees_Says, sees_own, sees_Server, sees_Friend, sees_Enemy]; |
|
197 |
Delsimps [sees_Cons]; (**** NOTE REMOVAL -- laws above are cleaner ****) |
|
198 |
||
199 |
||
200 |
goal thy "!!K. newK evs = invKey K ==> newK evs = K"; |
|
201 |
br (invKey_eq RS iffD1) 1; |
|
202 |
by (Simp_tac 1); |
|
203 |
val newK_invKey = result(); |
|
204 |
||
1993 | 205 |
AddSDs [newK_invKey]; |
1934 | 206 |
|
207 |
(** Rewrites to push in Key and Crypt messages, so that other messages can |
|
208 |
be pulled out using the analz_insert rules **) |
|
209 |
||
210 |
fun insComm x y = read_instantiate_sg (sign_of thy) [("x",x), ("y",y)] |
|
211 |
insert_commute; |
|
212 |
||
213 |
val pushKeys = map (insComm "Key ?K") |
|
214 |
["Agent ?C", "Nonce ?N", "MPair ?X ?Y", "Crypt ?X ?K'"]; |
|
215 |
||
216 |
val pushCrypts = map (insComm "Crypt ?X ?K") |
|
217 |
["Agent ?C", "Nonce ?N", "MPair ?X' ?Y"]; |
|
218 |
||
219 |
(*Cannot be added with Addsimps -- we don't always want to re-order messages*) |
|
220 |
val pushes = pushKeys@pushCrypts; |
|
221 |
||
1943 | 222 |
val pushKey_newK = insComm "Key (newK ?evs)" "Key (shrK ?C)"; |
1934 | 223 |
|
224 |
||
1993 | 225 |
(*No premature instantiation of variables. For proving weak liveness.*) |
226 |
fun safe_solver prems = |
|
227 |
match_tac (TrueI::refl::prems) ORELSE' eq_assume_tac |
|
228 |
ORELSE' etac FalseE; |
|
229 |
||
2000 | 230 |
(*Analysis of Fake cases and of messages that forward unknown parts |
231 |
Abstraction over i is ESSENTIAL: it delays the dereferencing of claset*) |
|
232 |
fun enemy_analz_tac i = |
|
1993 | 233 |
SELECT_GOAL |
234 |
(EVERY [ (*push in occurrences of X...*) |
|
235 |
(REPEAT o CHANGED) |
|
236 |
(res_inst_tac [("x1","X")] (insert_commute RS ssubst) 1), |
|
237 |
(*...allowing further simplifications*) |
|
238 |
simp_tac (!simpset setloop split_tac [expand_if]) 1, |
|
239 |
REPEAT (resolve_tac [impI,notI] 1), |
|
240 |
dtac (impOfSubs Fake_analz_insert) 1, |
|
241 |
eresolve_tac [asm_rl, synth.Inj] 1, |
|
242 |
Fast_tac 1, |
|
243 |
Asm_full_simp_tac 1, |
|
244 |
IF_UNSOLVED (deepen_tac (!claset addIs [impOfSubs analz_mono]) 0 1) |
|
2000 | 245 |
]) i; |
1993 | 246 |
|
247 |
||
2012 | 248 |
(** Simplifying parts (insert X (sees A evs)) |
249 |
= parts {X} Un parts (sees A evs) -- since general case loops*) |
|
250 |
||
251 |
val parts_insert_sees = |
|
252 |
parts_insert |> read_instantiate_sg (sign_of thy) [("H", "sees A evs")] |
|
253 |
|> standard; |
|
254 |