src/HOL/Auth/Message.thy
author paulson
Fri Nov 29 18:03:21 1996 +0100 (1996-11-29)
changeset 2284 80ebd1a213fd
parent 2121 7e118eb32bdc
child 2373 490ffa16952e
permissions -rw-r--r--
Swapped arguments of Crypt (for clarity and because it is conventional)
paulson@1839
     1
(*  Title:      HOL/Auth/Message
paulson@1839
     2
    ID:         $Id$
paulson@1839
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@1839
     4
    Copyright   1996  University of Cambridge
paulson@1839
     5
paulson@1839
     6
Datatypes of agents and messages;
paulson@1913
     7
Inductive relations "parts", "analz" and "synth"
paulson@1839
     8
*)
paulson@1839
     9
paulson@1839
    10
Message = Arith +
paulson@1839
    11
paulson@1839
    12
(*Is there a difference between a nonce and arbitrary numerical data?
paulson@1839
    13
  Do we need a type of nonces?*)
paulson@1839
    14
paulson@1839
    15
types 
paulson@1839
    16
  key = nat
paulson@1839
    17
paulson@1839
    18
consts
paulson@1839
    19
  invKey :: key=>key
paulson@1839
    20
paulson@1839
    21
rules
paulson@1839
    22
  invKey "invKey (invKey K) = K"
paulson@1839
    23
paulson@1839
    24
  (*The inverse of a symmetric key is itself;
paulson@1839
    25
    that of a public key is the private key and vice versa*)
paulson@1839
    26
paulson@1839
    27
constdefs
paulson@1839
    28
  isSymKey :: key=>bool
paulson@1839
    29
  "isSymKey K == (invKey K = K)"
paulson@1839
    30
paulson@2284
    31
  (*We do not assume  Crypt (invKey K) (Crypt K X) = X
paulson@2284
    32
    because Crypt a is constructor!  We assume that encryption is injective,
paulson@1839
    33
    which is not true in the real world.  The alternative is to take
paulson@2284
    34
    Crypt an as uninterpreted function symbol satisfying the equation
paulson@1839
    35
    above.  This seems to require moving to ZF and regarding msg as an
paulson@1839
    36
    inductive definition instead of a datatype.*) 
paulson@1839
    37
paulson@1839
    38
datatype  (*We allow any number of friendly agents*)
paulson@2032
    39
  agent = Server | Friend nat | Spy
paulson@1839
    40
paulson@1839
    41
datatype  (*Messages are agent names, nonces, keys, pairs and encryptions*)
paulson@1839
    42
  msg = Agent agent
paulson@1839
    43
      | Nonce nat
paulson@1839
    44
      | Key   key
paulson@1839
    45
      | MPair msg msg
paulson@2284
    46
      | Crypt key msg
paulson@1839
    47
paulson@1839
    48
(*Allows messages of the form {|A,B,NA|}, etc...*)
paulson@1839
    49
syntax
paulson@1947
    50
  "@MTuple"      :: "['a, args] => 'a * 'b"            ("(2{|_,/ _|})")
paulson@1839
    51
paulson@1839
    52
translations
paulson@1839
    53
  "{|x, y, z|}"   == "{|x, {|y, z|}|}"
paulson@1839
    54
  "{|x, y|}"      == "MPair x y"
paulson@1839
    55
paulson@1839
    56
paulson@1839
    57
constdefs  (*Keys useful to decrypt elements of a message set*)
paulson@1839
    58
  keysFor :: msg set => key set
paulson@2284
    59
  "keysFor H == invKey `` {K. EX X. Crypt K X : H}"
paulson@1839
    60
paulson@1839
    61
(** Inductive definition of all "parts" of a message.  **)
paulson@1839
    62
paulson@1839
    63
consts  parts   :: msg set => msg set
paulson@1839
    64
inductive "parts H"
paulson@1839
    65
  intrs 
paulson@1839
    66
    Inj     "X: H ==> X: parts H"
paulson@1839
    67
    Fst     "{|X,Y|} : parts H ==> X : parts H"
paulson@1839
    68
    Snd     "{|X,Y|} : parts H ==> Y : parts H"
paulson@2284
    69
    Body    "Crypt K X : parts H ==> X : parts H"
paulson@1839
    70
paulson@1839
    71
paulson@1913
    72
(** Inductive definition of "analz" -- what can be broken down from a set of
paulson@1839
    73
    messages, including keys.  A form of downward closure.  Pairs can
paulson@1839
    74
    be taken apart; messages decrypted with known keys.  **)
paulson@1839
    75
paulson@1913
    76
consts  analz   :: msg set => msg set
paulson@1913
    77
inductive "analz H"
paulson@1839
    78
  intrs 
paulson@1913
    79
    Inj     "X: H ==> X: analz H"
paulson@1913
    80
    Fst     "{|X,Y|} : analz H ==> X : analz H"
paulson@1913
    81
    Snd     "{|X,Y|} : analz H ==> Y : analz H"
paulson@2284
    82
    Decrypt "[| Crypt K X : analz H; Key(invKey K): analz H |] ==> X : analz H"
paulson@1839
    83
paulson@1839
    84
paulson@1913
    85
(** Inductive definition of "synth" -- what can be built up from a set of
paulson@1839
    86
    messages.  A form of upward closure.  Pairs can be built, messages
paulson@1839
    87
    encrypted with known keys.  Agent names may be quoted.  **)
paulson@1839
    88
paulson@1913
    89
consts  synth   :: msg set => msg set
paulson@1913
    90
inductive "synth H"
paulson@1839
    91
  intrs 
paulson@1913
    92
    Inj     "X: H ==> X: synth H"
paulson@1913
    93
    Agent   "Agent agt : synth H"
paulson@1913
    94
    MPair   "[| X: synth H;  Y: synth H |] ==> {|X,Y|} : synth H"
paulson@2284
    95
    Crypt   "[| X: synth H; Key(K): H |] ==> Crypt K X : synth H"
paulson@1839
    96
paulson@1839
    97
end