src/HOL/Auth/Guard/Proto.thy
changeset 61956 38b73f7940af
parent 61830 4f5ab843cf5b
child 62343 24106dc44def
equal deleted inserted replaced
61955:e96292f32c3c 61956:38b73f7940af
    37 | "apm s (Hash X) = Hash (apm s X)"
    37 | "apm s (Hash X) = Hash (apm s X)"
    38 | "apm s (Crypt K X) = (
    38 | "apm s (Crypt K X) = (
    39 if (EX A. K = pubK A) then Crypt (pubK (agent s (agt K))) (apm s X)
    39 if (EX A. K = pubK A) then Crypt (pubK (agent s (agt K))) (apm s X)
    40 else if (EX A. K = priK A) then Crypt (priK (agent s (agt K))) (apm s X)
    40 else if (EX A. K = priK A) then Crypt (priK (agent s (agt K))) (apm s X)
    41 else Crypt (key s K) (apm s X))"
    41 else Crypt (key s K) (apm s X))"
    42 | "apm s {|X,Y|} = {|apm s X, apm s Y|}"
    42 | "apm s \<lbrace>X,Y\<rbrace> = \<lbrace>apm s X, apm s Y\<rbrace>"
    43 
    43 
    44 lemma apm_parts: "X:parts {Y} ==> apm s X:parts {apm s Y}"
    44 lemma apm_parts: "X:parts {Y} ==> apm s X:parts {apm s Y}"
    45 apply (erule parts.induct, simp_all, blast)
    45 apply (erule parts.induct, simp_all, blast)
    46 apply (erule parts.Fst)
    46 apply (erule parts.Fst)
    47 apply (erule parts.Snd)
    47 apply (erule parts.Snd)
   369 definition Na :: nat where "Na == 0"
   369 definition Na :: nat where "Na == 0"
   370 definition Nb :: nat where "Nb == 1"
   370 definition Nb :: nat where "Nb == 1"
   371 
   371 
   372 abbreviation
   372 abbreviation
   373   ns1 :: rule where
   373   ns1 :: rule where
   374   "ns1 == ({}, Says a b (Crypt (pubK b) {|Nonce Na, Agent a|}))"
   374   "ns1 == ({}, Says a b (Crypt (pubK b) \<lbrace>Nonce Na, Agent a\<rbrace>))"
   375 
   375 
   376 abbreviation
   376 abbreviation
   377   ns2 :: rule where
   377   ns2 :: rule where
   378   "ns2 == ({Says a' b (Crypt (pubK b) {|Nonce Na, Agent a|})},
   378   "ns2 == ({Says a' b (Crypt (pubK b) \<lbrace>Nonce Na, Agent a\<rbrace>)},
   379     Says b a (Crypt (pubK a) {|Nonce Na, Nonce Nb, Agent b|}))"
   379     Says b a (Crypt (pubK a) \<lbrace>Nonce Na, Nonce Nb, Agent b\<rbrace>))"
   380 
   380 
   381 abbreviation
   381 abbreviation
   382   ns3 :: rule where
   382   ns3 :: rule where
   383   "ns3 == ({Says a b (Crypt (pubK b) {|Nonce Na, Agent a|}),
   383   "ns3 == ({Says a b (Crypt (pubK b) \<lbrace>Nonce Na, Agent a\<rbrace>),
   384     Says b' a (Crypt (pubK a) {|Nonce Na, Nonce Nb, Agent b|})},
   384     Says b' a (Crypt (pubK a) \<lbrace>Nonce Na, Nonce Nb, Agent b\<rbrace>)},
   385     Says a b (Crypt (pubK b) (Nonce Nb)))"
   385     Says a b (Crypt (pubK b) (Nonce Nb)))"
   386 
   386 
   387 inductive_set ns :: proto where
   387 inductive_set ns :: proto where
   388   [iff]: "ns1:ns"
   388   [iff]: "ns1:ns"
   389 | [iff]: "ns2:ns"
   389 | [iff]: "ns2:ns"
   390 | [iff]: "ns3:ns"
   390 | [iff]: "ns3:ns"
   391 
   391 
   392 abbreviation (input)
   392 abbreviation (input)
   393   ns3a :: event where
   393   ns3a :: event where
   394   "ns3a == Says a b (Crypt (pubK b) {|Nonce Na, Agent a|})"
   394   "ns3a == Says a b (Crypt (pubK b) \<lbrace>Nonce Na, Agent a\<rbrace>)"
   395 
   395 
   396 abbreviation (input)
   396 abbreviation (input)
   397   ns3b :: event where
   397   ns3b :: event where
   398   "ns3b == Says b' a (Crypt (pubK a) {|Nonce Na, Nonce Nb, Agent b|})"
   398   "ns3b == Says b' a (Crypt (pubK a) \<lbrace>Nonce Na, Nonce Nb, Agent b\<rbrace>)"
   399 
   399 
   400 definition keys :: "keyfun" where
   400 definition keys :: "keyfun" where
   401 "keys R' s' n evs == {priK' s' a, priK' s' b}"
   401 "keys R' s' n evs == {priK' s' a, priK' s' b}"
   402 
   402 
   403 lemma "monoton ns keys"
   403 lemma "monoton ns keys"
   404 by (simp add: keys_def monoton_def)
   404 by (simp add: keys_def monoton_def)
   405 
   405 
   406 definition secret :: "secfun" where
   406 definition secret :: "secfun" where
   407 "secret R n s Ks ==
   407 "secret R n s Ks ==
   408 (if R=ns1 then apm s (Crypt (pubK b) {|Nonce Na, Agent a|})
   408 (if R=ns1 then apm s (Crypt (pubK b) \<lbrace>Nonce Na, Agent a\<rbrace>)
   409 else if R=ns2 then apm s (Crypt (pubK a) {|Nonce Na, Nonce Nb, Agent b|})
   409 else if R=ns2 then apm s (Crypt (pubK a) \<lbrace>Nonce Na, Nonce Nb, Agent b\<rbrace>)
   410 else Number 0)"
   410 else Number 0)"
   411 
   411 
   412 definition inf :: "rule => rule => bool" where
   412 definition inf :: "rule => rule => bool" where
   413 "inf R R' == (R=ns1 | (R=ns2 & R'~=ns1) | (R=ns3 & R'=ns3))"
   413 "inf R R' == (R=ns1 | (R=ns2 & R'~=ns1) | (R=ns3 & R'=ns3))"
   414 
   414