| 13508 |      1 | (******************************************************************************
 | 
|  |      2 | from G. Karjoth, N. Asokan and C. Gulcu
 | 
|  |      3 | "Protecting the computation results of free-roaming agents"
 | 
|  |      4 | Mobiles Agents 1998, LNCS 1477
 | 
|  |      5 | 
 | 
|  |      6 | date: march 2002
 | 
|  |      7 | author: Frederic Blanqui
 | 
|  |      8 | email: blanqui@lri.fr
 | 
|  |      9 | webpage: http://www.lri.fr/~blanqui/
 | 
|  |     10 | 
 | 
|  |     11 | University of Cambridge, Computer Laboratory
 | 
|  |     12 | William Gates Building, JJ Thomson Avenue
 | 
|  |     13 | Cambridge CB3 0FD, United Kingdom
 | 
|  |     14 | ******************************************************************************)
 | 
|  |     15 | 
 | 
|  |     16 | header{*Protocol P2*}
 | 
|  |     17 | 
 | 
| 16417 |     18 | theory P2 imports Guard_Public List_Msg begin
 | 
| 13508 |     19 | 
 | 
|  |     20 | subsection{*Protocol Definition*}
 | 
|  |     21 | 
 | 
|  |     22 | 
 | 
|  |     23 | text{*Like P1 except the definitions of @{text chain}, @{text shop},
 | 
|  |     24 |   @{text next_shop} and @{text nonce}*}
 | 
|  |     25 | 
 | 
|  |     26 | subsubsection{*offer chaining:
 | 
|  |     27 | B chains his offer for A with the head offer of L for sending it to C*}
 | 
|  |     28 | 
 | 
|  |     29 | constdefs chain :: "agent => nat => agent => msg => agent => msg"
 | 
|  |     30 | "chain B ofr A L C ==
 | 
|  |     31 | let m1= sign B (Nonce ofr) in
 | 
|  |     32 | let m2= Hash {|head L, Agent C|} in
 | 
|  |     33 | {|Crypt (pubK A) m1, m2|}"
 | 
|  |     34 | 
 | 
|  |     35 | declare Let_def [simp]
 | 
|  |     36 | 
 | 
|  |     37 | lemma chain_inj [iff]: "(chain B ofr A L C = chain B' ofr' A' L' C')
 | 
|  |     38 | = (B=B' & ofr=ofr' & A=A' & head L = head L' & C=C')"
 | 
|  |     39 | by (auto simp: chain_def Let_def)
 | 
|  |     40 | 
 | 
|  |     41 | lemma Nonce_in_chain [iff]: "Nonce ofr:parts {chain B ofr A L C}"
 | 
|  |     42 | by (auto simp: chain_def sign_def)
 | 
|  |     43 | 
 | 
|  |     44 | subsubsection{*agent whose key is used to sign an offer*}
 | 
|  |     45 | 
 | 
|  |     46 | consts shop :: "msg => msg"
 | 
|  |     47 | 
 | 
|  |     48 | recdef shop "measure size"
 | 
|  |     49 | "shop {|Crypt K {|B,ofr,Crypt K' H|},m2|} = Agent (agt K')"
 | 
|  |     50 | 
 | 
|  |     51 | lemma shop_chain [simp]: "shop (chain B ofr A L C) = Agent B"
 | 
|  |     52 | by (simp add: chain_def sign_def)
 | 
|  |     53 | 
 | 
|  |     54 | subsubsection{*nonce used in an offer*}
 | 
|  |     55 | 
 | 
|  |     56 | consts nonce :: "msg => msg"
 | 
|  |     57 | 
 | 
|  |     58 | recdef nonce "measure size"
 | 
|  |     59 | "nonce {|Crypt K {|B,ofr,CryptH|},m2|} = ofr"
 | 
|  |     60 | 
 | 
|  |     61 | lemma nonce_chain [simp]: "nonce (chain B ofr A L C) = Nonce ofr"
 | 
|  |     62 | by (simp add: chain_def sign_def)
 | 
|  |     63 | 
 | 
|  |     64 | subsubsection{*next shop*}
 | 
|  |     65 | 
 | 
|  |     66 | consts next_shop :: "msg => agent"
 | 
|  |     67 | 
 | 
|  |     68 | recdef next_shop "measure size"
 | 
|  |     69 | "next_shop {|m1,Hash {|headL,Agent C|}|} = C"
 | 
|  |     70 | 
 | 
|  |     71 | lemma "next_shop (chain B ofr A L C) = C"
 | 
|  |     72 | by (simp add: chain_def sign_def)
 | 
|  |     73 | 
 | 
|  |     74 | subsubsection{*anchor of the offer list*}
 | 
|  |     75 | 
 | 
|  |     76 | constdefs anchor :: "agent => nat => agent => msg"
 | 
|  |     77 | "anchor A n B == chain A n A (cons nil nil) B"
 | 
|  |     78 | 
 | 
|  |     79 | lemma anchor_inj [iff]:
 | 
|  |     80 |      "(anchor A n B = anchor A' n' B') = (A=A' & n=n' & B=B')"
 | 
|  |     81 | by (auto simp: anchor_def)
 | 
|  |     82 | 
 | 
|  |     83 | lemma Nonce_in_anchor [iff]: "Nonce n:parts {anchor A n B}"
 | 
|  |     84 | by (auto simp: anchor_def)
 | 
|  |     85 | 
 | 
|  |     86 | lemma shop_anchor [simp]: "shop (anchor A n B) = Agent A"
 | 
|  |     87 | by (simp add: anchor_def)
 | 
|  |     88 | 
 | 
|  |     89 | subsubsection{*request event*}
 | 
|  |     90 | 
 | 
|  |     91 | constdefs reqm :: "agent => nat => nat => msg => agent => msg"
 | 
|  |     92 | "reqm A r n I B == {|Agent A, Number r, cons (Agent A) (cons (Agent B) I),
 | 
|  |     93 | cons (anchor A n B) nil|}"
 | 
