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 |
|
|
15 |
(*FUN.ML?? WE NEED A NOTION OF INVERSE IMAGE, OR GRAPH!!*)
|
|
16 |
goal Set.thy "!!f. B <= range f = (B = f`` {x. f x: B})";
|
|
17 |
by (fast_tac (!claset addEs [equalityE]) 1);
|
|
18 |
val subset_range_iff = result();
|
|
19 |
|
|
20 |
|
|
21 |
open Shared;
|
|
22 |
|
1964
|
23 |
(*Holds because Friend is injective: thus cannot prove for all f*)
|
|
24 |
goal thy "(Friend x : Friend``A) = (x:A)";
|
|
25 |
by (Auto_tac());
|
|
26 |
qed "Friend_image_eq";
|
|
27 |
Addsimps [Friend_image_eq];
|
|
28 |
|
1934
|
29 |
Addsimps [Un_insert_left, Un_insert_right];
|
|
30 |
|
|
31 |
(*By default only o_apply is built-in. But in the presence of eta-expansion
|
|
32 |
this means that some terms displayed as (f o g) will be rewritten, and others
|
|
33 |
will not!*)
|
|
34 |
Addsimps [o_def];
|
|
35 |
|
1943
|
36 |
(*** Basic properties of shrK and newK ***)
|
1934
|
37 |
|
1943
|
38 |
(* invKey (shrK A) = shrK A *)
|
|
39 |
bind_thm ("invKey_shrK", rewrite_rule [isSymKey_def] isSym_shrK);
|
1934
|
40 |
|
|
41 |
(* invKey (newK evs) = newK evs *)
|
|
42 |
bind_thm ("invKey_newK", rewrite_rule [isSymKey_def] isSym_newK);
|
1943
|
43 |
Addsimps [invKey_shrK, invKey_newK];
|
1934
|
44 |
|
|
45 |
|
|
46 |
(*New keys and nonces are fresh*)
|
1943
|
47 |
val shrK_inject = inj_shrK RS injD;
|
1934
|
48 |
val newN_inject = inj_newN RS injD
|
|
49 |
and newK_inject = inj_newK RS injD;
|
1943
|
50 |
AddSEs [shrK_inject, newN_inject, newK_inject,
|
1934
|
51 |
fresh_newK RS notE, fresh_newN RS notE];
|
1943
|
52 |
Addsimps [inj_shrK RS inj_eq, inj_newN RS inj_eq, inj_newK RS inj_eq];
|
1934
|
53 |
Addsimps [fresh_newN, fresh_newK];
|
|
54 |
|
|
55 |
(** Rewrites should not refer to initState(Friend i)
|
|
56 |
-- not in normal form! **)
|
|
57 |
|
1943
|
58 |
goal thy "newK evs ~= shrK B";
|
|
59 |
by (subgoal_tac "newK evs = shrK B --> \
|
1934
|
60 |
\ Key (newK evs) : parts (initState B)" 1);
|
|
61 |
by (Fast_tac 1);
|
|
62 |
by (agent.induct_tac "B" 1);
|
1967
|
63 |
by (auto_tac (!claset addIs [range_eqI], !simpset addsimps [bad_def]));
|
1943
|
64 |
qed "newK_neq_shrK";
|
1934
|
65 |
|
1943
|
66 |
Addsimps [newK_neq_shrK, newK_neq_shrK RS not_sym];
|
1934
|
67 |
|
|
68 |
(*Good for talking about Server's initial state*)
|
|
69 |
goal thy "!!H. H <= Key``E ==> parts H = H";
|
|
70 |
by (Auto_tac ());
|
|
71 |
be parts.induct 1;
|
|
72 |
by (ALLGOALS (fast_tac (!claset addss (!simpset))));
|
|
73 |
qed "parts_image_subset";
|
|
74 |
|
|
75 |
bind_thm ("parts_image_Key", subset_refl RS parts_image_subset);
|
|
76 |
|
|
77 |
goal thy "!!H. H <= Key``E ==> analz H = H";
|
|
78 |
by (Auto_tac ());
|
|
79 |
be analz.induct 1;
|
|
80 |
by (ALLGOALS (fast_tac (!claset addss (!simpset))));
|
|
81 |
qed "analz_image_subset";
|
|
82 |
|
|
83 |
bind_thm ("analz_image_Key", subset_refl RS analz_image_subset);
|
|
84 |
|
|
85 |
Addsimps [parts_image_Key, analz_image_Key];
|
|
86 |
|
|
87 |
goalw thy [keysFor_def] "keysFor (parts (initState C)) = {}";
|
|
88 |
by (agent.induct_tac "C" 1);
|
|
89 |
by (auto_tac (!claset addIs [range_eqI] delrules partsEs, !simpset));
|
|
90 |
qed "keysFor_parts_initState";
|
|
91 |
Addsimps [keysFor_parts_initState];
|
|
92 |
|
|
93 |
goalw thy [keysFor_def] "keysFor (Key``E) = {}";
|
|
94 |
by (Auto_tac ());
|
|
95 |
qed "keysFor_image_Key";
|
|
96 |
Addsimps [keysFor_image_Key];
|
|
97 |
|
1943
|
98 |
goal thy "shrK A ~: newK``E";
|
1934
|
99 |
by (agent.induct_tac "A" 1);
|
|
100 |
by (Auto_tac ());
|
1943
|
101 |
qed "shrK_notin_image_newK";
|
|
102 |
Addsimps [shrK_notin_image_newK];
|
1934
|
103 |
|
1964
|
104 |
(*Agents see their own shared keys!*)
|
|
105 |
goal thy "Key (shrK A) : sees A evs";
|
1934
|
106 |
by (list.induct_tac "evs" 1);
|
|
107 |
by (agent.induct_tac "A" 1);
|
1967
|
108 |
by (auto_tac (!claset, !simpset addsimps [bad_def]));
|
1964
|
109 |
qed "sees_own_shrK";
|
1934
|
110 |
|
1967
|
111 |
(*Enemy sees shared keys of bad agents!*)
|
|
112 |
goal thy "!!i. A: bad ==> Key (shrK A) : sees Enemy evs";
|
1964
|
113 |
by (list.induct_tac "evs" 1);
|
1967
|
114 |
by (auto_tac (!claset, !simpset addsimps [bad_def]));
|
|
115 |
qed "Enemy_sees_bad";
|
1934
|
116 |
|
1967
|
117 |
AddSIs [sees_own_shrK, Enemy_sees_bad];
|
1934
|
118 |
|
|
119 |
|
|
120 |
(** Specialized rewrite rules for (sees A (Says...#evs)) **)
|
|
121 |
|
|
122 |
goal thy "sees A (Says A B X # evs) = insert X (sees A evs)";
|
|
123 |
by (Simp_tac 1);
|
|
124 |
qed "sees_own";
|
|
125 |
|
|
126 |
goal thy "!!A. Server ~= A ==> \
|
|
127 |
\ sees Server (Says A B X # evs) = sees Server evs";
|
|
128 |
by (Asm_simp_tac 1);
|
|
129 |
qed "sees_Server";
|
|
130 |
|
|
131 |
goal thy "!!A. Friend i ~= A ==> \
|
|
132 |
\ sees (Friend i) (Says A B X # evs) = sees (Friend i) evs";
|
|
133 |
by (Asm_simp_tac 1);
|
|
134 |
qed "sees_Friend";
|
|
135 |
|
|
136 |
goal thy "sees Enemy (Says A B X # evs) = insert X (sees Enemy evs)";
|
|
137 |
by (Simp_tac 1);
|
|
138 |
qed "sees_Enemy";
|
|
139 |
|
|
140 |
goal thy "sees A (Says A' B X # evs) <= insert X (sees A evs)";
|
|
141 |
by (simp_tac (!simpset setloop split_tac [expand_if]) 1);
|
|
142 |
by (Fast_tac 1);
|
|
143 |
qed "sees_Says_subset_insert";
|
|
144 |
|
1943
|
145 |
goal thy "sees A (Notes A' X # evs) <= insert X (sees A evs)";
|
|
146 |
by (simp_tac (!simpset setloop split_tac [expand_if]) 1);
|
|
147 |
by (Fast_tac 1);
|
|
148 |
qed "sees_Notes_subset_insert";
|
|
149 |
|
1934
|
150 |
goal thy "sees A evs <= sees A (Says A' B X # evs)";
|
|
151 |
by (simp_tac (!simpset setloop split_tac [expand_if]) 1);
|
|
152 |
by (Fast_tac 1);
|
|
153 |
qed "sees_subset_sees_Says";
|
|
154 |
|
|
155 |
(*Pushing Unions into parts; one of the A's equals B, and thus sees Y*)
|
|
156 |
goal thy "(UN A. parts (sees A (Says B C Y # evs))) = \
|
|
157 |
\ parts {Y} Un (UN A. parts (sees A evs))";
|
|
158 |
by (Step_tac 1);
|
|
159 |
be rev_mp 1; (*for some reason, split_tac does not work on assumptions*)
|
|
160 |
val ss = (!simpset addsimps [parts_Un, sees_Cons]
|
|
161 |
setloop split_tac [expand_if]);
|
|
162 |
by (ALLGOALS (fast_tac (!claset addss ss)));
|
|
163 |
qed "UN_parts_sees_Says";
|
|
164 |
|
|
165 |
goal thy "Says A B X : set_of_list evs --> X : sees Enemy evs";
|
|
166 |
by (list.induct_tac "evs" 1);
|
|
167 |
by (Auto_tac ());
|
|
168 |
qed_spec_mp "Says_imp_sees_Enemy";
|
|
169 |
|
|
170 |
Addsimps [Says_imp_sees_Enemy];
|
|
171 |
AddIs [Says_imp_sees_Enemy];
|
|
172 |
|
1943
|
173 |
goal thy "initState C <= Key `` range shrK";
|
1934
|
174 |
by (agent.induct_tac "C" 1);
|
|
175 |
by (Auto_tac ());
|
|
176 |
qed "initState_subset";
|
|
177 |
|
|
178 |
goal thy "X : sees C evs --> \
|
|
179 |
\ (EX A B. Says A B X : set_of_list evs) | \
|
|
180 |
\ (EX A. Notes A X : set_of_list evs) | \
|
1943
|
181 |
\ (EX A. X = Key (shrK A))";
|
1934
|
182 |
by (list.induct_tac "evs" 1);
|
|
183 |
by (ALLGOALS Asm_simp_tac);
|
|
184 |
by (fast_tac (!claset addDs [impOfSubs initState_subset]) 1);
|
|
185 |
br conjI 1;
|
|
186 |
by (Fast_tac 2);
|
|
187 |
by (event.induct_tac "a" 1);
|
|
188 |
by (ALLGOALS (asm_simp_tac (!simpset addsimps [mem_if])));
|
|
189 |
by (ALLGOALS Fast_tac);
|
|
190 |
qed_spec_mp "seesD";
|
|
191 |
|
|
192 |
|
|
193 |
Addsimps [UN_parts_sees_Says, sees_own, sees_Server, sees_Friend, sees_Enemy];
|
|
194 |
Delsimps [sees_Cons]; (**** NOTE REMOVAL -- laws above are cleaner ****)
|
|
195 |
|
|
196 |
|
|
197 |
goal thy "!!K. newK evs = invKey K ==> newK evs = K";
|
|
198 |
br (invKey_eq RS iffD1) 1;
|
|
199 |
by (Simp_tac 1);
|
|
200 |
val newK_invKey = result();
|
|
201 |
|
|
202 |
|
|
203 |
(** Rewrites to push in Key and Crypt messages, so that other messages can
|
|
204 |
be pulled out using the analz_insert rules **)
|
|
205 |
|
|
206 |
fun insComm x y = read_instantiate_sg (sign_of thy) [("x",x), ("y",y)]
|
|
207 |
insert_commute;
|
|
208 |
|
|
209 |
val pushKeys = map (insComm "Key ?K")
|
|
210 |
["Agent ?C", "Nonce ?N", "MPair ?X ?Y", "Crypt ?X ?K'"];
|
|
211 |
|
|
212 |
val pushCrypts = map (insComm "Crypt ?X ?K")
|
|
213 |
["Agent ?C", "Nonce ?N", "MPair ?X' ?Y"];
|
|
214 |
|
|
215 |
(*Cannot be added with Addsimps -- we don't always want to re-order messages*)
|
|
216 |
val pushes = pushKeys@pushCrypts;
|
|
217 |
|
1943
|
218 |
val pushKey_newK = insComm "Key (newK ?evs)" "Key (shrK ?C)";
|
1934
|
219 |
|
|
220 |
|