src/HOL/Auth/Message.thy
author paulson
Fri Sep 19 18:27:31 1997 +0200 (1997-09-19)
changeset 3686 4b484805b4c4
parent 3668 a39baf59ea47
child 5102 8c782c25a11e
permissions -rw-r--r--
First working version with Oops event for session keys
     1 (*  Title:      HOL/Auth/Message
     2     ID:         $Id$
     3     Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
     4     Copyright   1996  University of Cambridge
     5 
     6 Datatypes of agents and messages;
     7 Inductive relations "parts", "analz" and "synth"
     8 *)
     9 
    10 Message = Arith +
    11 
    12 (*Is there a difference between a nonce and arbitrary numerical data?
    13   Do we need a type of nonces?*)
    14 
    15 types 
    16   key = nat
    17 
    18 consts
    19   invKey :: key=>key
    20 
    21 rules
    22   invKey "invKey (invKey K) = K"
    23 
    24   (*The inverse of a symmetric key is itself;
    25     that of a public key is the private key and vice versa*)
    26 
    27 constdefs
    28   isSymKey :: key=>bool
    29   "isSymKey K == (invKey K = K)"
    30 
    31 datatype  (*We allow any number of friendly agents*)
    32   agent = Server | Friend nat | Spy
    33 
    34 datatype  
    35   atomic = AGENT  agent	(*Agent names*)
    36          | NUMBER nat   (*Ordinary integers, timestamps, ...*)
    37          | NONCE  nat   (*Unguessable nonces*)
    38          | KEY    key   (*Crypto keys*)
    39 
    40 datatype
    41   msg = Atomic atomic
    42       | Hash   msg       (*Hashing*)
    43       | MPair  msg msg   (*Compound messages*)
    44       | Crypt  key msg   (*Encryption, public- or shared-key*)
    45 
    46 (*Allows messages of the form {|A,B,NA|}, etc...*)
    47 syntax
    48   Agent          :: agent => msg
    49   Number         :: nat   => msg
    50   Nonce          :: nat   => msg
    51   Key            :: key   => msg
    52   "@MTuple"      :: "['a, args] => 'a * 'b"       ("(2{|_,/ _|})")
    53 
    54 translations
    55   "Agent x"       == "Atomic (AGENT x)"
    56   "Number x"	  == "Atomic (NUMBER x)"
    57   "Nonce x"	  == "Atomic (NONCE x)"
    58   "Key x"	  == "Atomic (KEY x)"
    59   "Key``x"	  == "Atomic `` (KEY `` x)"
    60 
    61   "{|x, y, z|}"   == "{|x, {|y, z|}|}"
    62   "{|x, y|}"      == "MPair x y"
    63 
    64 
    65 constdefs
    66   (*Message Y, paired with a MAC computed with the help of X*)
    67   HPair :: "[msg,msg]=>msg"                       ("(4Hash[_] /_)" [0, 1000])
    68     "Hash[X] Y == {| Hash{|X,Y|}, Y|}"
    69 
    70   (*Keys useful to decrypt elements of a message set*)
    71   keysFor :: msg set => key set
    72   "keysFor H == invKey `` {K. EX X. Crypt K X : H}"
    73 
    74 (** Inductive definition of all "parts" of a message.  **)
    75 
    76 consts  parts   :: msg set => msg set
    77 inductive "parts H"
    78   intrs 
    79     Inj     "X: H  ==>  X: parts H"
    80     Fst     "{|X,Y|}   : parts H ==> X : parts H"
    81     Snd     "{|X,Y|}   : parts H ==> Y : parts H"
    82     Body    "Crypt K X : parts H ==> X : parts H"
    83 
    84 
    85 (** Inductive definition of "analz" -- what can be broken down from a set of
    86     messages, including keys.  A form of downward closure.  Pairs can
    87     be taken apart; messages decrypted with known keys.  **)
    88 
    89 consts  analz   :: msg set => msg set
    90 inductive "analz H"
    91   intrs 
    92     Inj     "X: H ==> X: analz H"
    93     Fst     "{|X,Y|} : analz H ==> X : analz H"
    94     Snd     "{|X,Y|} : analz H ==> Y : analz H"
    95     Decrypt "[| Crypt K X : analz H; Key(invKey K): analz H |] ==> X : analz H"
    96 
    97 
    98 (** Inductive definition of "synth" -- what can be built up from a set of
    99     messages.  A form of upward closure.  Pairs can be built, messages
   100     encrypted with known keys.  Agent names are public domain.
   101     Numbers can be guessed, but Nonces cannot be.  **)
   102 
   103 consts  synth   :: msg set => msg set
   104 inductive "synth H"
   105   intrs 
   106     Inj     "X: H ==> X: synth H"
   107     Agent   "Agent agt : synth H"
   108     Number  "Number n  : synth H"
   109     Hash    "X: synth H ==> Hash X : synth H"
   110     MPair   "[| X: synth H;  Y: synth H |] ==> {|X,Y|} : synth H"
   111     Crypt   "[| X: synth H;  Key(K) : H |] ==> Crypt K X : synth H"
   112 
   113 end