|  |     94 | 
 | 
|  |     95 | lemma reqm_inj [iff]: "(reqm A r n I B = reqm A' r' n' I' B')
 | 
|  |     96 | = (A=A' & r=r' & n=n' & I=I' & B=B')"
 | 
|  |     97 | by (auto simp: reqm_def)
 | 
|  |     98 | 
 | 
|  |     99 | lemma Nonce_in_reqm [iff]: "Nonce n:parts {reqm A r n I B}"
 | 
|  |    100 | by (auto simp: reqm_def)
 | 
|  |    101 | 
 | 
|  |    102 | constdefs req :: "agent => nat => nat => msg => agent => event"
 | 
|  |    103 | "req A r n I B == Says A B (reqm A r n I B)"
 | 
|  |    104 | 
 | 
|  |    105 | lemma req_inj [iff]: "(req A r n I B = req A' r' n' I' B')
 | 
|  |    106 | = (A=A' & r=r' & n=n' & I=I' & B=B')"
 | 
|  |    107 | by (auto simp: req_def)
 | 
|  |    108 | 
 | 
|  |    109 | subsubsection{*propose event*}
 | 
|  |    110 | 
 | 
|  |    111 | constdefs prom :: "agent => nat => agent => nat => msg => msg =>
 | 
|  |    112 | msg => agent => msg"
 | 
|  |    113 | "prom B ofr A r I L J C == {|Agent A, Number r,
 | 
|  |    114 | app (J, del (Agent B, I)), cons (chain B ofr A L C) L|}"
 | 
|  |    115 | 
 | 
|  |    116 | lemma prom_inj [dest]: "prom B ofr A r I L J C = prom B' ofr' A' r' I' L' J' C'
 | 
|  |    117 | ==> B=B' & ofr=ofr' & A=A' & r=r' & L=L' & C=C'"
 | 
|  |    118 | by (auto simp: prom_def)
 | 
|  |    119 | 
 | 
|  |    120 | lemma Nonce_in_prom [iff]: "Nonce ofr:parts {prom B ofr A r I L J C}"
 | 
|  |    121 | by (auto simp: prom_def)
 | 
|  |    122 | 
 | 
|  |    123 | constdefs pro :: "agent => nat => agent => nat => msg => msg =>
 | 
|  |    124 |                   msg => agent => event"
 | 
|  |    125 | "pro B ofr A r I L J C == Says B C (prom B ofr A r I L J C)"
 | 
|  |    126 | 
 | 
|  |    127 | lemma pro_inj [dest]: "pro B ofr A r I L J C = pro B' ofr' A' r' I' L' J' C'
 | 
|  |    128 | ==> B=B' & ofr=ofr' & A=A' & r=r' & L=L' & C=C'"
 | 
|  |    129 | by (auto simp: pro_def dest: prom_inj)
 | 
|  |    130 | 
 | 
|  |    131 | subsubsection{*protocol*}
 | 
|  |    132 | 
 | 
|  |    133 | consts p2 :: "event list set"
 | 
|  |    134 | 
 | 
|  |    135 | inductive p2
 | 
|  |    136 | intros
 | 
|  |    137 | 
 | 
|  |    138 | Nil: "[]:p2"
 | 
|  |    139 | 
 | 
|  |    140 | Fake: "[| evsf:p2; X:synth (analz (spies evsf)) |] ==> Says Spy B X # evsf : p2"
 | 
|  |    141 | 
 | 
|  |    142 | Request: "[| evsr:p2; Nonce n ~:used evsr; I:agl |] ==> req A r n I B # evsr : p2"
 | 
|  |    143 | 
 | 
|  |    144 | Propose: "[| evsp:p2; Says A' B {|Agent A,Number r,I,cons M L|}:set evsp;
 | 
|  |    145 | I:agl; J:agl; isin (Agent C, app (J, del (Agent B, I)));
 | 
|  |    146 | Nonce ofr ~:used evsp |] ==> pro B ofr A r I (cons M L) J C # evsp : p2"
 | 
|  |    147 | 
 | 
|  |    148 | subsubsection{*valid offer lists*}
 | 
|  |    149 | 
 | 
|  |    150 | consts valid :: "agent => nat => agent => msg set"
 | 
|  |    151 | 
 | 
|  |    152 | inductive "valid A n B"
 | 
|  |    153 | intros
 | 
|  |    154 | Request [intro]: "cons (anchor A n B) nil:valid A n B"
 | 
|  |    155 | 
 | 
|  |    156 | Propose [intro]: "L:valid A n B
 | 
|  |    157 | ==> cons (chain (next_shop (head L)) ofr A L C) L:valid A n B"
 | 
|  |    158 | 
 | 
