src/HOL/Auth/Shared.thy
changeset 2032 1bbf1bdcaf56
parent 2012 1b234f1fd9c7
child 2064 5a5e508e2a2b
equal deleted inserted replaced
2031:03a843f0f447 2032:1bbf1bdcaf56
    10 
    10 
    11 Shared = Message + List + 
    11 Shared = Message + List + 
    12 
    12 
    13 consts
    13 consts
    14   shrK    :: agent => key  (*symmetric keys*)
    14   shrK    :: agent => key  (*symmetric keys*)
    15   leaked  :: nat set       (*Friendly agents whose keys have leaked to Enemy*)
       
    16 
       
    17 constdefs     (*Enemy and compromised agents*)
       
    18   bad     :: agent set     "bad == insert Enemy (Friend``leaked)"
       
    19 
    15 
    20 rules
    16 rules
    21   isSym_shrK "isSymKey (shrK A)"
    17   isSym_shrK "isSymKey (shrK A)"
    22 
    18 
    23 consts  (*Initial states of agents -- parameter of the construction*)
    19 consts  (*Initial states of agents -- parameter of the construction*)
    24   initState :: agent => msg set
    20   initState :: [agent set, agent] => msg set
    25 
    21 
    26 primrec initState agent
    22 primrec initState agent
    27         (*Server knows all keys; other agents know only their own*)
    23         (*Server knows all keys; other agents know only their own*)
    28   initState_Server  "initState Server     = Key `` range shrK"
    24   initState_Server  "initState lost Server     = Key `` range shrK"
    29   initState_Friend  "initState (Friend i) = {Key (shrK (Friend i))}"
    25   initState_Friend  "initState lost (Friend i) = {Key (shrK (Friend i))}"
    30   initState_Enemy   "initState Enemy      = Key``shrK``bad"
    26   initState_Spy   "initState lost Spy      = Key``shrK``lost"
       
    27 
    31 
    28 
    32 datatype  (*Messages, and components of agent stores*)
    29 datatype  (*Messages, and components of agent stores*)
    33   event = Says agent agent msg
    30   event = Says agent agent msg
    34 
    31 
    35 consts  
    32 consts  
    36   sees1 :: [agent, event] => msg set
    33   sees1 :: [agent, event] => msg set
    37 
    34 
    38 primrec sees1 event
    35 primrec sees1 event
    39            (*First agent recalls all that it says, but NOT everything
    36            (*First agent recalls all that it says, but NOT everything
    40              that is sent to it; it must note such things if/when received*)
    37              that is sent to it; it must note such things if/when received*)
    41   sees1_Says  "sees1 A (Says A' B X)  = (if A:{A',Enemy} then {X} else {})"
    38   sees1_Says  "sees1 A (Says A' B X)  = (if A:{A',Spy} then {X} else {})"
    42           (*part of A's internal state*)
    39           (*part of A's internal state*)
    43 
    40 
    44 consts  
    41 consts  
    45   sees :: [agent, event list] => msg set
    42   sees :: [agent set, agent, event list] => msg set
    46 
    43 
    47 primrec sees list
    44 primrec sees list
    48         (*Initial knowledge includes all public keys and own private key*)
    45         (*Initial knowledge includes all public keys and own private key*)
    49   sees_Nil  "sees A []       = initState A"
    46   sees_Nil  "sees lost A []       = initState lost A"
    50   sees_Cons "sees A (ev#evs) = sees1 A ev Un sees A evs"
    47   sees_Cons "sees lost A (ev#evs) = sees1 A ev Un sees lost A evs"
    51 
    48 
    52 
    49 
    53 (*Agents generate "random" nonces.  Different traces always yield
    50 (*Agents generate "random" nonces.  Different traces always yield
    54   different nonces.  Same applies for keys.*)
    51   different nonces.  Same applies for keys.*)
    55 consts
    52 consts
    56   newN :: "event list => nat"
    53   newN :: "event list => nat"
    57   newK :: "event list => key"
    54   newK :: "event list => key"
    58 
    55 
    59 rules
    56 rules
    60   inj_shrK "inj shrK"
    57   inj_shrK      "inj shrK"
    61 
    58 
    62   inj_newN   "inj newN"
    59   inj_newN      "inj newN"
    63   fresh_newN "Nonce (newN evs) ~: parts (initState B)" 
       
    64 
    60 
    65   inj_newK   "inj newK"
    61   inj_newK      "inj newK"
    66   fresh_newK "Key (newK evs) ~: parts (initState B)" 
    62   newK_neq_shrK "newK evs ~= shrK A" 
    67   isSym_newK "isSymKey (newK evs)"
    63   isSym_newK    "isSymKey (newK evs)"
    68 
    64 
    69 end
    65 end