author | bulwahn |
Tue, 10 Jan 2012 10:18:08 +0100 | |
changeset 46169 | 321abd584588 |
parent 37936 | 1e4c5015a72e |
child 58889 | 5b7a9633cfa8 |
permissions | -rw-r--r-- |
37936 | 1 |
(* Title: HOL/Auth/OtwayRees_AN.thy |
2090 | 2 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
3 |
Copyright 1996 University of Cambridge |
|
14207
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
paulson
parents:
14200
diff
changeset
|
4 |
*) |
2090 | 5 |
|
14207
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
paulson
parents:
14200
diff
changeset
|
6 |
header{*The Otway-Rees Protocol as Modified by Abadi and Needham*} |
2090 | 7 |
|
16417 | 8 |
theory OtwayRees_AN imports Public begin |
14207
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
paulson
parents:
14200
diff
changeset
|
9 |
|
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
paulson
parents:
14200
diff
changeset
|
10 |
text{* |
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
paulson
parents:
14200
diff
changeset
|
11 |
This simplified version has minimal encryption and explicit messages. |
2090 | 12 |
|
2516
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2451
diff
changeset
|
13 |
Note that the formalization does not even assume that nonces are fresh. |
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2451
diff
changeset
|
14 |
This is because the protocol does not rely on uniqueness of nonces for |
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2451
diff
changeset
|
15 |
security, only for freshness, and the proof script does not prove freshness |
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2451
diff
changeset
|
16 |
properties. |
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2451
diff
changeset
|
17 |
|
2090 | 18 |
From page 11 of |
14207
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
paulson
parents:
14200
diff
changeset
|
19 |
Abadi and Needham (1996). |
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
paulson
parents:
14200
diff
changeset
|
20 |
Prudent Engineering Practice for Cryptographic Protocols. |
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
paulson
parents:
14200
diff
changeset
|
21 |
IEEE Trans. SE 22 (1) |
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
paulson
parents:
14200
diff
changeset
|
22 |
*} |
2090 | 23 |
|
23746 | 24 |
inductive_set otway :: "event list set" |
25 |
where |
|
14238 | 26 |
Nil: --{*The empty trace*} |
27 |
"[] \<in> otway" |
|
2090 | 28 |
|
23746 | 29 |
| Fake: --{*The Spy may say anything he can say. The sender field is correct, |
14238 | 30 |
but agents don't use that information.*} |
31 |
"[| evsf \<in> otway; X \<in> synth (analz (knows Spy evsf)) |] |
|
11251 | 32 |
==> Says Spy B X # evsf \<in> otway" |
2090 | 33 |
|
14238 | 34 |
|
23746 | 35 |
| Reception: --{*A message that has been sent can be received by the |
14238 | 36 |
intended recipient.*} |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32366
diff
changeset
|
37 |
"[| evsr \<in> otway; Says A B X \<in>set evsr |] |
11251 | 38 |
==> Gets B X # evsr \<in> otway" |
6308
76f3865a2b1d
Added Bella's "Gets" model for Otway_Rees. Also affects some other theories.
paulson
parents:
5434
diff
changeset
|
39 |
|
23746 | 40 |
| OR1: --{*Alice initiates a protocol run*} |
14238 | 41 |
"evs1 \<in> otway |
11251 | 42 |
==> Says A B {|Agent A, Agent B, Nonce NA|} # evs1 \<in> otway" |
2090 | 43 |
|
23746 | 44 |
| OR2: --{*Bob's response to Alice's message.*} |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32366
diff
changeset
|
45 |
"[| evs2 \<in> otway; |
11251 | 46 |
Gets B {|Agent A, Agent B, Nonce NA|} \<in>set evs2 |] |
2516
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2451
diff
changeset
|
47 |
==> Says B Server {|Agent A, Agent B, Nonce NA, Nonce NB|} |
11251 | 48 |
# evs2 \<in> otway" |
2090 | 49 |
|
23746 | 50 |
| OR3: --{*The Server receives Bob's message. Then he sends a new |
14238 | 51 |
session key to Bob with a packet for forwarding to Alice.*} |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32366
diff
changeset
|
52 |
"[| evs3 \<in> otway; Key KAB \<notin> used evs3; |
6308
76f3865a2b1d
Added Bella's "Gets" model for Otway_Rees. Also affects some other theories.
paulson
parents:
5434
diff
changeset
|
53 |
Gets Server {|Agent A, Agent B, Nonce NA, Nonce NB|} |
11251 | 54 |
\<in>set evs3 |] |
55 |
==> Says Server B |
|
2516
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2451
diff
changeset
|
56 |
{|Crypt (shrK A) {|Nonce NA, Agent A, Agent B, Key KAB|}, |
4d68fbe6378b
Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents:
2451
diff
changeset
|
57 |
Crypt (shrK B) {|Nonce NB, Agent A, Agent B, Key KAB|}|} |
11251 | 58 |
# evs3 \<in> otway" |
2090 | 59 |
|
23746 | 60 |
| OR4: --{*Bob receives the Server's (?) message and compares the Nonces with |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32366
diff
changeset
|
61 |
those in the message he previously sent the Server. |
14238 | 62 |
Need @{term "B \<noteq> Server"} because we allow messages to self.*} |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32366
diff
changeset
|
63 |
"[| evs4 \<in> otway; B \<noteq> Server; |
11251 | 64 |
Says B Server {|Agent A, Agent B, Nonce NA, Nonce NB|} \<in>set evs4; |
6308
76f3865a2b1d
Added Bella's "Gets" model for Otway_Rees. Also affects some other theories.
paulson
parents:
5434
diff
changeset
|
65 |
Gets B {|X, Crypt(shrK B){|Nonce NB,Agent A,Agent B,Key K|}|} |
11251 | 66 |
\<in>set evs4 |] |
67 |
==> Says B A X # evs4 \<in> otway" |
|
2090 | 68 |
|
23746 | 69 |
| Oops: --{*This message models possible leaks of session keys. The nonces |
14238 | 70 |
identify the protocol run.*} |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32366
diff
changeset
|
71 |
"[| evso \<in> otway; |
11251 | 72 |
Says Server B |
73 |
{|Crypt (shrK A) {|Nonce NA, Agent A, Agent B, Key K|}, |
|
2284
80ebd1a213fd
Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents:
2131
diff
changeset
|
74 |
Crypt (shrK B) {|Nonce NB, Agent A, Agent B, Key K|}|} |
11251 | 75 |
\<in>set evso |] |
76 |
==> Notes Spy {|Nonce NA, Nonce NB, Key K|} # evso \<in> otway" |
|
77 |
||
78 |
||
79 |
declare Says_imp_knows_Spy [THEN analz.Inj, dest] |
|
80 |
declare parts.Body [dest] |
|
81 |
declare analz_into_parts [dest] |
|
82 |
declare Fake_parts_insert_in_Un [dest] |
|
83 |
||
84 |
||
14238 | 85 |
text{*A "possibility property": there are traces that reach the end*} |
14200
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents:
13507
diff
changeset
|
86 |
lemma "[| B \<noteq> Server; Key K \<notin> used [] |] |
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents:
13507
diff
changeset
|
87 |
==> \<exists>evs \<in> otway. |
11251 | 88 |
Says B A (Crypt (shrK A) {|Nonce NA, Agent A, Agent B, Key K|}) |
89 |
\<in> set evs" |
|
90 |
apply (intro exI bexI) |
|
91 |
apply (rule_tac [2] otway.Nil |
|
92 |
[THEN otway.OR1, THEN otway.Reception, |
|
93 |
THEN otway.OR2, THEN otway.Reception, |
|
14200
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents:
13507
diff
changeset
|
94 |
THEN otway.OR3, THEN otway.Reception, THEN otway.OR4]) |
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents:
13507
diff
changeset
|
95 |
apply (possibility, simp add: used_Cons) |
11251 | 96 |
done |
97 |
||
98 |
lemma Gets_imp_Says [dest!]: |
|
99 |
"[| Gets B X \<in> set evs; evs \<in> otway |] ==> \<exists>A. Says A B X \<in> set evs" |
|
100 |
by (erule rev_mp, erule otway.induct, auto) |
|
101 |
||
102 |
||
103 |
||
14238 | 104 |
text{* For reasoning about the encrypted portion of messages *} |
11251 | 105 |
|
106 |
lemma OR4_analz_knows_Spy: |
|
107 |
"[| Gets B {|X, Crypt(shrK B) X'|} \<in> set evs; evs \<in> otway |] |
|
108 |
==> X \<in> analz (knows Spy evs)" |
|
109 |
by blast |
|
110 |
||
111 |
||
14238 | 112 |
text{*Theorems of the form @{term "X \<notin> parts (spies evs)"} imply that |
113 |
NOBODY sends messages containing X! *} |
|
11251 | 114 |
|
14238 | 115 |
text{*Spy never sees a good agent's shared key!*} |
11251 | 116 |
lemma Spy_see_shrK [simp]: |
117 |
"evs \<in> otway ==> (Key (shrK A) \<in> parts (knows Spy evs)) = (A \<in> bad)" |
|
14238 | 118 |
by (erule otway.induct, simp_all, blast+) |
11251 | 119 |
|
120 |
lemma Spy_analz_shrK [simp]: |
|
121 |
"evs \<in> otway ==> (Key (shrK A) \<in> analz (knows Spy evs)) = (A \<in> bad)" |
|
122 |
by auto |
|
123 |
||
124 |
lemma Spy_see_shrK_D [dest!]: |
|
125 |
"[|Key (shrK A) \<in> parts (knows Spy evs); evs \<in> otway|] ==> A \<in> bad" |
|
126 |
by (blast dest: Spy_see_shrK) |
|
127 |
||
128 |
||
14238 | 129 |
subsection{*Proofs involving analz *} |
11251 | 130 |
|
14238 | 131 |
text{*Describes the form of K and NA when the Server sends this message.*} |
11251 | 132 |
lemma Says_Server_message_form: |
133 |
"[| Says Server B |
|
134 |
{|Crypt (shrK A) {|NA, Agent A, Agent B, Key K|}, |
|
135 |
Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|} |
|
136 |
\<in> set evs; |
|
137 |
evs \<in> otway |] |
|
138 |
==> K \<notin> range shrK & (\<exists>i. NA = Nonce i) & (\<exists>j. NB = Nonce j)" |
|
139 |
apply (erule rev_mp) |
|
14207
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
paulson
parents:
14200
diff
changeset
|
140 |
apply (erule otway.induct, auto) |
11251 | 141 |
done |
142 |
||
143 |
||
144 |
||
145 |
(**** |
|
146 |
The following is to prove theorems of the form |
|
147 |
||
148 |
Key K \<in> analz (insert (Key KAB) (knows Spy evs)) ==> |
|
149 |
Key K \<in> analz (knows Spy evs) |
|
150 |
||
151 |
A more general formula must be proved inductively. |
|
152 |
****) |
|
153 |
||
154 |
||
14238 | 155 |
text{* Session keys are not used to encrypt other session keys *} |
11251 | 156 |
|
14238 | 157 |
text{*The equality makes the induction hypothesis easier to apply*} |
11251 | 158 |
lemma analz_image_freshK [rule_format]: |
159 |
"evs \<in> otway ==> |
|
160 |
\<forall>K KK. KK <= -(range shrK) --> |
|
161 |
(Key K \<in> analz (Key`KK Un (knows Spy evs))) = |
|
162 |
(K \<in> KK | Key K \<in> analz (knows Spy evs))" |
|
14207
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
paulson
parents:
14200
diff
changeset
|
163 |
apply (erule otway.induct) |
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
paulson
parents:
14200
diff
changeset
|
164 |
apply (frule_tac [8] Says_Server_message_form) |
f20fbb141673
Conversion of all main protocols from "Shared" to "Public".
paulson
parents:
14200
diff
changeset
|
165 |
apply (drule_tac [7] OR4_analz_knows_Spy, analz_freshK, spy_analz, auto) |
11251 | 166 |
done |
167 |
||
168 |
lemma analz_insert_freshK: |
|
169 |
"[| evs \<in> otway; KAB \<notin> range shrK |] ==> |
|
11655 | 170 |
(Key K \<in> analz (insert (Key KAB) (knows Spy evs))) = |
11251 | 171 |
(K = KAB | Key K \<in> analz (knows Spy evs))" |
172 |
by (simp only: analz_image_freshK analz_image_freshK_simps) |
|
173 |
||
174 |
||
14238 | 175 |
text{*The Key K uniquely identifies the Server's message.*} |
11251 | 176 |
lemma unique_session_keys: |
177 |
"[| Says Server B |
|
178 |
{|Crypt (shrK A) {|NA, Agent A, Agent B, K|}, |
|
179 |
Crypt (shrK B) {|NB, Agent A, Agent B, K|}|} |
|
180 |
\<in> set evs; |
|
181 |
Says Server B' |
|
182 |
{|Crypt (shrK A') {|NA', Agent A', Agent B', K|}, |
|
183 |
Crypt (shrK B') {|NB', Agent A', Agent B', K|}|} |
|
184 |
\<in> set evs; |
|
185 |
evs \<in> otway |] |
|
186 |
==> A=A' & B=B' & NA=NA' & NB=NB'" |
|
13507 | 187 |
apply (erule rev_mp, erule rev_mp, erule otway.induct, simp_all) |
14238 | 188 |
apply blast+ --{*OR3 and OR4*} |
11251 | 189 |
done |
190 |
||
191 |
||
14238 | 192 |
subsection{*Authenticity properties relating to NA*} |
11251 | 193 |
|
14238 | 194 |
text{*If the encrypted message appears then it originated with the Server!*} |
11251 | 195 |
lemma NA_Crypt_imp_Server_msg [rule_format]: |
196 |
"[| A \<notin> bad; A \<noteq> B; evs \<in> otway |] |
|
197 |
==> Crypt (shrK A) {|NA, Agent A, Agent B, Key K|} \<in> parts (knows Spy evs) |
|
198 |
--> (\<exists>NB. Says Server B |
|
199 |
{|Crypt (shrK A) {|NA, Agent A, Agent B, Key K|}, |
|
200 |
Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|} |
|
201 |
\<in> set evs)" |
|
202 |
apply (erule otway.induct, force) |
|
203 |
apply (simp_all add: ex_disj_distrib) |
|
14238 | 204 |
apply blast+ --{*Fake, OR3*} |
11251 | 205 |
done |
206 |
||
207 |
||
14238 | 208 |
text{*Corollary: if A receives B's OR4 message then it originated with the |
209 |
Server. Freshness may be inferred from nonce NA.*} |
|
11251 | 210 |
lemma A_trusts_OR4: |
211 |
"[| Says B' A (Crypt (shrK A) {|NA, Agent A, Agent B, Key K|}) \<in> set evs; |
|
212 |
A \<notin> bad; A \<noteq> B; evs \<in> otway |] |
|
213 |
==> \<exists>NB. Says Server B |
|
214 |
{|Crypt (shrK A) {|NA, Agent A, Agent B, Key K|}, |
|
215 |
Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|} |
|
216 |
\<in> set evs" |
|
217 |
by (blast intro!: NA_Crypt_imp_Server_msg) |
|
218 |
||
219 |
||
14238 | 220 |
text{*Crucial secrecy property: Spy does not see the keys sent in msg OR3 |
11251 | 221 |
Does not in itself guarantee security: an attack could violate |
14238 | 222 |
the premises, e.g. by having @{term "A=Spy"}*} |
11251 | 223 |
lemma secrecy_lemma: |
224 |
"[| A \<notin> bad; B \<notin> bad; evs \<in> otway |] |
|
225 |
==> Says Server B |
|
226 |
{|Crypt (shrK A) {|NA, Agent A, Agent B, Key K|}, |
|
227 |
Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|} |
|
228 |
\<in> set evs --> |
|
229 |
Notes Spy {|NA, NB, Key K|} \<notin> set evs --> |
|
230 |
Key K \<notin> analz (knows Spy evs)" |
|
231 |
apply (erule otway.induct, force) |
|
232 |
apply (frule_tac [7] Says_Server_message_form) |
|
233 |
apply (drule_tac [6] OR4_analz_knows_Spy) |
|
14238 | 234 |
apply (simp_all add: analz_insert_eq analz_insert_freshK pushes) |
235 |
apply spy_analz --{*Fake*} |
|
236 |
apply (blast dest: unique_session_keys)+ --{*OR3, OR4, Oops*} |
|
11251 | 237 |
done |
238 |
||
239 |
||
240 |
lemma Spy_not_see_encrypted_key: |
|
241 |
"[| Says Server B |
|
242 |
{|Crypt (shrK A) {|NA, Agent A, Agent B, Key K|}, |
|
243 |
Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|} |
|
244 |
\<in> set evs; |
|
245 |
Notes Spy {|NA, NB, Key K|} \<notin> set evs; |
|
246 |
A \<notin> bad; B \<notin> bad; evs \<in> otway |] |
|
247 |
==> Key K \<notin> analz (knows Spy evs)" |
|
32366
b269b56b6a14
Demonstrations of sledgehammer in protocol proofs.
paulson
parents:
23746
diff
changeset
|
248 |
by (metis secrecy_lemma) |
11251 | 249 |
|
250 |
||
14238 | 251 |
text{*A's guarantee. The Oops premise quantifies over NB because A cannot know |
252 |
what it is.*} |
|
11251 | 253 |
lemma A_gets_good_key: |
254 |
"[| Says B' A (Crypt (shrK A) {|NA, Agent A, Agent B, Key K|}) \<in> set evs; |
|
255 |
\<forall>NB. Notes Spy {|NA, NB, Key K|} \<notin> set evs; |
|
256 |
A \<notin> bad; B \<notin> bad; A \<noteq> B; evs \<in> otway |] |
|
257 |
==> Key K \<notin> analz (knows Spy evs)" |
|
32366
b269b56b6a14
Demonstrations of sledgehammer in protocol proofs.
paulson
parents:
23746
diff
changeset
|
258 |
by (metis A_trusts_OR4 secrecy_lemma) |
11251 | 259 |
|
260 |
||
261 |
||
14238 | 262 |
subsection{*Authenticity properties relating to NB*} |
11251 | 263 |
|
14238 | 264 |
text{*If the encrypted message appears then it originated with the Server!*} |
11251 | 265 |
lemma NB_Crypt_imp_Server_msg [rule_format]: |
266 |
"[| B \<notin> bad; A \<noteq> B; evs \<in> otway |] |
|
267 |
==> Crypt (shrK B) {|NB, Agent A, Agent B, Key K|} \<in> parts (knows Spy evs) |
|
268 |
--> (\<exists>NA. Says Server B |
|
269 |
{|Crypt (shrK A) {|NA, Agent A, Agent B, Key K|}, |
|
270 |
Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|} |
|
271 |
\<in> set evs)" |
|
272 |
apply (erule otway.induct, force, simp_all add: ex_disj_distrib) |
|
14238 | 273 |
apply blast+ --{*Fake, OR3*} |
11251 | 274 |
done |
275 |
||
276 |
||
277 |
||
14238 | 278 |
text{*Guarantee for B: if it gets a well-formed certificate then the Server |
279 |
has sent the correct message in round 3.*} |
|
11251 | 280 |
lemma B_trusts_OR3: |
281 |
"[| Says S B {|X, Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|} |
|
282 |
\<in> set evs; |
|
283 |
B \<notin> bad; A \<noteq> B; evs \<in> otway |] |
|
284 |
==> \<exists>NA. Says Server B |
|
285 |
{|Crypt (shrK A) {|NA, Agent A, Agent B, Key K|}, |
|
286 |
Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|} |
|
287 |
\<in> set evs" |
|
288 |
by (blast intro!: NB_Crypt_imp_Server_msg) |
|
289 |
||
290 |
||
14238 | 291 |
text{*The obvious combination of @{text B_trusts_OR3} with |
292 |
@{text Spy_not_see_encrypted_key}*} |
|
11251 | 293 |
lemma B_gets_good_key: |
294 |
"[| Gets B {|X, Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|} |
|
295 |
\<in> set evs; |
|
296 |
\<forall>NA. Notes Spy {|NA, NB, Key K|} \<notin> set evs; |
|
297 |
A \<notin> bad; B \<notin> bad; A \<noteq> B; evs \<in> otway |] |
|
298 |
==> Key K \<notin> analz (knows Spy evs)" |
|
299 |
by (blast dest: B_trusts_OR3 Spy_not_see_encrypted_key) |
|
2090 | 300 |
|
301 |
end |