|  |    159 | subsubsection{*basic properties of valid*}
 | 
|  |    160 | 
 | 
|  |    161 | lemma valid_not_empty: "L:valid A n B ==> EX M L'. L = cons M L'"
 | 
|  |    162 | by (erule valid.cases, auto)
 | 
|  |    163 | 
 | 
|  |    164 | lemma valid_pos_len: "L:valid A n B ==> 0 < len L"
 | 
|  |    165 | by (erule valid.induct, auto)
 | 
|  |    166 | 
 | 
|  |    167 | subsubsection{*list of offers*}
 | 
|  |    168 | 
 | 
|  |    169 | consts offers :: "msg => msg"
 | 
|  |    170 | 
 | 
|  |    171 | recdef offers "measure size"
 | 
|  |    172 | "offers (cons M L) = cons {|shop M, nonce M|} (offers L)"
 | 
|  |    173 | "offers other = nil"
 | 
|  |    174 | 
 | 
|  |    175 | 
 | 
|  |    176 | subsection{*Properties of Protocol P2*}
 | 
|  |    177 | 
 | 
|  |    178 | text{*same as @{text P1_Prop} except that publicly verifiable forward
 | 
|  |    179 | integrity is replaced by forward privacy*}
 | 
|  |    180 | 
 | 
|  |    181 | subsection{*strong forward integrity:
 | 
|  |    182 | except the last one, no offer can be modified*}
 | 
|  |    183 | 
 | 
|  |    184 | lemma strong_forward_integrity: "ALL L. Suc i < len L
 | 
|  |    185 | --> L:valid A n B --> repl (L,Suc i,M):valid A n B --> M = ith (L,Suc i)"
 | 
|  |    186 | apply (induct i)
 | 
|  |    187 | (* i = 0 *)
 | 
|  |    188 | apply clarify
 | 
|  |    189 | apply (frule len_not_empty, clarsimp)
 | 
|  |    190 | apply (frule len_not_empty, clarsimp)
 | 
|  |    191 | apply (ind_cases "{|x,xa,l'a|}:valid A n B")
 | 
|  |    192 | apply (ind_cases "{|x,M,l'a|}:valid A n B")
 | 
|  |    193 | apply (simp add: chain_def)
 | 
|  |    194 | (* i > 0 *)
 | 
|  |    195 | apply clarify
 | 
|  |    196 | apply (frule len_not_empty, clarsimp)
 | 
|  |    197 | apply (ind_cases "{|x,repl(l',Suc na,M)|}:valid A n B")
 | 
|  |    198 | apply (frule len_not_empty, clarsimp)
 | 
|  |    199 | apply (ind_cases "{|x,l'|}:valid A n B")
 | 
