src/HOL/Auth/Message.thy
author paulson
Wed Jul 21 15:22:11 1999 +0200 (1999-07-21)
changeset 7057 b9ddbb925939
parent 6807 6737af18317e
child 9686 87b460d72e80
permissions -rw-r--r--
tweaked proofs to handle new freeness reasoning for data c onstructors
     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 = Main +
    11 
    12 types 
    13   key = nat
    14 
    15 consts
    16   invKey :: key=>key
    17 
    18 rules
    19   invKey "invKey (invKey K) = K"
    20 
    21   (*The inverse of a symmetric key is itself;
    22     that of a public key is the private key and vice versa*)
    23 
    24 constdefs
    25   isSymKey :: key=>bool
    26   "isSymKey K == (invKey K = K)"
    27 
    28 datatype  (*We allow any number of friendly agents*)
    29   agent = Server | Friend nat | Spy
    30 
    31 datatype
    32      msg = Agent  agent	    (*Agent names*)
    33          | Number nat       (*Ordinary integers, timestamps, ...*)
    34          | Nonce  nat       (*Unguessable nonces*)
    35          | Key    key       (*Crypto keys*)
    36 	 | Hash   msg       (*Hashing*)
    37 	 | MPair  msg msg   (*Compound messages*)
    38 	 | Crypt  key msg   (*Encryption, public- or shared-key*)
    39 
    40 
    41 (*Concrete syntax: messages appear as {|A,B,NA|}, etc...*)
    42 syntax
    43   "@MTuple"      :: "['a, args] => 'a * 'b"       ("(2{|_,/ _|})")
    44 
    45 translations
    46   "{|x, y, z|}"   == "{|x, {|y, z|}|}"
    47   "{|x, y|}"      == "MPair x y"
    48 
    49 
    50 constdefs
    51   (*Message Y, paired with a MAC computed with the help of X*)
    52   HPair :: "[msg,msg]=>msg"                       ("(4Hash[_] /_)" [0, 1000])
    53     "Hash[X] Y == {| Hash{|X,Y|}, Y|}"
    54 
    55   (*Keys useful to decrypt elements of a message set*)
    56   keysFor :: msg set => key set
    57   "keysFor H == invKey `` {K. EX X. Crypt K X : H}"
    58 
    59 (** Inductive definition of all "parts" of a message.  **)
    60 
    61 consts  parts   :: msg set => msg set
    62 inductive "parts H"
    63   intrs 
    64     Inj     "X: H  ==>  X: parts H"
    65     Fst     "{|X,Y|}   : parts H ==> X : parts H"
    66     Snd     "{|X,Y|}   : parts H ==> Y : parts H"
    67     Body    "Crypt K X : parts H ==> X : parts H"
    68 
    69 
    70 (** Inductive definition of "analz" -- what can be broken down from a set of
    71     messages, including keys.  A form of downward closure.  Pairs can
    72     be taken apart; messages decrypted with known keys.  **)
    73 
    74 consts  analz   :: msg set => msg set
    75 inductive "analz H"
    76   intrs 
    77     Inj     "X: H ==> X: analz H"
    78     Fst     "{|X,Y|} : analz H ==> X : analz H"
    79     Snd     "{|X,Y|} : analz H ==> Y : analz H"
    80     Decrypt "[| Crypt K X : analz H; Key(invKey K): analz H |] ==> X : analz H"
    81 
    82 
    83 (** Inductive definition of "synth" -- what can be built up from a set of
    84     messages.  A form of upward closure.  Pairs can be built, messages
    85     encrypted with known keys.  Agent names are public domain.
    86     Numbers can be guessed, but Nonces cannot be.  **)
    87 
    88 consts  synth   :: msg set => msg set
    89 inductive "synth H"
    90   intrs 
    91     Inj     "X: H ==> X: synth H"
    92     Agent   "Agent agt : synth H"
    93     Number  "Number n  : synth H"
    94     Hash    "X: synth H ==> Hash X : synth H"
    95     MPair   "[| X: synth H;  Y: synth H |] ==> {|X,Y|} : synth H"
    96     Crypt   "[| X: synth H;  Key(K) : H |] ==> Crypt K X : synth H"
    97 
    98 end