src/HOL/Auth/Guard/Guard_Yahalom.thy
author wenzelm
Sun Nov 02 18:21:45 2014 +0100 (2014-11-02)
changeset 58889 5b7a9633cfa8
parent 56073 29e308b56d23
child 61830 4f5ab843cf5b
permissions -rw-r--r--
modernized header uniformly as section;
     1 (*  Title:      HOL/Auth/Guard/Guard_Yahalom.thy
     2     Author:     Frederic Blanqui, University of Cambridge Computer Laboratory
     3     Copyright   2002  University of Cambridge
     4 *)
     5 
     6 section{*Yahalom Protocol*}
     7 
     8 theory Guard_Yahalom imports "../Shared" Guard_Shared begin
     9 
    10 subsection{*messages used in the protocol*}
    11 
    12 abbreviation (input)
    13   ya1 :: "agent => agent => nat => event" where
    14   "ya1 A B NA == Says A B {|Agent A, Nonce NA|}"
    15 
    16 abbreviation (input)
    17   ya1' :: "agent => agent => agent => nat => event" where
    18   "ya1' A' A B NA == Says A' B {|Agent A, Nonce NA|}"
    19 
    20 abbreviation (input)
    21   ya2 :: "agent => agent => nat => nat => event" where
    22   "ya2 A B NA NB == Says B Server {|Agent B, Ciph B {|Agent A, Nonce NA, Nonce NB|}|}"
    23 
    24 abbreviation (input)
    25   ya2' :: "agent => agent => agent => nat => nat => event" where
    26   "ya2' B' A B NA NB == Says B' Server {|Agent B, Ciph B {|Agent A, Nonce NA, Nonce NB|}|}"
    27 
    28 abbreviation (input)
    29   ya3 :: "agent => agent => nat => nat => key => event" where
    30   "ya3 A B NA NB K ==
    31     Says Server A {|Ciph A {|Agent B, Key K, Nonce NA, Nonce NB|},
    32                     Ciph B {|Agent A, Key K|}|}"
    33 
    34 abbreviation (input)
    35   ya3':: "agent => msg => agent => agent => nat => nat => key => event" where
    36   "ya3' S Y A B NA NB K ==
    37     Says S A {|Ciph A {|Agent B, Key K, Nonce NA, Nonce NB|}, Y|}"
    38 
    39 abbreviation (input)
    40   ya4 :: "agent => agent => nat => nat => msg => event" where
    41   "ya4 A B K NB Y == Says A B {|Y, Crypt K (Nonce NB)|}"
    42 
    43 abbreviation (input)
    44   ya4' :: "agent => agent => nat => nat => msg => event" where
    45   "ya4' A' B K NB Y == Says A' B {|Y, Crypt K (Nonce NB)|}"
    46 
    47 
    48 subsection{*definition of the protocol*}
    49 
    50 inductive_set ya :: "event list set"
    51 where
    52 
    53   Nil: "[]:ya"
    54 
    55 | Fake: "[| evs:ya; X:synth (analz (spies evs)) |] ==> Says Spy B X # evs:ya"
    56 
    57 | YA1: "[| evs1:ya; Nonce NA ~:used evs1 |] ==> ya1 A B NA # evs1:ya"
    58 
    59 | YA2: "[| evs2:ya; ya1' A' A B NA:set evs2; Nonce NB ~:used evs2 |]
    60   ==> ya2 A B NA NB # evs2:ya"
    61 
    62 | YA3: "[| evs3:ya; ya2' B' A B NA NB:set evs3; Key K ~:used evs3 |]
    63   ==> ya3 A B NA NB K # evs3:ya"
    64 
    65 | YA4: "[| evs4:ya; ya1 A B NA:set evs4; ya3' S Y A B NA NB K:set evs4 |]
    66   ==> ya4 A B K NB Y # evs4:ya"
    67 
    68 subsection{*declarations for tactics*}
    69 
    70 declare knows_Spy_partsEs [elim]
    71 declare Fake_parts_insert [THEN subsetD, dest]
    72 declare initState.simps [simp del]
    73 
    74 subsection{*general properties of ya*}
    75 
    76 lemma ya_has_no_Gets: "evs:ya ==> ALL A X. Gets A X ~:set evs"
    77 by (erule ya.induct, auto)
    78 
    79 lemma ya_is_Gets_correct [iff]: "Gets_correct ya"
    80 by (auto simp: Gets_correct_def dest: ya_has_no_Gets)
    81 
    82 lemma ya_is_one_step [iff]: "one_step ya"
    83 by (unfold one_step_def, clarify, ind_cases "ev#evs:ya" for ev evs, auto)
    84 
    85 lemma ya_has_only_Says' [rule_format]: "evs:ya ==>
    86 ev:set evs --> (EX A B X. ev=Says A B X)"
    87 by (erule ya.induct, auto)
    88 
    89 lemma ya_has_only_Says [iff]: "has_only_Says ya"
    90 by (auto simp: has_only_Says_def dest: ya_has_only_Says')
    91 
    92 lemma ya_is_regular [iff]: "regular ya"
    93 apply (simp only: regular_def, clarify)
    94 apply (erule ya.induct, simp_all add: initState.simps knows.simps)
    95 by (auto dest: parts_sub)
    96 
    97 subsection{*guardedness of KAB*}
    98 
    99 lemma Guard_KAB [rule_format]: "[| evs:ya; A ~:bad; B ~:bad |] ==>
   100 ya3 A B NA NB K:set evs --> GuardK K {shrK A,shrK B} (spies evs)" 
   101 apply (erule ya.induct)
   102 (* Nil *)
   103 apply simp_all
   104 (* Fake *)
   105 apply (clarify, erule in_synth_GuardK, erule GuardK_analz, simp)
   106 (* YA1 *)
   107 (* YA2 *)
   108 apply safe
   109 apply (blast dest: Says_imp_spies)
   110 (* YA3 *)
   111 apply blast
   112 apply (drule_tac A=Server in Key_neq, simp+, rule No_Key, simp)
   113 apply (drule_tac A=Server in Key_neq, simp+, rule No_Key, simp)
   114 (* YA4 *)
   115 apply (blast dest: Says_imp_spies in_GuardK_kparts)
   116 by blast
   117 
   118 subsection{*session keys are not symmetric keys*}
   119 
   120 lemma KAB_isnt_shrK [rule_format]: "evs:ya ==>
   121 ya3 A B NA NB K:set evs --> K ~:range shrK"
   122 by (erule ya.induct, auto)
   123 
   124 lemma ya3_shrK: "evs:ya ==> ya3 A B NA NB (shrK C) ~:set evs"
   125 by (blast dest: KAB_isnt_shrK)
   126 
   127 subsection{*ya2' implies ya1'*}
   128 
   129 lemma ya2'_parts_imp_ya1'_parts [rule_format]:
   130      "[| evs:ya; B ~:bad |] ==>
   131       Ciph B {|Agent A, Nonce NA, Nonce NB|}:parts (spies evs) -->
   132       {|Agent A, Nonce NA|}:spies evs"
   133 by (erule ya.induct, auto dest: Says_imp_spies intro: parts_parts)
   134 
   135 lemma ya2'_imp_ya1'_parts: "[| ya2' B' A B NA NB:set evs; evs:ya; B ~:bad |]
   136 ==> {|Agent A, Nonce NA|}:spies evs"
   137 by (blast dest: Says_imp_spies ya2'_parts_imp_ya1'_parts)
   138 
   139 subsection{*uniqueness of NB*}
   140 
   141 lemma NB_is_uniq_in_ya2'_parts [rule_format]: "[| evs:ya; B ~:bad; B' ~:bad |] ==>
   142 Ciph B {|Agent A, Nonce NA, Nonce NB|}:parts (spies evs) -->
   143 Ciph B' {|Agent A', Nonce NA', Nonce NB|}:parts (spies evs) -->
   144 A=A' & B=B' & NA=NA'"
   145 apply (erule ya.induct, simp_all, clarify)
   146 apply (drule Crypt_synth_insert, simp+)
   147 apply (drule Crypt_synth_insert, simp+, safe)
   148 apply (drule not_used_parts_false, simp+)+
   149 by (drule Says_not_parts, simp+)+
   150 
   151 lemma NB_is_uniq_in_ya2': "[| ya2' C A B NA NB:set evs;
   152 ya2' C' A' B' NA' NB:set evs; evs:ya; B ~:bad; B' ~:bad |]
   153 ==> A=A' & B=B' & NA=NA'"
   154 by (drule NB_is_uniq_in_ya2'_parts, auto dest: Says_imp_spies)
   155 
   156 subsection{*ya3' implies ya2'*}
   157 
   158 lemma ya3'_parts_imp_ya2'_parts [rule_format]: "[| evs:ya; A ~:bad |] ==>
   159 Ciph A {|Agent B, Key K, Nonce NA, Nonce NB|}:parts (spies evs)
   160 --> Ciph B {|Agent A, Nonce NA, Nonce NB|}:parts (spies evs)"
   161 apply (erule ya.induct, simp_all)
   162 apply (clarify, drule Crypt_synth_insert, simp+)
   163 apply (blast intro: parts_sub, blast)
   164 by (auto dest: Says_imp_spies parts_parts)
   165 
   166 lemma ya3'_parts_imp_ya2' [rule_format]: "[| evs:ya; A ~:bad |] ==>
   167 Ciph A {|Agent B, Key K, Nonce NA, Nonce NB|}:parts (spies evs)
   168 --> (EX B'. ya2' B' A B NA NB:set evs)"
   169 apply (erule ya.induct, simp_all, safe)
   170 apply (drule Crypt_synth_insert, simp+)
   171 apply (drule Crypt_synth_insert, simp+, blast)
   172 apply blast
   173 apply blast
   174 by (auto dest: Says_imp_spies2 parts_parts)
   175 
   176 lemma ya3'_imp_ya2': "[| ya3' S Y A B NA NB K:set evs; evs:ya; A ~:bad |]
   177 ==> (EX B'. ya2' B' A B NA NB:set evs)"
   178 by (drule ya3'_parts_imp_ya2', auto dest: Says_imp_spies)
   179 
   180 subsection{*ya3' implies ya3*}
   181 
   182 lemma ya3'_parts_imp_ya3 [rule_format]: "[| evs:ya; A ~:bad |] ==>
   183 Ciph A {|Agent B, Key K, Nonce NA, Nonce NB|}:parts(spies evs)
   184 --> ya3 A B NA NB K:set evs"
   185 apply (erule ya.induct, simp_all, safe)
   186 apply (drule Crypt_synth_insert, simp+)
   187 by (blast dest: Says_imp_spies2 parts_parts)
   188 
   189 lemma ya3'_imp_ya3: "[| ya3' S Y A B NA NB K:set evs; evs:ya; A ~:bad |]
   190 ==> ya3 A B NA NB K:set evs"
   191 by (blast dest: Says_imp_spies ya3'_parts_imp_ya3)
   192 
   193 subsection{*guardedness of NB*}
   194 
   195 definition ya_keys :: "agent => agent => nat => nat => event list => key set" where
   196 "ya_keys A B NA NB evs == {shrK A,shrK B} Un {K. ya3 A B NA NB K:set evs}"
   197 
   198 lemma Guard_NB [rule_format]: "[| evs:ya; A ~:bad; B ~:bad |] ==>
   199 ya2 A B NA NB:set evs --> Guard NB (ya_keys A B NA NB evs) (spies evs)"
   200 apply (erule ya.induct)
   201 (* Nil *)
   202 apply (simp_all add: ya_keys_def)
   203 (* Fake *)
   204 apply safe
   205 apply (erule in_synth_Guard, erule Guard_analz, simp, clarify)
   206 apply (frule_tac B=B in Guard_KAB, simp+)
   207 apply (drule_tac p=ya in GuardK_Key_analz, simp+)
   208 apply (blast dest: KAB_isnt_shrK, simp)
   209 (* YA1 *)
   210 apply (drule_tac n=NB in Nonce_neq, simp+, rule No_Nonce, simp)
   211 (* YA2 *)
   212 apply blast
   213 apply (drule Says_imp_spies)
   214 apply (drule_tac n=NB in Nonce_neq, simp+)
   215 apply (drule_tac n'=NAa in in_Guard_kparts_neq, simp+)
   216 apply (rule No_Nonce, simp)
   217 (* YA3 *)
   218 apply (rule Guard_extand, simp, blast)
   219 apply (case_tac "NAa=NB", clarify)
   220 apply (frule Says_imp_spies)
   221 apply (frule in_Guard_kparts_Crypt, simp+)
   222 apply (frule_tac A=A and B=B and NA=NA and NB=NB and C=Ba in ya3_shrK, simp)
   223 apply (drule ya2'_imp_ya1'_parts, simp, blast, blast)
   224 apply (case_tac "NBa=NB", clarify)
   225 apply (frule Says_imp_spies)
   226 apply (frule in_Guard_kparts_Crypt, simp+)
   227 apply (frule_tac A=A and B=B and NA=NA and NB=NB and C=Ba in ya3_shrK, simp)
   228 apply (drule NB_is_uniq_in_ya2', simp+, blast, simp+)
   229 apply (simp add: No_Nonce, blast)
   230 (* YA4 *)
   231 apply (blast dest: Says_imp_spies)
   232 apply (case_tac "NBa=NB", clarify)
   233 apply (frule_tac A=S in Says_imp_spies)
   234 apply (frule in_Guard_kparts_Crypt, simp+)
   235 apply (blast dest: Says_imp_spies)
   236 apply (case_tac "NBa=NB", clarify)
   237 apply (frule_tac A=S in Says_imp_spies)
   238 apply (frule in_Guard_kparts_Crypt, simp+, blast, simp+)
   239 apply (frule_tac A=A and B=B and NA=NA and NB=NB and C=Aa in ya3_shrK, simp)
   240 apply (frule ya3'_imp_ya2', simp+, blast, clarify)
   241 apply (frule_tac A=B' in Says_imp_spies)
   242 apply (rotate_tac -1, frule in_Guard_kparts_Crypt, simp+)
   243 apply (frule_tac A=A and B=B and NA=NA and NB=NB and C=Ba in ya3_shrK, simp)
   244 apply (drule NB_is_uniq_in_ya2', simp+, blast, clarify)
   245 apply (drule ya3'_imp_ya3, simp+)
   246 apply (simp add: Guard_Nonce)
   247 apply (simp add: No_Nonce)
   248 done
   249 
   250 end