src/HOL/Auth/Shared.thy
changeset 1934 58573e7041b4
child 1943 20574dca5a3e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/HOL/Auth/Shared.thy	Wed Aug 21 13:25:27 1996 +0200
     1.3 @@ -0,0 +1,67 @@
     1.4 +(*  Title:      HOL/Auth/Shared
     1.5 +    ID:         $Id$
     1.6 +    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
     1.7 +    Copyright   1996  University of Cambridge
     1.8 +
     1.9 +Theory of Shared Keys (common to all symmetric-key protocols)
    1.10 +
    1.11 +Server keys; initial states of agents; new nonces and keys; function "sees" 
    1.12 +*)
    1.13 +
    1.14 +Shared = Message + List + 
    1.15 +
    1.16 +consts
    1.17 +  serverKey    :: agent => key  (*symmetric keys*)
    1.18 +
    1.19 +rules
    1.20 +  isSym_serverKey "isSymKey (serverKey A)"
    1.21 +
    1.22 +consts  (*Initial states of agents -- parameter of the construction*)
    1.23 +  initState :: agent => msg set
    1.24 +
    1.25 +primrec initState agent
    1.26 +        (*Server knows all keys; other agents know only their own*)
    1.27 +  initState_Server  "initState Server     = Key `` range serverKey"
    1.28 +  initState_Friend  "initState (Friend i) = {Key (serverKey (Friend i))}"
    1.29 +  initState_Enemy   "initState Enemy  = {Key (serverKey Enemy)}"
    1.30 +
    1.31 +datatype  (*Messages, and components of agent stores*)
    1.32 +  event = Says agent agent msg
    1.33 +        | Notes agent msg
    1.34 +
    1.35 +consts  
    1.36 +  sees1 :: [agent, event] => msg set
    1.37 +
    1.38 +primrec sees1 event
    1.39 +           (*First agent recalls all that it says, but NOT everything
    1.40 +             that is sent to it; it must note such things if/when received*)
    1.41 +  sees1_Says  "sees1 A (Says A' B X)  = (if A:{A',Enemy} then {X} else {})"
    1.42 +          (*part of A's internal state*)
    1.43 +  sees1_Notes "sees1 A (Notes A' X)   = (if A=A' then {X} else {})"
    1.44 +
    1.45 +consts  
    1.46 +  sees :: [agent, event list] => msg set
    1.47 +
    1.48 +primrec sees list
    1.49 +        (*Initial knowledge includes all public keys and own private key*)
    1.50 +  sees_Nil  "sees A []       = initState A"
    1.51 +  sees_Cons "sees A (ev#evs) = sees1 A ev Un sees A evs"
    1.52 +
    1.53 +
    1.54 +(*Agents generate "random" nonces.  Different traces always yield
    1.55 +  different nonces.  Same applies for keys.*)
    1.56 +consts
    1.57 +  newN :: "event list => nat"
    1.58 +  newK :: "event list => key"
    1.59 +
    1.60 +rules
    1.61 +  inj_serverKey "inj serverKey"
    1.62 +
    1.63 +  inj_newN   "inj newN"
    1.64 +  fresh_newN "Nonce (newN evs) ~: parts (initState B)" 
    1.65 +
    1.66 +  inj_newK   "inj newK"
    1.67 +  fresh_newK "Key (newK evs) ~: parts (initState B)" 
    1.68 +  isSym_newK "isSymKey (newK evs)"
    1.69 +
    1.70 +end