author | paulson |
Wed, 18 Nov 1998 15:10:46 +0100 | |
changeset 5931 | 325300576da7 |
parent 5758 | 27a2b36efd95 |
child 6570 | a7d7985050a9 |
permissions | -rw-r--r-- |
5430 | 1 |
(* Title: HOL/Auth/NSP_Bad |
2 |
ID: $Id$ |
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
|
4 |
Copyright 1996 University of Cambridge |
|
5 |
||
6 |
Inductive relation "ns_public" for the Needham-Schroeder Public-Key protocol. |
|
7 |
Flawed version, vulnerable to Lowe's attack. |
|
8 |
||
9 |
From page 260 of |
|
10 |
Burrows, Abadi and Needham. A Logic of Authentication. |
|
11 |
Proc. Royal Soc. 426 (1989) |
|
12 |
*) |
|
13 |
||
14 |
AddEs spies_partsEs; |
|
15 |
AddDs [impOfSubs analz_subset_parts]; |
|
16 |
AddDs [impOfSubs Fake_parts_insert]; |
|
17 |
||
18 |
AddIffs [Spy_in_bad]; |
|
19 |
||
20 |
(*For other theories, e.g. Mutex and Lift, using AddIffs slows proofs down. |
|
21 |
Here, it facilitates re-use of the Auth proofs.*) |
|
22 |
||
23 |
AddIffs (map simp_of_act [Fake_def, NS1_def, NS2_def, NS3_def]); |
|
24 |
||
25 |
Addsimps [Nprg_def RS def_prg_simps]; |
|
26 |
||
5648 | 27 |
|
5430 | 28 |
(*A "possibility property": there are traces that reach the end*) |
29 |
Goal "A ~= B ==> EX NB. EX s: reachable Nprg. \ |
|
30 |
\ Says A B (Crypt (pubK B) (Nonce NB)) : set s"; |
|
31 |
by (REPEAT (resolve_tac [exI,bexI] 1)); |
|
32 |
by (res_inst_tac [("act", "NS3")] reachable.Acts 2); |
|
33 |
by (res_inst_tac [("act", "NS2")] reachable.Acts 3); |
|
34 |
by (res_inst_tac [("act", "NS1")] reachable.Acts 4); |
|
5536 | 35 |
by (rtac reachable.Init 5); |
5648 | 36 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps [Nprg_def]))); |
5536 | 37 |
by (REPEAT_FIRST (rtac exI )); |
5430 | 38 |
by possibility_tac; |
39 |
result(); |
|
40 |
||
41 |
||
42 |
(**** Inductive proofs about ns_public ****) |
|
43 |
||
44 |
(*can be used to simulate analz_mono_contra_tac |
|
45 |
val analz_impI = read_instantiate_sg (sign_of thy) |
|
46 |
[("P", "?Y ~: analz (spies ?evs)")] impI; |
|
47 |
||
48 |
val spies_Says_analz_contraD = |
|
49 |
spies_subset_spies_Says RS analz_mono RS contra_subsetD; |
|
50 |
||
51 |
by (rtac analz_impI 2); |
|
52 |
by (auto_tac (claset() addSDs [spies_Says_analz_contraD], simpset())); |
|
53 |
*) |
|
54 |
||
55 |
val parts_induct_tac = |
|
56 |
(SELECT_GOAL o EVERY) |
|
57 |
[etac reachable.induct 1, |
|
58 |
Force_tac 1, |
|
59 |
Full_simp_tac 1, |
|
60 |
safe_tac (claset() delrules [impI,impCE]), |
|
61 |
REPEAT (FIRSTGOAL analz_mono_contra_tac), |
|
62 |
ALLGOALS Asm_simp_tac]; |
|
63 |
||
64 |
||
65 |
(** Theorems of the form X ~: parts (spies evs) imply that NOBODY |
|
66 |
sends messages containing X! **) |
|
67 |
||
68 |
(*Spy never sees another agent's private key! (unless it's bad at start)*) |
|
5487 | 69 |
(* |
5648 | 70 |
Goal "Nprg : Invariant {s. (Key (priK A) : parts (spies s)) = (A : bad)}"; |
5487 | 71 |
by (rtac InvariantI 1); |
72 |
by (Force_tac 1); |
|
73 |
by (constrains_tac 1); |
|
74 |
by Auto_tac; |
|
75 |
qed "Spy_see_priK"; |
|
5430 | 76 |
*) |
77 |
||
78 |
Goal "s : reachable Nprg ==> (Key (priK A) : parts (spies s)) = (A : bad)"; |
|
5536 | 79 |
by (etac reachable.induct 1); |
5758
27a2b36efd95
corrected auto_tac (applications of unsafe wrappers)
oheimb
parents:
5648
diff
changeset
|
80 |
by (ALLGOALS Force_tac); |
5430 | 81 |
qed "Spy_see_priK"; |
82 |
Addsimps [Spy_see_priK]; |
|
83 |
||
84 |
Goal "s : reachable Nprg ==> (Key (priK A) : analz (spies s)) = (A : bad)"; |
|
85 |
by Auto_tac; |
|
86 |
qed "Spy_analz_priK"; |
|
87 |
Addsimps [Spy_analz_priK]; |
|
88 |
||
89 |
AddSDs [Spy_see_priK RSN (2, rev_iffD1), |
|
90 |
Spy_analz_priK RSN (2, rev_iffD1)]; |
|
91 |
||
92 |
||
93 |
(**** Authenticity properties obtained from NS2 ****) |
|
94 |
||
95 |
(*It is impossible to re-use a nonce in both NS1 and NS2, provided the nonce |
|
96 |
is secret. (Honest users generate fresh nonces.)*) |
|
97 |
Goal "[| Crypt (pubK B) {|Nonce NA, Agent A|} : parts (spies s); \ |
|
98 |
\ Nonce NA ~: analz (spies s); s : reachable Nprg |] \ |
|
99 |
\ ==> Crypt (pubK C) {|NA', Nonce NA|} ~: parts (spies s)"; |
|
100 |
by (etac rev_mp 1); |
|
101 |
by (etac rev_mp 1); |
|
102 |
by (parts_induct_tac 1); |
|
103 |
by (ALLGOALS Blast_tac); |
|
104 |
qed "no_nonce_NS1_NS2"; |
|
105 |
||
106 |
(*Adding it to the claset slows down proofs...*) |
|
107 |
val nonce_NS1_NS2_E = no_nonce_NS1_NS2 RSN (2, rev_notE); |
|
108 |
||
109 |
||
110 |
(*Unicity for NS1: nonce NA identifies agents A and B*) |
|
111 |
Goal "[| Nonce NA ~: analz (spies s); s : reachable Nprg |] \ |
|
112 |
\ ==> EX A' B'. ALL A B. \ |
|
113 |
\ Crypt (pubK B) {|Nonce NA, Agent A|} : parts (spies s) --> \ |
|
114 |
\ A=A' & B=B'"; |
|
115 |
by (etac rev_mp 1); |
|
116 |
by (parts_induct_tac 1); |
|
117 |
by (ALLGOALS (simp_tac (simpset() addsimps [all_conj_distrib]))); |
|
118 |
(*NS1*) |
|
119 |
by (expand_case_tac "NA = ?y" 2 THEN Blast_tac 2); |
|
120 |
(*Fake*) |
|
121 |
by (Blast_tac 1); |
|
122 |
val lemma = result(); |
|
123 |
||
124 |
Goal "[| Crypt(pubK B) {|Nonce NA, Agent A|} : parts(spies s); \ |
|
125 |
\ Crypt(pubK B') {|Nonce NA, Agent A'|} : parts(spies s); \ |
|
126 |
\ Nonce NA ~: analz (spies s); \ |
|
127 |
\ s : reachable Nprg |] \ |
|
128 |
\ ==> A=A' & B=B'"; |
|
129 |
by (prove_unique_tac lemma 1); |
|
130 |
qed "unique_NA"; |
|
131 |
||
132 |
||
133 |
(*Tactic for proving secrecy theorems*) |
|
134 |
val analz_induct_tac = |
|
135 |
(SELECT_GOAL o EVERY) |
|
136 |
[etac reachable.induct 1, |
|
137 |
Force_tac 1, |
|
138 |
Full_simp_tac 1, |
|
139 |
safe_tac (claset() delrules [impI,impCE]), |
|
140 |
ALLGOALS Asm_simp_tac]; |
|
141 |
||
142 |
||
143 |
||
144 |
(*Secrecy: Spy does not see the nonce sent in msg NS1 if A and B are secure*) |
|
145 |
Goal "[| Says A B (Crypt(pubK B) {|Nonce NA, Agent A|}) : set s; \ |
|
146 |
\ A ~: bad; B ~: bad; s : reachable Nprg |] \ |
|
147 |
\ ==> Nonce NA ~: analz (spies s)"; |
|
148 |
by (etac rev_mp 1); |
|
149 |
by (analz_induct_tac 1); |
|
150 |
(*NS3*) |
|
151 |
by (blast_tac (claset() addEs [nonce_NS1_NS2_E]) 4); |
|
152 |
(*NS2*) |
|
153 |
by (blast_tac (claset() addDs [unique_NA]) 3); |
|
154 |
(*NS1*) |
|
155 |
by (Blast_tac 2); |
|
156 |
(*Fake*) |
|
157 |
by (spy_analz_tac 1); |
|
158 |
qed "Spy_not_see_NA"; |
|
159 |
||
160 |
||
161 |
(*Authentication for A: if she receives message 2 and has used NA |
|
162 |
to start a run, then B has sent message 2.*) |
|
163 |
Goal "[| Says A B (Crypt(pubK B) {|Nonce NA, Agent A|}) : set s; \ |
|
164 |
\ Says B' A (Crypt(pubK A) {|Nonce NA, Nonce NB|}): set s; \ |
|
165 |
\ A ~: bad; B ~: bad; s : reachable Nprg |] \ |
|
166 |
\ ==> Says B A (Crypt(pubK A) {|Nonce NA, Nonce NB|}): set s"; |
|
167 |
by (etac rev_mp 1); |
|
168 |
(*prepare induction over Crypt (pubK A) {|NA,NB|} : parts H*) |
|
169 |
by (etac (Says_imp_spies RS parts.Inj RS rev_mp) 1); |
|
170 |
by (parts_induct_tac 1); |
|
171 |
by (ALLGOALS Clarify_tac); |
|
172 |
(*NS2*) |
|
173 |
by (blast_tac (claset() addDs [Spy_not_see_NA, unique_NA]) 3); |
|
174 |
(*NS1*) |
|
175 |
by (Blast_tac 2); |
|
176 |
(*Fake*) |
|
177 |
by (blast_tac (claset() addDs [Spy_not_see_NA]) 1); |
|
178 |
qed "A_trusts_NS2"; |
|
179 |
||
180 |
||
181 |
(*If the encrypted message appears then it originated with Alice in NS1*) |
|
182 |
Goal "[| Crypt (pubK B) {|Nonce NA, Agent A|} : parts (spies s); \ |
|
183 |
\ Nonce NA ~: analz (spies s); \ |
|
184 |
\ s : reachable Nprg |] \ |
|
185 |
\ ==> Says A B (Crypt (pubK B) {|Nonce NA, Agent A|}) : set s"; |
|
186 |
by (etac rev_mp 1); |
|
187 |
by (etac rev_mp 1); |
|
188 |
by (parts_induct_tac 1); |
|
189 |
by (Blast_tac 1); |
|
190 |
qed "B_trusts_NS1"; |
|
191 |
||
192 |
||
193 |
||
194 |
(**** Authenticity properties obtained from NS2 ****) |
|
195 |
||
196 |
(*Unicity for NS2: nonce NB identifies nonce NA and agent A |
|
197 |
[proof closely follows that for unique_NA] *) |
|
198 |
Goal "[| Nonce NB ~: analz (spies s); s : reachable Nprg |] \ |
|
199 |
\ ==> EX A' NA'. ALL A NA. \ |
|
200 |
\ Crypt (pubK A) {|Nonce NA, Nonce NB|} : parts (spies s) \ |
|
201 |
\ --> A=A' & NA=NA'"; |
|
202 |
by (etac rev_mp 1); |
|
203 |
by (parts_induct_tac 1); |
|
204 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps [all_conj_distrib]))); |
|
205 |
(*NS2*) |
|
206 |
by (expand_case_tac "NB = ?y" 2 THEN Blast_tac 2); |
|
207 |
(*Fake*) |
|
208 |
by (Blast_tac 1); |
|
209 |
val lemma = result(); |
|
210 |
||
211 |
Goal "[| Crypt(pubK A) {|Nonce NA, Nonce NB|} : parts(spies s); \ |
|
212 |
\ Crypt(pubK A'){|Nonce NA', Nonce NB|} : parts(spies s); \ |
|
213 |
\ Nonce NB ~: analz (spies s); \ |
|
214 |
\ s : reachable Nprg |] \ |
|
215 |
\ ==> A=A' & NA=NA'"; |
|
216 |
by (prove_unique_tac lemma 1); |
|
217 |
qed "unique_NB"; |
|
218 |
||
219 |
||
220 |
(*NB remains secret PROVIDED Alice never responds with round 3*) |
|
221 |
Goal "[| Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set s; \ |
|
222 |
\ ALL C. Says A C (Crypt (pubK C) (Nonce NB)) ~: set s; \ |
|
223 |
\ A ~: bad; B ~: bad; s : reachable Nprg |] \ |
|
224 |
\ ==> Nonce NB ~: analz (spies s)"; |
|
225 |
by (etac rev_mp 1); |
|
226 |
by (etac rev_mp 1); |
|
227 |
by (analz_induct_tac 1); |
|
228 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps [all_conj_distrib]))); |
|
229 |
by (ALLGOALS Clarify_tac); |
|
230 |
(*NS3: because NB determines A*) |
|
231 |
by (blast_tac (claset() addDs [unique_NB]) 4); |
|
232 |
(*NS2: by freshness and unicity of NB*) |
|
233 |
by (blast_tac (claset() addEs [nonce_NS1_NS2_E]) 3); |
|
234 |
(*NS1: by freshness*) |
|
235 |
by (Blast_tac 2); |
|
236 |
(*Fake*) |
|
237 |
by (spy_analz_tac 1); |
|
238 |
qed "Spy_not_see_NB"; |
|
239 |
||
240 |
||
241 |
||
242 |
(*Authentication for B: if he receives message 3 and has used NB |
|
243 |
in message 2, then A has sent message 3--to somebody....*) |
|
244 |
Goal "[| Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set s; \ |
|
245 |
\ Says A' B (Crypt (pubK B) (Nonce NB)): set s; \ |
|
246 |
\ A ~: bad; B ~: bad; s : reachable Nprg |] \ |
|
247 |
\ ==> EX C. Says A C (Crypt (pubK C) (Nonce NB)) : set s"; |
|
248 |
by (etac rev_mp 1); |
|
249 |
(*prepare induction over Crypt (pubK B) NB : parts H*) |
|
250 |
by (etac (Says_imp_spies RS parts.Inj RS rev_mp) 1); |
|
251 |
by (parts_induct_tac 1); |
|
252 |
by (ALLGOALS (asm_simp_tac (simpset() addsimps [ex_disj_distrib]))); |
|
253 |
by (ALLGOALS Clarify_tac); |
|
254 |
(*NS3: because NB determines A (this use of unique_NB is more robust) *) |
|
255 |
by (blast_tac (claset() addDs [Spy_not_see_NB] |
|
256 |
addIs [unique_NB RS conjunct1]) 3); |
|
257 |
(*NS1: by freshness*) |
|
258 |
by (Blast_tac 2); |
|
259 |
(*Fake*) |
|
260 |
by (blast_tac (claset() addDs [Spy_not_see_NB]) 1); |
|
261 |
qed "B_trusts_NS3"; |
|
262 |
||
263 |
||
264 |
(*Can we strengthen the secrecy theorem? NO*) |
|
265 |
Goal "[| A ~: bad; B ~: bad; s : reachable Nprg |] \ |
|
266 |
\ ==> Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set s \ |
|
267 |
\ --> Nonce NB ~: analz (spies s)"; |
|
268 |
by (analz_induct_tac 1); |
|
269 |
by (ALLGOALS Clarify_tac); |
|
270 |
(*NS2: by freshness and unicity of NB*) |
|
271 |
by (blast_tac (claset() addEs [nonce_NS1_NS2_E]) 3); |
|
272 |
(*NS1: by freshness*) |
|
273 |
by (Blast_tac 2); |
|
274 |
(*Fake*) |
|
275 |
by (spy_analz_tac 1); |
|
276 |
(*NS3: unicity of NB identifies A and NA, but not B*) |
|
277 |
by (forw_inst_tac [("A'","A")] (Says_imp_spies RS parts.Inj RS unique_NB) 1 |
|
278 |
THEN REPEAT (eresolve_tac [asm_rl, Says_imp_spies RS parts.Inj] 1)); |
|
279 |
by Auto_tac; |
|
280 |
by (rename_tac "s B' C" 1); |
|
281 |
||
282 |
(* |
|
283 |
THIS IS THE ATTACK! |
|
284 |
Level 8 |
|
285 |
!!s. [| A ~: bad; B ~: bad; s : reachable Nprg |] |
|
286 |
==> Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set s --> |
|
287 |
Nonce NB ~: analz (spies s) |
|
288 |
1. !!s B' C. |
|
289 |
[| A ~: bad; B ~: bad; s : reachable Nprg; |
|
290 |
Says A C (Crypt (pubK C) {|Nonce NA, Agent A|}) : set s; |
|
291 |
Says B' A (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set s; C : bad; |
|
292 |
Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set s; |
|
293 |
Nonce NB ~: analz (spies s) |] |
|
294 |
==> False |
|
295 |
*) |