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