2002
|
1 |
(* Title: HOL/Auth/OtwayRees_Bad
|
|
2 |
ID: $Id$
|
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory
|
|
4 |
Copyright 1996 University of Cambridge
|
|
5 |
|
|
6 |
Inductive relation "otway" for the Otway-Rees protocol.
|
|
7 |
|
|
8 |
The FAULTY version omitting encryption of Nonce NB, as suggested on page 247 of
|
|
9 |
Burrows, Abadi and Needham. A Logic of Authentication.
|
|
10 |
Proc. Royal Soc. 426 (1989)
|
|
11 |
|
|
12 |
This file illustrates the consequences of such errors. We can still prove
|
2032
|
13 |
impressive-looking properties such as Spy_not_see_encrypted_key, yet the
|
2002
|
14 |
protocol is open to a middleperson attack. Attempting to prove some key lemmas
|
|
15 |
indicates the possibility of this attack.
|
|
16 |
*)
|
|
17 |
|
|
18 |
open OtwayRees_Bad;
|
|
19 |
|
|
20 |
proof_timing:=true;
|
|
21 |
HOL_quantifiers := false;
|
|
22 |
|
|
23 |
|
|
24 |
(*Weak liveness: there are traces that reach the end*)
|
|
25 |
goal thy
|
|
26 |
"!!A B. [| A ~= B; A ~= Server; B ~= Server |] \
|
|
27 |
\ ==> EX K. EX NA. EX evs: otway. \
|
|
28 |
\ Says B A {|Nonce NA, Crypt {|Nonce NA, Key K|} (shrK A)|} \
|
|
29 |
\ : set_of_list evs";
|
|
30 |
by (REPEAT (resolve_tac [exI,bexI] 1));
|
2032
|
31 |
by (rtac (otway.Nil RS otway.OR1 RS otway.OR2 RS otway.OR3 RS otway.OR4) 2);
|
2002
|
32 |
by (ALLGOALS (simp_tac (!simpset setsolver safe_solver)));
|
|
33 |
by (REPEAT_FIRST (resolve_tac [refl, conjI]));
|
|
34 |
by (ALLGOALS (fast_tac (!claset addss (!simpset setsolver safe_solver))));
|
|
35 |
result();
|
|
36 |
|
|
37 |
|
|
38 |
(**** Inductive proofs about otway ****)
|
|
39 |
|
2032
|
40 |
(*The Spy can see more than anybody else, except for their initial state*)
|
2002
|
41 |
goal thy
|
|
42 |
"!!evs. evs : otway ==> \
|
2032
|
43 |
\ sees A evs <= initState A Un sees Spy evs";
|
|
44 |
by (etac otway.induct 1);
|
2002
|
45 |
by (ALLGOALS (fast_tac (!claset addDs [sees_Says_subset_insert RS subsetD]
|
2032
|
46 |
addss (!simpset))));
|
|
47 |
qed "sees_agent_subset_sees_Spy";
|
2002
|
48 |
|
|
49 |
|
|
50 |
(*Nobody sends themselves messages*)
|
|
51 |
goal thy "!!evs. evs : otway ==> ALL A X. Says A A X ~: set_of_list evs";
|
2032
|
52 |
by (etac otway.induct 1);
|
2002
|
53 |
by (Auto_tac());
|
|
54 |
qed_spec_mp "not_Says_to_self";
|
|
55 |
Addsimps [not_Says_to_self];
|
|
56 |
AddSEs [not_Says_to_self RSN (2, rev_notE)];
|
|
57 |
|
|
58 |
|
|
59 |
(** For reasoning about the encrypted portion of messages **)
|
|
60 |
|
|
61 |
goal thy "!!evs. Says A' B {|N, Agent A, Agent B, X|} : set_of_list evs ==> \
|
2032
|
62 |
\ X : analz (sees Spy evs)";
|
|
63 |
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS analz.Inj]) 1);
|
|
64 |
qed "OR2_analz_sees_Spy";
|
2002
|
65 |
|
|
66 |
goal thy "!!evs. Says S B {|N, X, X'|} : set_of_list evs ==> \
|
2032
|
67 |
\ X : analz (sees Spy evs)";
|
|
68 |
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS analz.Inj]) 1);
|
|
69 |
qed "OR4_analz_sees_Spy";
|
2002
|
70 |
|
|
71 |
goal thy "!!evs. Says B' A {|N, Crypt {|N,K|} K'|} : set_of_list evs ==> \
|
2032
|
72 |
\ K : parts (sees Spy evs)";
|
2002
|
73 |
by (fast_tac (!claset addSEs partsEs
|
2032
|
74 |
addSDs [Says_imp_sees_Spy RS parts.Inj]) 1);
|
|
75 |
qed "Reveal_parts_sees_Spy";
|
2002
|
76 |
|
|
77 |
(*OR2_analz... and OR4_analz... let us treat those cases using the same
|
|
78 |
argument as for the Fake case. This is possible for most, but not all,
|
|
79 |
proofs: Fake does not invent new nonces (as in OR2), and of course Fake
|
2032
|
80 |
messages originate from the Spy. *)
|
2002
|
81 |
|
|
82 |
val parts_Fake_tac =
|
2032
|
83 |
dtac (OR2_analz_sees_Spy RS (impOfSubs analz_subset_parts)) 4 THEN
|
|
84 |
dtac (OR4_analz_sees_Spy RS (impOfSubs analz_subset_parts)) 6 THEN
|
|
85 |
dtac Reveal_parts_sees_Spy 7;
|
2002
|
86 |
|
|
87 |
|
2032
|
88 |
(** Theorems of the form X ~: parts (sees Spy evs) imply that NOBODY
|
2002
|
89 |
sends messages containing X! **)
|
|
90 |
|
2032
|
91 |
(*Spy never sees another agent's shared key! (unless it is leaked at start)*)
|
2002
|
92 |
goal thy
|
|
93 |
"!!evs. [| evs : otway; A ~: bad |] \
|
2032
|
94 |
\ ==> Key (shrK A) ~: parts (sees Spy evs)";
|
|
95 |
by (etac otway.induct 1);
|
2002
|
96 |
by parts_Fake_tac;
|
|
97 |
by (Auto_tac());
|
|
98 |
(*Deals with Fake message*)
|
|
99 |
by (best_tac (!claset addDs [impOfSubs analz_subset_parts,
|
2032
|
100 |
impOfSubs Fake_parts_insert]) 1);
|
|
101 |
qed "Spy_not_see_shrK";
|
2002
|
102 |
|
2032
|
103 |
bind_thm ("Spy_not_analz_shrK",
|
|
104 |
[analz_subset_parts, Spy_not_see_shrK] MRS contra_subsetD);
|
2002
|
105 |
|
2032
|
106 |
Addsimps [Spy_not_see_shrK, Spy_not_analz_shrK];
|
2002
|
107 |
|
|
108 |
(*We go to some trouble to preserve R in the 3rd and 4th subgoals
|
|
109 |
As usual fast_tac cannot be used because it uses the equalities too soon*)
|
|
110 |
val major::prems =
|
2032
|
111 |
goal thy "[| Key (shrK A) : parts (sees Spy evs); \
|
2002
|
112 |
\ evs : otway; \
|
|
113 |
\ A:bad ==> R \
|
|
114 |
\ |] ==> R";
|
2032
|
115 |
by (rtac ccontr 1);
|
|
116 |
by (rtac ([major, Spy_not_see_shrK] MRS rev_notE) 1);
|
2002
|
117 |
by (swap_res_tac prems 2);
|
|
118 |
by (ALLGOALS (fast_tac (!claset addIs prems)));
|
2032
|
119 |
qed "Spy_see_shrK_E";
|
2002
|
120 |
|
2032
|
121 |
bind_thm ("Spy_analz_shrK_E",
|
|
122 |
analz_subset_parts RS subsetD RS Spy_see_shrK_E);
|
2002
|
123 |
|
2032
|
124 |
AddSEs [Spy_see_shrK_E, Spy_analz_shrK_E];
|
2002
|
125 |
|
|
126 |
|
|
127 |
(*** Future keys can't be seen or used! ***)
|
|
128 |
|
|
129 |
(*Nobody can have SEEN keys that will be generated in the future.
|
|
130 |
This has to be proved anew for each protocol description,
|
|
131 |
but should go by similar reasoning every time. Hardest case is the
|
|
132 |
standard Fake rule.
|
|
133 |
The Union over C is essential for the induction! *)
|
|
134 |
goal thy "!!evs. evs : otway ==> \
|
|
135 |
\ length evs <= length evs' --> \
|
|
136 |
\ Key (newK evs') ~: (UN C. parts (sees C evs))";
|
2032
|
137 |
by (etac otway.induct 1);
|
2002
|
138 |
by parts_Fake_tac;
|
|
139 |
(*auto_tac does not work here, as it performs safe_tac first*)
|
|
140 |
by (ALLGOALS Asm_simp_tac);
|
|
141 |
by (REPEAT_FIRST (best_tac (!claset addDs [impOfSubs analz_subset_parts,
|
2032
|
142 |
impOfSubs parts_insert_subset_Un,
|
|
143 |
Suc_leD]
|
|
144 |
addss (!simpset))));
|
2002
|
145 |
val lemma = result();
|
|
146 |
|
|
147 |
(*Variant needed for the main theorem below*)
|
|
148 |
goal thy
|
|
149 |
"!!evs. [| evs : otway; length evs <= length evs' |] \
|
|
150 |
\ ==> Key (newK evs') ~: parts (sees C evs)";
|
|
151 |
by (fast_tac (!claset addDs [lemma]) 1);
|
|
152 |
qed "new_keys_not_seen";
|
|
153 |
Addsimps [new_keys_not_seen];
|
|
154 |
|
|
155 |
(*Another variant: old messages must contain old keys!*)
|
|
156 |
goal thy
|
|
157 |
"!!evs. [| Says A B X : set_of_list evs; \
|
|
158 |
\ Key (newK evt) : parts {X}; \
|
|
159 |
\ evs : otway \
|
|
160 |
\ |] ==> length evt < length evs";
|
2032
|
161 |
by (rtac ccontr 1);
|
|
162 |
by (fast_tac (!claset addSDs [new_keys_not_seen, Says_imp_sees_Spy]
|
|
163 |
addIs [impOfSubs parts_mono, leI]) 1);
|
2002
|
164 |
qed "Says_imp_old_keys";
|
|
165 |
|
|
166 |
|
|
167 |
(*** Future nonces can't be seen or used! [proofs resemble those above] ***)
|
|
168 |
|
|
169 |
goal thy "!!evs. evs : otway ==> \
|
|
170 |
\ length evs <= length evs' --> \
|
|
171 |
\ Nonce (newN evs') ~: (UN C. parts (sees C evs))";
|
2032
|
172 |
by (etac otway.induct 1);
|
2002
|
173 |
(*auto_tac does not work here, as it performs safe_tac first*)
|
|
174 |
by (ALLGOALS (asm_simp_tac (!simpset addsimps [de_Morgan_disj]
|
|
175 |
addcongs [conj_cong])));
|
|
176 |
by (REPEAT_FIRST (fast_tac (!claset (*60 seconds???*)
|
2032
|
177 |
addSEs [MPair_parts]
|
|
178 |
addDs [Says_imp_sees_Spy RS parts.Inj,
|
|
179 |
impOfSubs analz_subset_parts,
|
|
180 |
impOfSubs parts_insert_subset_Un,
|
|
181 |
Suc_leD]
|
|
182 |
addss (!simpset))));
|
2002
|
183 |
val lemma = result();
|
|
184 |
|
|
185 |
(*Variant needed for the main theorem below*)
|
|
186 |
goal thy
|
|
187 |
"!!evs. [| evs : otway; length evs <= length evs' |] \
|
|
188 |
\ ==> Nonce (newN evs') ~: parts (sees C evs)";
|
|
189 |
by (fast_tac (!claset addDs [lemma]) 1);
|
|
190 |
qed "new_nonces_not_seen";
|
|
191 |
Addsimps [new_nonces_not_seen];
|
|
192 |
|
|
193 |
(*Another variant: old messages must contain old nonces!*)
|
|
194 |
goal thy
|
|
195 |
"!!evs. [| Says A B X : set_of_list evs; \
|
|
196 |
\ Nonce (newN evt) : parts {X}; \
|
|
197 |
\ evs : otway \
|
|
198 |
\ |] ==> length evt < length evs";
|
2032
|
199 |
by (rtac ccontr 1);
|
|
200 |
by (fast_tac (!claset addSDs [new_nonces_not_seen, Says_imp_sees_Spy]
|
|
201 |
addIs [impOfSubs parts_mono, leI]) 1);
|
2002
|
202 |
qed "Says_imp_old_nonces";
|
|
203 |
|
|
204 |
|
|
205 |
(*Nobody can have USED keys that will be generated in the future.
|
|
206 |
...very like new_keys_not_seen*)
|
|
207 |
goal thy "!!evs. evs : otway ==> \
|
|
208 |
\ length evs <= length evs' --> \
|
|
209 |
\ newK evs' ~: keysFor (UN C. parts (sees C evs))";
|
2032
|
210 |
by (etac otway.induct 1);
|
2002
|
211 |
by parts_Fake_tac;
|
|
212 |
by (ALLGOALS Asm_simp_tac);
|
|
213 |
(*OR1 and OR3*)
|
|
214 |
by (EVERY (map (fast_tac (!claset addDs [Suc_leD] addss (!simpset))) [4,2]));
|
|
215 |
(*Fake, OR2, OR4: these messages send unknown (X) components*)
|
|
216 |
by (EVERY
|
|
217 |
(map
|
|
218 |
(best_tac
|
|
219 |
(!claset addDs [impOfSubs (analz_subset_parts RS keysFor_mono),
|
2032
|
220 |
impOfSubs (parts_insert_subset_Un RS keysFor_mono),
|
|
221 |
Suc_leD]
|
|
222 |
addEs [new_keys_not_seen RS not_parts_not_analz RSN(2,rev_notE)]
|
|
223 |
addss (!simpset)))
|
2002
|
224 |
[3,2,1]));
|
|
225 |
(*Reveal: dummy message*)
|
|
226 |
by (best_tac (!claset addEs [new_keys_not_seen RSN(2,rev_notE)]
|
2032
|
227 |
addIs [less_SucI, impOfSubs keysFor_mono]
|
|
228 |
addss (!simpset addsimps [le_def])) 1);
|
2002
|
229 |
val lemma = result();
|
|
230 |
|
|
231 |
goal thy
|
|
232 |
"!!evs. [| evs : otway; length evs <= length evs' |] \
|
|
233 |
\ ==> newK evs' ~: keysFor (parts (sees C evs))";
|
|
234 |
by (fast_tac (!claset addSDs [lemma] addss (!simpset)) 1);
|
|
235 |
qed "new_keys_not_used";
|
|
236 |
|
|
237 |
bind_thm ("new_keys_not_analzd",
|
2032
|
238 |
[analz_subset_parts RS keysFor_mono,
|
|
239 |
new_keys_not_used] MRS contra_subsetD);
|
2002
|
240 |
|
|
241 |
Addsimps [new_keys_not_used, new_keys_not_analzd];
|
|
242 |
|
|
243 |
|
|
244 |
(** Lemmas concerning the form of items passed in messages **)
|
|
245 |
|
|
246 |
|
|
247 |
(****
|
|
248 |
The following is to prove theorems of the form
|
|
249 |
|
2032
|
250 |
Key K : analz (insert (Key (newK evt)) (sees Spy evs)) ==>
|
|
251 |
Key K : analz (sees Spy evs)
|
2002
|
252 |
|
|
253 |
A more general formula must be proved inductively.
|
|
254 |
|
|
255 |
****)
|
|
256 |
|
|
257 |
|
|
258 |
(*NOT useful in this form, but it says that session keys are not used
|
|
259 |
to encrypt messages containing other keys, in the actual protocol.
|
|
260 |
We require that agents should behave like this subsequently also.*)
|
|
261 |
goal thy
|
|
262 |
"!!evs. evs : otway ==> \
|
2032
|
263 |
\ (Crypt X (newK evt)) : parts (sees Spy evs) & \
|
|
264 |
\ Key K : parts {X} --> Key K : parts (sees Spy evs)";
|
|
265 |
by (etac otway.induct 1);
|
2002
|
266 |
by parts_Fake_tac;
|
|
267 |
by (ALLGOALS (asm_simp_tac (!simpset addsimps pushes)));
|
|
268 |
(*Deals with Faked messages*)
|
|
269 |
by (best_tac (!claset addSEs partsEs
|
2032
|
270 |
addDs [impOfSubs analz_subset_parts,
|
2002
|
271 |
impOfSubs parts_insert_subset_Un]
|
|
272 |
addss (!simpset)) 2);
|
|
273 |
(*Base case and Reveal*)
|
|
274 |
by (Auto_tac());
|
|
275 |
result();
|
|
276 |
|
|
277 |
|
|
278 |
(** Specialized rewriting for this proof **)
|
|
279 |
|
|
280 |
Delsimps [image_insert];
|
|
281 |
Addsimps [image_insert RS sym];
|
|
282 |
|
|
283 |
Delsimps [image_Un];
|
|
284 |
Addsimps [image_Un RS sym];
|
|
285 |
|
|
286 |
goal thy "insert (Key (newK x)) (sees A evs) = \
|
|
287 |
\ Key `` (newK``{x}) Un (sees A evs)";
|
|
288 |
by (Fast_tac 1);
|
|
289 |
val insert_Key_singleton = result();
|
|
290 |
|
|
291 |
goal thy "insert (Key (f x)) (Key``(f``E) Un C) = \
|
|
292 |
\ Key `` (f `` (insert x E)) Un C";
|
|
293 |
by (Fast_tac 1);
|
|
294 |
val insert_Key_image = result();
|
|
295 |
|
|
296 |
|
|
297 |
(*This lets us avoid analyzing the new message -- unless we have to!*)
|
|
298 |
(*NEEDED??*)
|
2032
|
299 |
goal thy "synth (analz (sees Spy evs)) <= \
|
|
300 |
\ synth (analz (sees Spy (Says A B X # evs)))";
|
2002
|
301 |
by (Simp_tac 1);
|
2032
|
302 |
by (rtac (subset_insertI RS analz_mono RS synth_mono) 1);
|
2002
|
303 |
qed "synth_analz_thin";
|
|
304 |
|
|
305 |
AddIs [impOfSubs synth_analz_thin];
|
|
306 |
|
|
307 |
|
|
308 |
|
|
309 |
(** Session keys are not used to encrypt other session keys **)
|
|
310 |
|
|
311 |
(*Describes the form of Key K when the following message is sent. The use of
|
|
312 |
"parts" strengthens the induction hyp for proving the Fake case. The
|
|
313 |
assumptions on A are needed to prevent its being a Faked message. (Based
|
|
314 |
on NS_Shared/Says_S_message_form) *)
|
|
315 |
goal thy
|
|
316 |
"!!evs. evs: otway ==> \
|
2032
|
317 |
\ Crypt {|N, Key K|} (shrK A) : parts (sees Spy evs) & \
|
2002
|
318 |
\ A ~: bad --> \
|
|
319 |
\ (EX evt:otway. K = newK evt)";
|
2032
|
320 |
by (etac otway.induct 1);
|
2002
|
321 |
by parts_Fake_tac;
|
|
322 |
by (Auto_tac());
|
|
323 |
(*Deals with Fake message*)
|
|
324 |
by (best_tac (!claset addDs [impOfSubs analz_subset_parts,
|
2032
|
325 |
impOfSubs Fake_parts_insert]) 1);
|
2002
|
326 |
val lemma = result() RS mp;
|
|
327 |
|
|
328 |
|
|
329 |
(*EITHER describes the form of Key K when the following message is sent,
|
|
330 |
OR reduces it to the Fake case.*)
|
|
331 |
goal thy
|
|
332 |
"!!evs. [| Says B' A {|N, Crypt {|N, Key K|} (shrK A)|} : set_of_list evs; \
|
|
333 |
\ evs : otway |] \
|
2032
|
334 |
\ ==> (EX evt:otway. K = newK evt) | Key K : analz (sees Spy evs)";
|
2002
|
335 |
by (excluded_middle_tac "A : bad" 1);
|
2032
|
336 |
by (fast_tac (!claset addSDs [Says_imp_sees_Spy RS analz.Inj]
|
|
337 |
addss (!simpset)) 2);
|
2002
|
338 |
by (forward_tac [lemma] 1);
|
|
339 |
by (fast_tac (!claset addEs partsEs
|
2032
|
340 |
addSDs [Says_imp_sees_Spy RS parts.Inj]) 1);
|
2002
|
341 |
by (Fast_tac 1);
|
|
342 |
qed "Reveal_message_form";
|
|
343 |
|
|
344 |
|
|
345 |
(*Lemma for the trivial direction of the if-and-only-if*)
|
|
346 |
goal thy
|
|
347 |
"!!evs. (Key K : analz (Key``nE Un sEe)) --> \
|
|
348 |
\ (K : nE | Key K : analz sEe) ==> \
|
|
349 |
\ (Key K : analz (Key``nE Un sEe)) = (K : nE | Key K : analz sEe)";
|
|
350 |
by (fast_tac (!claset addSEs [impOfSubs analz_mono]) 1);
|
|
351 |
val lemma = result();
|
|
352 |
|
|
353 |
|
|
354 |
(*The equality makes the induction hypothesis easier to apply*)
|
|
355 |
goal thy
|
|
356 |
"!!evs. evs : otway ==> \
|
2032
|
357 |
\ ALL K E. (Key K : analz (Key``(newK``E) Un (sees Spy evs))) = \
|
|
358 |
\ (K : newK``E | Key K : analz (sees Spy evs))";
|
|
359 |
by (etac otway.induct 1);
|
|
360 |
by (dtac OR2_analz_sees_Spy 4);
|
|
361 |
by (dtac OR4_analz_sees_Spy 6);
|
|
362 |
by (dtac Reveal_message_form 7);
|
2002
|
363 |
by (REPEAT_FIRST (ares_tac [allI, lemma]));
|
|
364 |
by (REPEAT ((eresolve_tac [bexE, disjE] ORELSE' hyp_subst_tac) 7));
|
|
365 |
by (ALLGOALS (*Takes 28 secs*)
|
|
366 |
(asm_simp_tac
|
|
367 |
(!simpset addsimps ([insert_Key_singleton, insert_Key_image, pushKey_newK]
|
2032
|
368 |
@ pushes)
|
2002
|
369 |
setloop split_tac [expand_if])));
|
|
370 |
(** LEVEL 7 **)
|
|
371 |
(*Reveal case 2, OR4, OR2, Fake*)
|
2032
|
372 |
by (EVERY (map spy_analz_tac [7,5,3,2]));
|
2002
|
373 |
(*Reveal case 1, OR3, Base*)
|
|
374 |
by (Auto_tac());
|
|
375 |
qed_spec_mp "analz_image_newK";
|
|
376 |
|
|
377 |
|
|
378 |
goal thy
|
|
379 |
"!!evs. evs : otway ==> \
|
2032
|
380 |
\ Key K : analz (insert (Key (newK evt)) (sees Spy evs)) = \
|
|
381 |
\ (K = newK evt | Key K : analz (sees Spy evs))";
|
2002
|
382 |
by (asm_simp_tac (HOL_ss addsimps [pushKey_newK, analz_image_newK,
|
2032
|
383 |
insert_Key_singleton]) 1);
|
2002
|
384 |
by (Fast_tac 1);
|
|
385 |
qed "analz_insert_Key_newK";
|
|
386 |
|
|
387 |
|
|
388 |
(*Describes the form of K and NA when the Server sends this message.*)
|
|
389 |
goal thy
|
|
390 |
"!!evs. [| Says Server B \
|
|
391 |
\ {|NA, Crypt {|NA, K|} (shrK A), \
|
|
392 |
\ Crypt {|NB, K|} (shrK B)|} : set_of_list evs; \
|
|
393 |
\ evs : otway |] \
|
|
394 |
\ ==> (EX evt:otway. K = Key(newK evt)) & \
|
|
395 |
\ (EX i. NA = Nonce i)";
|
2032
|
396 |
by (etac rev_mp 1);
|
|
397 |
by (etac otway.induct 1);
|
2002
|
398 |
by (ALLGOALS (fast_tac (!claset addIs [less_SucI] addss (!simpset))));
|
|
399 |
qed "Says_Server_message_form";
|
|
400 |
|
|
401 |
|
|
402 |
(*Crucial security property, but not itself enough to guarantee correctness!
|
|
403 |
The need for quantification over N, C seems to indicate the problem.
|
|
404 |
Omitting the Reveal message from the description deprives us of even
|
2032
|
405 |
this clue. *)
|
2002
|
406 |
goal thy
|
|
407 |
"!!evs. [| A ~: bad; B ~: bad; evs : otway; evt : otway |] \
|
|
408 |
\ ==> Says Server B \
|
|
409 |
\ {|Nonce NA, Crypt {|Nonce NA, Key(newK evt)|} (shrK A), \
|
|
410 |
\ Crypt {|NB, Key(newK evt)|} (shrK B)|} : set_of_list evs --> \
|
2032
|
411 |
\ (ALL N C. Says C Spy {|N, Key(newK evt)|} ~: set_of_list evs) --> \
|
|
412 |
\ Key(newK evt) ~: analz (sees Spy evs)";
|
|
413 |
by (etac otway.induct 1);
|
|
414 |
by (dtac OR2_analz_sees_Spy 4);
|
|
415 |
by (dtac OR4_analz_sees_Spy 6);
|
|
416 |
by (dtac Reveal_message_form 7);
|
2002
|
417 |
by (REPEAT_FIRST (eresolve_tac [asm_rl, bexE, disjE] ORELSE' hyp_subst_tac));
|
|
418 |
by (ALLGOALS
|
|
419 |
(asm_full_simp_tac
|
|
420 |
(!simpset addsimps ([analz_subset_parts RS contra_subsetD,
|
2032
|
421 |
analz_insert_Key_newK] @ pushes)
|
2002
|
422 |
setloop split_tac [expand_if])));
|
|
423 |
(** LEVEL 6 **)
|
|
424 |
(*Reveal case 1*)
|
|
425 |
by (Fast_tac 5);
|
|
426 |
(*OR3*)
|
|
427 |
by (fast_tac (!claset addSIs [parts_insertI]
|
2032
|
428 |
addEs [Says_imp_old_keys RS less_irrefl]
|
|
429 |
addss (!simpset)) 3);
|
2002
|
430 |
(*Reveal case 2, OR4, OR2, Fake*)
|
2032
|
431 |
by (rtac conjI 3);
|
|
432 |
by (REPEAT (spy_analz_tac 1));
|
2002
|
433 |
val lemma = result() RS mp RS mp RSN(2,rev_notE);
|
|
434 |
|
|
435 |
|
|
436 |
|
|
437 |
(*WEAK VERSION: NEED TO ELIMINATE QUANTIFICATION OVER N, C!!*)
|
|
438 |
goal thy
|
|
439 |
"!!evs. [| Says Server B \
|
|
440 |
\ {|NA, Crypt {|NA, K|} (shrK A), \
|
|
441 |
\ Crypt {|NB, K|} (shrK B)|} : set_of_list evs; \
|
2032
|
442 |
\ (ALL N C. Says C Spy {|N, K|} ~: set_of_list evs); \
|
2002
|
443 |
\ A ~: bad; B ~: bad; evs : otway |] \
|
2032
|
444 |
\ ==> K ~: analz (sees Spy evs)";
|
2002
|
445 |
by (forward_tac [Says_Server_message_form] 1 THEN assume_tac 1);
|
|
446 |
by (fast_tac (!claset addSEs [lemma]) 1);
|
2032
|
447 |
qed "Spy_not_see_encrypted_key";
|
2002
|
448 |
|
|
449 |
|
|
450 |
(*** Attempting to prove stronger properties ***)
|
|
451 |
|
|
452 |
(** The Key K uniquely identifies the Server's message. **)
|
|
453 |
|
|
454 |
fun ex_strip_tac i = REPEAT (ares_tac [exI, conjI] i) THEN assume_tac (i+1);
|
|
455 |
|
|
456 |
goal thy
|
|
457 |
"!!evs. evs : otway ==> \
|
|
458 |
\ EX A' B' NA' NB'. ALL A B NA NB. \
|
|
459 |
\ Says Server B \
|
|
460 |
\ {|NA, Crypt {|NA, K|} (shrK A), \
|
|
461 |
\ Crypt {|NB, K|} (shrK B)|} : set_of_list evs --> \
|
|
462 |
\ A=A' & B=B' & NA=NA' & NB=NB'";
|
2032
|
463 |
by (etac otway.induct 1);
|
2002
|
464 |
by (ALLGOALS (asm_simp_tac (!simpset addsimps [all_conj_distrib])));
|
|
465 |
by (Step_tac 1);
|
|
466 |
(*Remaining cases: OR3 and OR4*)
|
|
467 |
by (ex_strip_tac 2);
|
|
468 |
by (Fast_tac 2);
|
|
469 |
by (excluded_middle_tac "K = Key(newK evsa)" 1);
|
|
470 |
by (Asm_simp_tac 1);
|
|
471 |
by (REPEAT (ares_tac [refl,exI,impI,conjI] 1));
|
|
472 |
(*...we assume X is a very new message, and handle this case by contradiction*)
|
|
473 |
by (fast_tac (!claset addEs [Says_imp_old_keys RS less_irrefl]
|
2032
|
474 |
delrules [conjI] (*prevent split-up into 4 subgoals*)
|
|
475 |
addss (!simpset addsimps [parts_insertI])) 1);
|
2002
|
476 |
val lemma = result();
|
|
477 |
|
|
478 |
|
|
479 |
goal thy
|
|
480 |
"!!evs. [| Says Server B \
|
|
481 |
\ {|NA, Crypt {|NA, K|} (shrK A), \
|
|
482 |
\ Crypt {|NB, K|} (shrK B)|} \
|
|
483 |
\ : set_of_list evs; \
|
|
484 |
\ Says Server B' \
|
|
485 |
\ {|NA', Crypt {|NA', K|} (shrK A'), \
|
|
486 |
\ Crypt {|NB', K|} (shrK B')|} \
|
|
487 |
\ : set_of_list evs; \
|
|
488 |
\ evs : otway |] \
|
|
489 |
\ ==> A=A' & B=B' & NA=NA' & NB=NB'";
|
2032
|
490 |
by (dtac lemma 1);
|
2002
|
491 |
by (REPEAT (etac exE 1));
|
|
492 |
(*Duplicate the assumption*)
|
|
493 |
by (forw_inst_tac [("psi", "ALL C.?P(C)")] asm_rl 1);
|
|
494 |
by (fast_tac (!claset addSDs [spec]) 1);
|
|
495 |
qed "unique_session_keys";
|
|
496 |
|
|
497 |
|
|
498 |
(*Could probably remove the A ~= B premise using another induction*)
|
|
499 |
goal thy
|
|
500 |
"!!evs. [| A ~: bad; A ~= B; evs : otway |] \
|
|
501 |
\ ==> Crypt {|NA, Agent A, Agent B|} (shrK A) \
|
2032
|
502 |
\ : parts (sees Spy evs) --> \
|
2002
|
503 |
\ Says A B {|NA, Agent A, Agent B, \
|
|
504 |
\ Crypt {|NA, Agent A, Agent B|} (shrK A)|} \
|
|
505 |
\ : set_of_list evs";
|
2032
|
506 |
by (etac otway.induct 1);
|
2002
|
507 |
by parts_Fake_tac;
|
|
508 |
by (ALLGOALS Asm_simp_tac);
|
|
509 |
(*Fake*)
|
|
510 |
by (best_tac (!claset addSDs [impOfSubs analz_subset_parts,
|
2032
|
511 |
impOfSubs Fake_parts_insert]) 2);
|
2002
|
512 |
by (Auto_tac());
|
|
513 |
qed_spec_mp "Crypt_imp_OR1";
|
|
514 |
|
|
515 |
|
|
516 |
(*This key property is FALSE. Somebody could make a fake message to Server
|
|
517 |
substituting some other nonce NA' for NB.*)
|
|
518 |
goal thy
|
|
519 |
"!!evs. [| A ~: bad; evs : otway |] \
|
2032
|
520 |
\ ==> Crypt {|Nonce NA, Key K|} (shrK A) : parts (sees Spy evs) --> \
|
2002
|
521 |
\ Says A B {|Nonce NA, Agent A, Agent B, \
|
|
522 |
\ Crypt {|Nonce NA, Agent A, Agent B|} (shrK A)|} \
|
|
523 |
\ : set_of_list evs --> \
|
|
524 |
\ (EX B NB. Says Server B \
|
|
525 |
\ {|Nonce NA, \
|
|
526 |
\ Crypt {|Nonce NA, Key K|} (shrK A), \
|
|
527 |
\ Crypt {|Nonce NB, Key K|} (shrK B)|} \
|
|
528 |
\ : set_of_list evs)";
|
2032
|
529 |
by (etac otway.induct 1);
|
2002
|
530 |
fun ftac rl = forward_tac [rl];
|
|
531 |
by (
|
2032
|
532 |
ftac (OR2_analz_sees_Spy RS (impOfSubs analz_subset_parts)) 4 THEN
|
|
533 |
ftac (OR4_analz_sees_Spy RS (impOfSubs analz_subset_parts)) 6 THEN
|
|
534 |
ftac Reveal_parts_sees_Spy 7);
|
2002
|
535 |
|
|
536 |
(* by parts_Fake_tac; ?*)
|
|
537 |
by (ALLGOALS Asm_simp_tac);
|
|
538 |
(*Fake*)
|
|
539 |
by (best_tac (!claset addSDs [impOfSubs analz_subset_parts,
|
2032
|
540 |
impOfSubs Fake_parts_insert]) 1);
|
2002
|
541 |
(*OR1: it cannot be a new Nonce, contradiction.*)
|
|
542 |
by (fast_tac (!claset addSIs [parts_insertI]
|
2032
|
543 |
addSEs partsEs
|
|
544 |
addEs [Says_imp_old_nonces RS less_irrefl]
|
|
545 |
addss (!simpset)) 1);
|
2002
|
546 |
(*OR3 and OR4*) (** LEVEL 5 **)
|
|
547 |
(*OR4*)
|
|
548 |
by (REPEAT (Safe_step_tac 2));
|
|
549 |
by (best_tac (!claset addSDs [parts_cut]) 3);
|
|
550 |
by (best_tac (!claset addSDs [parts_cut]) 3);
|
|
551 |
by (forward_tac [Crypt_imp_OR1] 2);
|
|
552 |
by (fast_tac (!claset addEs partsEs
|
2032
|
553 |
addSDs [Says_imp_sees_Spy RS parts.Inj]) 4);
|
2002
|
554 |
by (REPEAT (Fast_tac 2));
|
|
555 |
(*OR3*) (** LEVEL 11 **)
|
|
556 |
by (ALLGOALS (asm_simp_tac (!simpset addsimps [ex_disj_distrib])));
|
|
557 |
fr impI;
|
|
558 |
by (REPEAT (etac conjE 1 ORELSE hyp_subst_tac 1));
|
|
559 |
fr impI;
|
|
560 |
(*The hypotheses at this point suggest an attack in which nonce NA is used
|
|
561 |
in two different places*)
|
|
562 |
writeln "GIVE UP!";
|
|
563 |
|
|
564 |
|
|
565 |
|
|
566 |
(*What can A deduce from receipt of OR4? This too is probably FALSE*)
|
|
567 |
goal thy
|
|
568 |
"!!evs. [| A ~: bad; evs : otway |] \
|
|
569 |
\ ==> ALL B' NA K B. \
|
|
570 |
\ Says B' A {|Nonce NA, Crypt {|Nonce NA, Key K|} (shrK A)|} \
|
|
571 |
\ : set_of_list evs --> \
|
|
572 |
\ Says A B {|Nonce NA, Agent A, Agent B, \
|
|
573 |
\ Crypt {|Nonce NA, Agent A, Agent B|} (shrK A)|} \
|
|
574 |
\ : set_of_list evs --> \
|
|
575 |
\ (EX NB. Says Server B \
|
|
576 |
\ {|Nonce NA, \
|
|
577 |
\ Crypt {|Nonce NA, Key K|} (shrK A), \
|
|
578 |
\ Crypt {|Nonce NB, Key K|} (shrK B)|} \
|
|
579 |
\ : set_of_list evs)";
|
2032
|
580 |
by (etac otway.induct 1);
|
2002
|
581 |
by (ALLGOALS (asm_simp_tac (!simpset addcongs [conj_cong])));
|
|
582 |
(*OR2*)
|
|
583 |
by (Fast_tac 3);
|
|
584 |
(*OR1: it cannot be a new Nonce, contradiction.*)
|
|
585 |
by (fast_tac (!claset addSIs [parts_insertI]
|
2032
|
586 |
addEs [Says_imp_old_nonces RS less_irrefl]
|
|
587 |
addss (!simpset)) 2);
|
2002
|
588 |
by (ALLGOALS
|
|
589 |
(asm_simp_tac (!simpset addsimps [all_conj_distrib, de_Morgan_disj, de_Morgan_conj])));
|
|
590 |
(*Fake, OR4*) (** LEVEL 5 **)
|
|
591 |
by (step_tac (!claset delrules [MPair_analz]) 1);
|
|
592 |
by (ALLGOALS Asm_simp_tac);
|
|
593 |
by (fast_tac (!claset addSDs [spec]) 4);
|
|
594 |
by (forward_tac [Crypt_imp_OR1] 3);
|
|
595 |
by (fast_tac (!claset addEs partsEs
|
2032
|
596 |
addSDs [Says_imp_sees_Spy RS parts.Inj]) 5);
|
2002
|
597 |
by (REPEAT (Fast_tac 3));
|
|
598 |
(** LEVEL 11 **)
|
|
599 |
(*Fake (??) and OR4*)
|
|
600 |
|
|
601 |
|
|
602 |
by (ALLGOALS (asm_simp_tac (!simpset addsimps [all_conj_distrib, ex_disj_distrib, de_Morgan_disj, de_Morgan_conj])));
|
|
603 |
|
|
604 |
|
|
605 |
(*** Session keys are issued at most once, and identify the principals ***)
|
|
606 |
|
|
607 |
(** First, two lemmas for the Fake, OR2 and OR4 cases **)
|
|
608 |
|
|
609 |
goal thy
|
2032
|
610 |
"!!evs. [| X : synth (analz (sees Spy evs)); \
|
2002
|
611 |
\ Crypt X' (shrK C) : parts{X}; \
|
|
612 |
\ C ~: bad; evs : otway |] \
|
2032
|
613 |
\ ==> Crypt X' (shrK C) : parts (sees Spy evs)";
|
2002
|
614 |
by (best_tac (!claset addSEs [impOfSubs analz_subset_parts]
|
2032
|
615 |
addDs [impOfSubs parts_insert_subset_Un]
|
2002
|
616 |
addss (!simpset)) 1);
|
|
617 |
qed "Crypt_Fake_parts";
|
|
618 |
|
|
619 |
goal thy
|
|
620 |
"!!evs. [| Crypt X' K : parts (sees A evs); evs : otway |] \
|
|
621 |
\ ==> EX S S' Y. Says S S' Y : set_of_list evs & \
|
|
622 |
\ Crypt X' K : parts {Y}";
|
2032
|
623 |
by (dtac parts_singleton 1);
|
2002
|
624 |
by (fast_tac (!claset addSDs [seesD] addss (!simpset)) 1);
|
|
625 |
qed "Crypt_parts_singleton";
|
|
626 |
|
|
627 |
(*The Key K uniquely identifies a pair of senders in the message encrypted by
|
2032
|
628 |
C, but if C=Spy then he could send all sorts of nonsense.*)
|
2002
|
629 |
goal thy
|
|
630 |
"!!evs. evs : otway ==> \
|
|
631 |
\ EX A B. ALL C. \
|
|
632 |
\ C ~: bad --> \
|
|
633 |
\ (ALL S S' X. Says S S' X : set_of_list evs --> \
|
|
634 |
\ (EX NA. Crypt {|NA, Key K|} (shrK C) : parts{X}) --> C=A | C=B)";
|
|
635 |
by (Simp_tac 1);
|
2032
|
636 |
by (etac otway.induct 1);
|
|
637 |
by (dtac OR2_analz_sees_Spy 4);
|
|
638 |
by (dtac OR4_analz_sees_Spy 6);
|
2002
|
639 |
by (ALLGOALS
|
|
640 |
(asm_simp_tac (!simpset addsimps [all_conj_distrib, imp_conj_distrib])));
|
|
641 |
by (REPEAT_FIRST (etac exE));
|
|
642 |
(*OR4*)
|
|
643 |
by (ex_strip_tac 4);
|
|
644 |
by (fast_tac (!claset addSDs [synth.Inj RS Crypt_Fake_parts,
|
2032
|
645 |
Crypt_parts_singleton]) 4);
|
2002
|
646 |
(*OR3: Case split propagates some context to other subgoal...*)
|
2032
|
647 |
(** LEVEL 8 **)
|
2002
|
648 |
by (excluded_middle_tac "K = newK evsa" 3);
|
|
649 |
by (Asm_simp_tac 3);
|
|
650 |
by (REPEAT (ares_tac [exI] 3));
|
|
651 |
(*...we prove this case by contradiction: the key is too new!*)
|
|
652 |
by (fast_tac (!claset addIs [parts_insertI]
|
2032
|
653 |
addSEs partsEs
|
|
654 |
addEs [Says_imp_old_keys RS less_irrefl]
|
|
655 |
addss (!simpset)) 3);
|
2002
|
656 |
(*OR2*) (** LEVEL 12 **)
|
2032
|
657 |
(*spy_analz_tac just does not work here: it is an entirely different proof!*)
|
2002
|
658 |
by (ex_strip_tac 2);
|
|
659 |
by (res_inst_tac [("x1","X")] (insert_commute RS ssubst) 2);
|
|
660 |
by (Simp_tac 2);
|
|
661 |
by (fast_tac (!claset addSDs [synth.Inj RS Crypt_Fake_parts,
|
2032
|
662 |
Crypt_parts_singleton]) 2);
|
2002
|
663 |
(*Fake*) (** LEVEL 16 **)
|
|
664 |
by (ex_strip_tac 1);
|
|
665 |
by (fast_tac (!claset addSDs [Crypt_Fake_parts, Crypt_parts_singleton]) 1);
|
|
666 |
qed "unique_session_keys2";
|
|
667 |
|
|
668 |
|