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