|  |    200 | by (drule_tac x=l' in spec, simp, blast)
 | 
|  |    201 | 
 | 
|  |    202 | subsection{*insertion resilience:
 | 
|  |    203 | except at the beginning, no offer can be inserted*}
 | 
|  |    204 | 
 | 
|  |    205 | lemma chain_isnt_head [simp]: "L:valid A n B ==>
 | 
|  |    206 | head L ~= chain (next_shop (head L)) ofr A L C"
 | 
|  |    207 | by (erule valid.induct, auto simp: chain_def sign_def anchor_def)
 | 
|  |    208 | 
 | 
|  |    209 | lemma insertion_resilience: "ALL L. L:valid A n B --> Suc i < len L
 | 
|  |    210 | --> ins (L,Suc i,M) ~:valid A n B"
 | 
|  |    211 | apply (induct i)
 | 
|  |    212 | (* i = 0 *)
 | 
|  |    213 | apply clarify
 | 
|  |    214 | apply (frule len_not_empty, clarsimp)
 | 
|  |    215 | apply (ind_cases "{|x,l'|}:valid A n B", simp)
 | 
|  |    216 | apply (ind_cases "{|x,M,l'|}:valid A n B", clarsimp)
 | 
|  |    217 | apply (ind_cases "{|head l',l'|}:valid A n B", simp, simp)
 | 
|  |    218 | (* i > 0 *)
 | 
|  |    219 | apply clarify
 | 
|  |    220 | apply (frule len_not_empty, clarsimp)
 | 
|  |    221 | apply (ind_cases "{|x,l'|}:valid A n B")
 | 
|  |    222 | apply (frule len_not_empty, clarsimp)
 | 
|  |    223 | apply (ind_cases "{|x,ins(l',Suc na,M)|}:valid A n B")
 | 
|  |    224 | apply (frule len_not_empty, clarsimp)
 | 
|  |    225 | by (drule_tac x=l' in spec, clarsimp)
 | 
|  |    226 | 
 | 
|  |    227 | subsection{*truncation resilience:
 | 
|  |    228 | only shop i can truncate at offer i*}
 | 
|  |    229 | 
 | 
|  |    230 | lemma truncation_resilience: "ALL L. L:valid A n B --> Suc i < len L
 | 
|  |    231 | --> cons M (trunc (L,Suc i)):valid A n B --> shop M = shop (ith (L,i))"
 | 
|  |    232 | apply (induct i)
 | 
|  |    233 | (* i = 0 *)
 | 
|  |    234 | apply clarify
 | 
|  |    235 | apply (frule len_not_empty, clarsimp)
 | 
|  |    236 | apply (ind_cases "{|x,l'|}:valid A n B")
 | 
|  |    237 | apply (frule len_not_empty, clarsimp)
 | 
|  |    238 | apply (ind_cases "{|M,l'|}:valid A n B")
 | 
|  |    239 | apply (frule len_not_empty, clarsimp, simp)
 | 
|  |    240 | (* i > 0 *)
 | 
|  |    241 | apply clarify
 | 
|  |    242 | apply (frule len_not_empty, clarsimp)
 | 
|  |    243 | apply (ind_cases "{|x,l'|}:valid A n B")
 | 
|  |    244 | apply (frule len_not_empty, clarsimp)
 | 
|  |    245 | by (drule_tac x=l' in spec, clarsimp)
 | 
|  |    246 | 
 | 
|  |    247 | subsection{*declarations for tactics*}
 | 
|  |    248 | 
 | 
|  |    249 | declare knows_Spy_partsEs [elim]
 | 
|  |    250 | declare Fake_parts_insert [THEN subsetD, dest]
 | 
|  |    251 | declare initState.simps [simp del]
 | 
|  |    252 | 
 | 
|  |    253 | subsection{*get components of a message*}
 | 
|  |    254 | 
 | 
|  |    255 | lemma get_ML [dest]: "Says A' B {|A,R,I,M,L|}:set evs ==>
 | 
|  |    256 | M:parts (spies evs) & L:parts (spies evs)"
 | 
|  |    257 | by blast
 | 
|  |    258 | 
 | 
|  |    259 | subsection{*general properties of p2*}
 | 
|  |    260 | 
 | 
|  |    261 | lemma reqm_neq_prom [iff]:
 | 
|  |    262 | "reqm A r n I B ~= prom B' ofr A' r' I' (cons M L) J C"
 | 
|  |    263 | by (auto simp: reqm_def prom_def)
 | 
|  |    264 | 
 | 
|  |    265 | lemma prom_neq_reqm [iff]:
 | 
|  |    266 | "prom B' ofr A' r' I' (cons M L) J C ~= reqm A r n I B"
 | 
|  |    267 | by (auto simp: reqm_def prom_def)
 | 
|  |    268 | 
 | 
|  |    269 | lemma req_neq_pro [iff]: "req A r n I B ~= pro B' ofr A' r' I' (cons M L) J C"
 | 
|  |    270 | by (auto simp: req_def pro_def)
 | 
|  |    271 | 
 | 
|  |    272 | lemma pro_neq_req [iff]: "pro B' ofr A' r' I' (cons M L) J C ~= req A r n I B"
 | 
|  |    273 | by (auto simp: req_def pro_def)
 | 
|  |    274 | 
 | 
|  |    275 | lemma p2_has_no_Gets: "evs:p2 ==> ALL A X. Gets A X ~:set evs"
 | 
|  |    276 | by (erule p2.induct, auto simp: req_def pro_def)
 | 
|  |    277 | 
 | 
|  |    278 | lemma p2_is_Gets_correct [iff]: "Gets_correct p2"
 | 
|  |    279 | by (auto simp: Gets_correct_def dest: p2_has_no_Gets)
 | 
|  |    280 | 
 | 
|  |    281 | lemma p2_is_one_step [iff]: "one_step p2"
 | 
|  |    282 | by (unfold one_step_def, clarify, ind_cases "ev#evs:p2", auto)
 | 
|  |    283 | 
 | 
|  |    284 | lemma p2_has_only_Says' [rule_format]: "evs:p2 ==>
 | 
|  |    285 | ev:set evs --> (EX A B X. ev=Says A B X)"
 | 
|  |    286 | by (erule p2.induct, auto simp: req_def pro_def)
 | 
|  |    287 | 
 | 
|  |    288 | lemma p2_has_only_Says [iff]: "has_only_Says p2"
 | 
|  |    289 | by (auto simp: has_only_Says_def dest: p2_has_only_Says')
 | 
|  |    290 | 
 | 
|  |    291 | lemma p2_is_regular [iff]: "regular p2"
 | 
|  |    292 | apply (simp only: regular_def, clarify)
 | 
|  |    293 | apply (erule_tac p2.induct)
 | 
|  |    294 | apply (simp_all add: initState.simps knows.simps pro_def prom_def
 | 
|  |    295 | req_def reqm_def anchor_def chain_def sign_def)
 | 
|  |    296 | by (auto dest: no_Key_in_agl no_Key_in_appdel parts_trans)
 | 
|  |    297 | 
 | 
|  |    298 | subsection{*private keys are safe*}
 | 
|  |    299 | 
 | 
|  |    300 | lemma priK_parts_Friend_imp_bad [rule_format,dest]:
 | 
|  |    301 |      "[| evs:p2; Friend B ~= A |]
 | 
|  |    302 |       ==> (Key (priK A):parts (knows (Friend B) evs)) --> (A:bad)"
 | 
|  |    303 | apply (erule p2.induct)
 | 
|  |    304 | apply (simp_all add: initState.simps knows.simps pro_def prom_def
 | 
|  |    305 |                 req_def reqm_def anchor_def chain_def sign_def, blast) 
 | 
|  |    306 | apply (blast dest: no_Key_in_agl)
 | 
|  |    307 | apply (auto del: parts_invKey disjE  dest: parts_trans
 | 
|  |    308 |             simp add: no_Key_in_appdel)
 | 
|  |    309 | done
 | 
|  |    310 | 
 | 
|  |    311 | lemma priK_analz_Friend_imp_bad [rule_format,dest]:
 | 
|  |    312 |      "[| evs:p2; Friend B ~= A |]
 | 
|  |    313 | ==> (Key (priK A):analz (knows (Friend B) evs)) --> (A:bad)"
 | 
|  |    314 | by auto
 | 
|  |    315 | 
 | 
|  |    316 | lemma priK_notin_knows_max_Friend:
 | 
|  |    317 |      "[| evs:p2; A ~:bad; A ~= Friend C |]
 | 
|  |    318 |       ==> Key (priK A) ~:analz (knows_max (Friend C) evs)"
 | 
|  |    319 | apply (rule not_parts_not_analz, simp add: knows_max_def, safe)
 | 
|  |    320 | apply (drule_tac H="spies' evs" in parts_sub)
 | 
|  |    321 | apply (rule_tac p=p2 in knows_max'_sub_spies', simp+)
 | 
|  |    322 | apply (drule_tac H="spies evs" in parts_sub)
 | 
|  |    323 | by (auto dest: knows'_sub_knows [THEN subsetD] priK_notin_initState_Friend)
 | 
|  |    324 | 
 | 
|  |    325 | subsection{*general guardedness properties*}
 | 
|  |    326 | 
 | 
|  |    327 | lemma agl_guard [intro]: "I:agl ==> I:guard n Ks"
 | 
|  |    328 | by (erule agl.induct, auto)
 | 
|  |    329 | 
 | 
|  |    330 | lemma Says_to_knows_max'_guard: "[| Says A' C {|A'',r,I,L|}:set evs;
 | 
|  |    331 | Guard n Ks (knows_max' C evs) |] ==> L:guard n Ks"
 | 
|  |    332 | by (auto dest: Says_to_knows_max')
 | 
|  |    333 | 
 | 
|  |    334 | lemma Says_from_knows_max'_guard: "[| Says C A' {|A'',r,I,L|}:set evs;
 | 
|  |    335 | Guard n Ks (knows_max' C evs) |] ==> L:guard n Ks"
 | 
|  |    336 | by (auto dest: Says_from_knows_max')
 | 
|  |    337 | 
 | 
|  |    338 | lemma Says_Nonce_not_used_guard: "[| Says A' B {|A'',r,I,L|}:set evs;
 | 
|  |    339 | Nonce n ~:used evs |] ==> L:guard n Ks"
 | 
|  |    340 | by (drule not_used_not_parts, auto)
 | 
|  |    341 | 
 | 
|  |    342 | subsection{*guardedness of messages*}
 | 
|  |    343 | 
 | 
|  |    344 | lemma chain_guard [iff]: "chain B ofr A L C:guard n {priK A}"
 | 
|  |    345 | by (case_tac "ofr=n", auto simp: chain_def sign_def)
 | 
|  |    346 | 
 | 
|  |    347 | lemma chain_guard_Nonce_neq [intro]: "n ~= ofr
 | 
|  |    348 | ==> chain B ofr A' L C:guard n {priK A}"
 | 
|  |    349 | by (auto simp: chain_def sign_def)
 | 
|  |    350 | 
 | 
|  |    351 | lemma anchor_guard [iff]: "anchor A n' B:guard n {priK A}"
 | 
|  |    352 | by (case_tac "n'=n", auto simp: anchor_def)
 | 
|  |    353 | 
 | 
|  |    354 | lemma anchor_guard_Nonce_neq [intro]: "n ~= n'
 | 
|  |    355 | ==> anchor A' n' B:guard n {priK A}"
 | 
|  |    356 | by (auto simp: anchor_def)
 | 
|  |    357 | 
 | 
|  |    358 | lemma reqm_guard [intro]: "I:agl ==> reqm A r n' I B:guard n {priK A}"
 | 
|  |    359 | by (case_tac "n'=n", auto simp: reqm_def)
 | 
|  |    360 | 
 | 
|  |    361 | lemma reqm_guard_Nonce_neq [intro]: "[| n ~= n'; I:agl |]
 | 
|  |    362 | ==> reqm A' r n' I B:guard n {priK A}"
 | 
|  |    363 | by (auto simp: reqm_def)
 | 
|  |    364 | 
 | 
|  |    365 | lemma prom_guard [intro]: "[| I:agl; J:agl; L:guard n {priK A} |]
 | 
|  |    366 | ==> prom B ofr A r I L J C:guard n {priK A}"
 | 
|  |    367 | by (auto simp: prom_def)
 | 
|  |    368 | 
 | 
|  |    369 | lemma prom_guard_Nonce_neq [intro]: "[| n ~= ofr; I:agl; J:agl;
 | 
|  |    370 | L:guard n {priK A} |] ==> prom B ofr A' r I L J C:guard n {priK A}"
 | 
|  |    371 | by (auto simp: prom_def)
 | 
|  |    372 | 
 | 
|  |    373 | subsection{*Nonce uniqueness*}
 | 
|  |    374 | 
 | 
|  |    375 | lemma uniq_Nonce_in_chain [dest]: "Nonce k:parts {chain B ofr A L C} ==> k=ofr"
 | 
|  |    376 | by (auto simp: chain_def sign_def)
 | 
|  |    377 | 
 | 
|  |    378 | lemma uniq_Nonce_in_anchor [dest]: "Nonce k:parts {anchor A n B} ==> k=n"
 | 
|  |    379 | by (auto simp: anchor_def chain_def sign_def)
 | 
|  |    380 | 
 | 
|  |    381 | lemma uniq_Nonce_in_reqm [dest]: "[| Nonce k:parts {reqm A r n I B};
 | 
|  |    382 | I:agl |] ==> k=n"
 | 
|  |    383 | by (auto simp: reqm_def dest: no_Nonce_in_agl)
 | 
|  |    384 | 
 | 
|  |    385 | lemma uniq_Nonce_in_prom [dest]: "[| Nonce k:parts {prom B ofr A r I L J C};
 | 
|  |    386 | I:agl; J:agl; Nonce k ~:parts {L} |] ==> k=ofr"
 | 
|  |    387 | by (auto simp: prom_def dest: no_Nonce_in_agl no_Nonce_in_appdel)
 | 
|  |    388 | 
 | 
|  |    389 | subsection{*requests are guarded*}
 | 
|  |    390 | 
 | 
|  |    391 | lemma req_imp_Guard [rule_format]: "[| evs:p2; A ~:bad |] ==>
 | 
|  |    392 | req A r n I B:set evs --> Guard n {priK A} (spies evs)"
 | 
|  |    393 | apply (erule p2.induct, simp)
 | 
|  |    394 | apply (simp add: req_def knows.simps, safe)
 | 
|  |    395 | apply (erule in_synth_Guard, erule Guard_analz, simp)
 | 
|  |    396 | by (auto simp: req_def pro_def dest: Says_imp_knows_Spy)
 | 
|  |    397 | 
 | 
|  |    398 | lemma req_imp_Guard_Friend: "[| evs:p2; A ~:bad; req A r n I B:set evs |]
 | 
|  |    399 | ==> Guard n {priK A} (knows_max (Friend C) evs)"
 | 
|  |    400 | apply (rule Guard_knows_max')
 | 
|  |    401 | apply (rule_tac H="spies evs" in Guard_mono)
 | 
|  |    402 | apply (rule req_imp_Guard, simp+)
 | 
|  |    403 | apply (rule_tac B="spies' evs" in subset_trans)
 | 
|  |    404 | apply (rule_tac p=p2 in knows_max'_sub_spies', simp+)
 | 
|  |    405 | by (rule knows'_sub_knows)
 | 
|  |    406 | 
 | 
|  |    407 | subsection{*propositions are guarded*}
 | 
|  |    408 | 
 | 
|  |    409 | lemma pro_imp_Guard [rule_format]: "[| evs:p2; B ~:bad; A ~:bad |] ==>
 | 
|  |    410 | pro B ofr A r I (cons M L) J C:set evs --> Guard ofr {priK A} (spies evs)"
 | 
|  |    411 | apply (erule p2.induct) (* +3 subgoals *)
 | 
|  |    412 | (* Nil *)
 | 
|  |    413 | apply simp
 | 
|  |    414 | (* Fake *)
 | 
|  |    415 | apply (simp add: pro_def, safe) (* +4 subgoals *)
 | 
|  |    416 | (* 1 *)
 | 
|  |    417 | apply (erule in_synth_Guard, drule Guard_analz, simp, simp)
 | 
|  |    418 | (* 2 *)
 | 
|  |    419 | apply simp
 | 
|  |    420 | (* 3 *)
 | 
|  |    421 | apply (simp, simp add: req_def pro_def, blast)
 | 
|  |    422 | (* 4 *)
 | 
|  |    423 | apply (simp add: pro_def)
 | 
|  |    424 | apply (blast dest: prom_inj Says_Nonce_not_used_guard Nonce_not_used_Guard)
 | 
|  |    425 | (* 5 *)
 | 
|  |    426 | apply simp
 | 
|  |    427 | apply safe (* +1 subgoal *)
 | 
|  |    428 | apply (simp add: pro_def)
 | 
|  |    429 | apply (blast dest: prom_inj Says_Nonce_not_used_guard)
 | 
|  |    430 | (* 6 *)
 | 
|  |    431 | apply (simp add: pro_def)
 | 
|  |    432 | apply (blast dest: Says_imp_knows_Spy)
 | 
|  |    433 | (* Request *)
 | 
|  |    434 | apply (simp add: pro_def)
 | 
|  |    435 | apply (blast dest: prom_inj Says_Nonce_not_used_guard Nonce_not_used_Guard)
 | 
|  |    436 | (* Propose *)
 | 
|  |    437 | apply simp
 | 
|  |    438 | apply safe (* +1 subgoal *)
 | 
|  |    439 | (* 1 *)
 | 
|  |    440 | apply (simp add: pro_def)
 | 
|  |    441 | apply (blast dest: prom_inj Says_Nonce_not_used_guard)
 | 
|  |    442 | (* 2 *)
 | 
|  |    443 | apply (simp add: pro_def)
 | 
|  |    444 | by (blast dest: Says_imp_knows_Spy)
 | 
|  |    445 | 
 | 
|  |    446 | lemma pro_imp_Guard_Friend: "[| evs:p2; B ~:bad; A ~:bad;
 | 
|  |    447 | pro B ofr A r I (cons M L) J C:set evs |]
 | 
|  |    448 | ==> Guard ofr {priK A} (knows_max (Friend D) evs)"
 | 
|  |    449 | apply (rule Guard_knows_max')
 | 
|  |    450 | apply (rule_tac H="spies evs" in Guard_mono)
 | 
|  |    451 | apply (rule pro_imp_Guard, simp+)
 | 
|  |    452 | apply (rule_tac B="spies' evs" in subset_trans)
 | 
|  |    453 | apply (rule_tac p=p2 in knows_max'_sub_spies', simp+)
 | 
|  |    454 | by (rule knows'_sub_knows)
 | 
|  |    455 | 
 | 
|  |    456 | subsection{*data confidentiality:
 | 
|  |    457 | no one other than the originator can decrypt the offers*}
 | 
|  |    458 | 
 | 
|  |    459 | lemma Nonce_req_notin_spies: "[| evs:p2; req A r n I B:set evs; A ~:bad |]
 | 
|  |    460 | ==> Nonce n ~:analz (spies evs)"
 | 
|  |    461 | by (frule req_imp_Guard, simp+, erule Guard_Nonce_analz, simp+)
 | 
|  |    462 | 
 | 
|  |    463 | lemma Nonce_req_notin_knows_max_Friend: "[| evs:p2; req A r n I B:set evs;
 | 
|  |    464 | A ~:bad; A ~= Friend C |] ==> Nonce n ~:analz (knows_max (Friend C) evs)"
 | 
|  |    465 | apply (clarify, frule_tac C=C in req_imp_Guard_Friend, simp+)
 | 
|  |    466 | apply (simp add: knows_max_def, drule Guard_invKey_keyset, simp+)
 | 
|  |    467 | by (drule priK_notin_knows_max_Friend, auto simp: knows_max_def)
 | 
|  |    468 | 
 | 
|  |    469 | lemma Nonce_pro_notin_spies: "[| evs:p2; B ~:bad; A ~:bad;
 | 
|  |    470 | pro B ofr A r I (cons M L) J C:set evs |] ==> Nonce ofr ~:analz (spies evs)"
 | 
|  |    471 | by (frule pro_imp_Guard, simp+, erule Guard_Nonce_analz, simp+)
 | 
|  |    472 | 
 | 
|  |    473 | lemma Nonce_pro_notin_knows_max_Friend: "[| evs:p2; B ~:bad; A ~:bad;
 | 
|  |    474 | A ~= Friend D; pro B ofr A r I (cons M L) J C:set evs |]
 | 
|  |    475 | ==> Nonce ofr ~:analz (knows_max (Friend D) evs)"
 | 
|  |    476 | apply (clarify, frule_tac A=A in pro_imp_Guard_Friend, simp+)
 | 
|  |    477 | apply (simp add: knows_max_def, drule Guard_invKey_keyset, simp+)
 | 
|  |    478 | by (drule priK_notin_knows_max_Friend, auto simp: knows_max_def)
 | 
|  |    479 | 
 | 
|  |    480 | subsection{*forward privacy:
 | 
|  |    481 | only the originator can know the identity of the shops*}
 | 
|  |    482 | 
 | 
|  |    483 | lemma forward_privacy_Spy: "[| evs:p2; B ~:bad; A ~:bad;
 | 
|  |    484 | pro B ofr A r I (cons M L) J C:set evs |]
 | 
|  |    485 | ==> sign B (Nonce ofr) ~:analz (spies evs)"
 | 
|  |    486 | by (auto simp:sign_def dest: Nonce_pro_notin_spies)
 | 
|  |    487 | 
 | 
|  |    488 | lemma forward_privacy_Friend: "[| evs:p2; B ~:bad; A ~:bad; A ~= Friend D;
 | 
|  |    489 | pro B ofr A r I (cons M L) J C:set evs |]
 | 
|  |    490 | ==> sign B (Nonce ofr) ~:analz (knows_max (Friend D) evs)"
 | 
|  |    491 | by (auto simp:sign_def dest:Nonce_pro_notin_knows_max_Friend )
 | 
|  |    492 | 
 | 
|  |    493 | subsection{*non repudiability: an offer signed by B has been sent by B*}
 | 
|  |    494 | 
 | 
|  |    495 | lemma Crypt_reqm: "[| Crypt (priK A) X:parts {reqm A' r n I B}; I:agl |] ==> A=A'"
 | 
|  |    496 | by (auto simp: reqm_def anchor_def chain_def sign_def dest: no_Crypt_in_agl)
 | 
|  |    497 | 
 | 
|  |    498 | lemma Crypt_prom: "[| Crypt (priK A) X:parts {prom B ofr A' r I L J C};
 | 
|  |    499 | I:agl; J:agl |] ==> A=B | Crypt (priK A) X:parts {L}"
 | 
|  |    500 | apply (simp add: prom_def anchor_def chain_def sign_def)
 | 
|  |    501 | by (blast dest: no_Crypt_in_agl no_Crypt_in_appdel)
 | 
|  |    502 | 
 | 
|  |    503 | lemma Crypt_safeness: "[| evs:p2; A ~:bad |] ==> Crypt (priK A) X:parts (spies evs)
 | 
|  |    504 | --> (EX B Y. Says A B Y:set evs & Crypt (priK A) X:parts {Y})"
 | 
|  |    505 | apply (erule p2.induct)
 | 
|  |    506 | (* Nil *)
 | 
|  |    507 | apply simp
 | 
|  |    508 | (* Fake *)
 | 
|  |    509 | apply clarsimp
 | 
|  |    510 | apply (drule_tac P="%G. Crypt (priK A) X:G" in parts_insert_substD, simp)
 | 
|  |    511 | apply (erule disjE)
 | 
|  |    512 | apply (drule_tac K="priK A" in Crypt_synth, simp+, blast, blast)
 | 
|  |    513 | (* Request *)
 | 
|  |    514 | apply (simp add: req_def, clarify)
 | 
|  |    515 | apply (drule_tac P="%G. Crypt (priK A) X:G" in parts_insert_substD, simp)
 | 
|  |    516 | apply (erule disjE)
 | 
|  |    517 | apply (frule Crypt_reqm, simp, clarify)
 | 
|  |    518 | apply (rule_tac x=B in exI, rule_tac x="reqm A r n I B" in exI, simp, blast)
 | 
|  |    519 | (* Propose *)
 | 
|  |    520 | apply (simp add: pro_def, clarify)
 | 
|  |    521 | apply (drule_tac P="%G. Crypt (priK A) X:G" in parts_insert_substD, simp)
 | 
|  |    522 | apply (rotate_tac -1, erule disjE)
 | 
|  |    523 | apply (frule Crypt_prom, simp, simp)
 | 
|  |    524 | apply (rotate_tac -1, erule disjE)
 | 
|  |    525 | apply (rule_tac x=C in exI)
 | 
|  |    526 | apply (rule_tac x="prom B ofr Aa r I (cons M L) J C" in exI, blast)
 | 
|  |    527 | apply (subgoal_tac "cons M L:parts (spies evsp)")
 | 
|  |    528 | apply (drule_tac G="{cons M L}" and H="spies evsp" in parts_trans, blast, blast)
 | 
|  |    529 | apply (drule Says_imp_spies, rotate_tac -1, drule parts.Inj)
 | 
|  |    530 | apply (drule parts.Snd, drule parts.Snd, drule parts.Snd)
 | 
|  |    531 | by auto
 | 
|  |    532 | 
 | 
|  |    533 | lemma Crypt_Hash_imp_sign: "[| evs:p2; A ~:bad |] ==>
 | 
|  |    534 | Crypt (priK A) (Hash X):parts (spies evs)
 | 
|  |    535 | --> (EX B Y. Says A B Y:set evs & sign A X:parts {Y})"
 | 
|  |    536 | apply (erule p2.induct)
 | 
|  |    537 | (* Nil *)
 | 
|  |    538 | apply simp
 | 
|  |    539 | (* Fake *)
 | 
|  |    540 | apply clarsimp
 | 
|  |    541 | apply (drule_tac P="%G. Crypt (priK A) (Hash X):G" in parts_insert_substD)
 | 
|  |    542 | apply simp
 | 
|  |    543 | apply (erule disjE)
 | 
|  |    544 | apply (drule_tac K="priK A" in Crypt_synth, simp+, blast, blast)
 | 
|  |    545 | (* Request *)
 | 
|  |    546 | apply (simp add: req_def, clarify)
 | 
|  |    547 | apply (drule_tac P="%G. Crypt (priK A) (Hash X):G" in parts_insert_substD)
 | 
|  |    548 | apply simp
 | 
|  |    549 | apply (erule disjE)
 | 
|  |    550 | apply (frule Crypt_reqm, simp+)
 | 
|  |    551 | apply (rule_tac x=B in exI, rule_tac x="reqm Aa r n I B" in exI)
 | 
|  |    552 | apply (simp add: reqm_def sign_def anchor_def no_Crypt_in_agl)
 | 
|  |    553 | apply (simp add: chain_def sign_def, blast)
 | 
|  |    554 | (* Propose *)
 | 
|  |    555 | apply (simp add: pro_def, clarify)
 | 
|  |    556 | apply (drule_tac P="%G. Crypt (priK A) (Hash X):G" in parts_insert_substD)
 | 
|  |    557 | apply simp
 | 
|  |    558 | apply (rotate_tac -1, erule disjE)
 | 
|  |    559 | apply (simp add: prom_def sign_def no_Crypt_in_agl no_Crypt_in_appdel)
 | 
|  |    560 | apply (simp add: chain_def sign_def)
 | 
|  |    561 | apply (rotate_tac -1, erule disjE)
 | 
|  |    562 | apply (rule_tac x=C in exI)
 | 
|  |    563 | apply (rule_tac x="prom B ofr Aa r I (cons M L) J C" in exI)
 | 
|  |    564 | apply (simp add: prom_def chain_def sign_def)
 | 
|  |    565 | apply (erule impE) 
 | 
|  |    566 | apply (blast dest: get_ML parts_sub) 
 | 
|  |    567 | apply (blast del: MPair_parts)+
 | 
|  |    568 | done
 | 
|  |    569 | 
 | 
|  |    570 | lemma sign_safeness: "[| evs:p2; A ~:bad |] ==> sign A X:parts (spies evs)
 | 
|  |    571 | --> (EX B Y. Says A B Y:set evs & sign A X:parts {Y})"
 | 
|  |    572 | apply (clarify, simp add: sign_def, frule parts.Snd)
 | 
|  |    573 | apply (blast dest: Crypt_Hash_imp_sign [unfolded sign_def])
 | 
|  |    574 | done
 | 
|  |    575 | 
 | 
|  |    576 | end |