src/HOL/Auth/CertifiedEmail.thy
author bulwahn
Mon, 12 Dec 2011 13:45:54 +0100
changeset 45818 53a697f5454a
parent 43584 027dc42505be
child 58889 5b7a9633cfa8
permissions -rw-r--r--
hiding constants and facts in the Quickcheck_Exhaustive and Quickcheck_Narrowing theory;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37936
1e4c5015a72e updated some headers;
wenzelm
parents: 35416
diff changeset
     1
(*  Title:      HOL/Auth/CertifiedEmail.thy
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
     2
    Author:     Giampaolo Bella, Christiano Longo and Lawrence C Paulson
13956
8fe7e12290e1 improved presentation of HOL/Auth theories
paulson
parents: 13934
diff changeset
     3
*)
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
     4
13956
8fe7e12290e1 improved presentation of HOL/Auth theories
paulson
parents: 13934
diff changeset
     5
header{*The Certified Electronic Mail Protocol by Abadi et al.*}
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
     6
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 15068
diff changeset
     7
theory CertifiedEmail imports Public begin
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
     8
20768
1d478c2d621f replaced syntax/translations by abbreviation;
wenzelm
parents: 17689
diff changeset
     9
abbreviation
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 20768
diff changeset
    10
  TTP :: agent where
20768
1d478c2d621f replaced syntax/translations by abbreviation;
wenzelm
parents: 17689
diff changeset
    11
  "TTP == Server"
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
    12
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 20768
diff changeset
    13
abbreviation
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 20768
diff changeset
    14
  RPwd :: "agent => key" where
20768
1d478c2d621f replaced syntax/translations by abbreviation;
wenzelm
parents: 17689
diff changeset
    15
  "RPwd == shrK"
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
    16
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
    17
 
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
    18
(*FIXME: the four options should be represented by pairs of 0 or 1.
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
    19
  Right now only BothAuth is modelled.*)
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
    20
consts
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
    21
  NoAuth   :: nat
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
    22
  TTPAuth  :: nat
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
    23
  SAuth    :: nat
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
    24
  BothAuth :: nat
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
    25
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
    26
text{*We formalize a fixed way of computing responses.  Could be better.*}
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 32960
diff changeset
    27
definition "response" :: "agent => agent => nat => msg" where
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
    28
   "response S R q == Hash {|Agent S, Key (shrK R), Nonce q|}"
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
    29
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
    30
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    31
inductive_set certified_mail :: "event list set"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    32
  where
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
    33
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    34
  Nil: --{*The empty trace*}
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
    35
     "[] \<in> certified_mail"
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
    36
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    37
| Fake: --{*The Spy may say anything he can say.  The sender field is correct,
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
    38
          but agents don't use that information.*}
14145
2e31b8cc8788 ZhouGollmann: new example (fair non-repudiation protocol)
paulson
parents: 13956
diff changeset
    39
      "[| evsf \<in> certified_mail; X \<in> synth(analz(spies evsf))|] 
13956
8fe7e12290e1 improved presentation of HOL/Auth theories
paulson
parents: 13934
diff changeset
    40
       ==> Says Spy B X # evsf \<in> certified_mail"
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
    41
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    42
| FakeSSL: --{*The Spy may open SSL sessions with TTP, who is the only agent
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
    43
    equipped with the necessary credentials to serve as an SSL server.*}
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 23746
diff changeset
    44
         "[| evsfssl \<in> certified_mail; X \<in> synth(analz(spies evsfssl))|]
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
    45
          ==> Notes TTP {|Agent Spy, Agent TTP, X|} # evsfssl \<in> certified_mail"
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
    46
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    47
| CM1: --{*The sender approaches the recipient.  The message is a number.*}
15068
58d216b32199 minor tweaks to go with the new version of the Accountability paper
paulson
parents: 14735
diff changeset
    48
 "[|evs1 \<in> certified_mail;
58d216b32199 minor tweaks to go with the new version of the Accountability paper
paulson
parents: 14735
diff changeset
    49
    Key K \<notin> used evs1;
58d216b32199 minor tweaks to go with the new version of the Accountability paper
paulson
parents: 14735
diff changeset
    50
    K \<in> symKeys;
58d216b32199 minor tweaks to go with the new version of the Accountability paper
paulson
parents: 14735
diff changeset
    51
    Nonce q \<notin> used evs1;
58d216b32199 minor tweaks to go with the new version of the Accountability paper
paulson
parents: 14735
diff changeset
    52
    hs = Hash{|Number cleartext, Nonce q, response S R q, Crypt K (Number m)|};
58d216b32199 minor tweaks to go with the new version of the Accountability paper
paulson
parents: 14735
diff changeset
    53
    S2TTP = Crypt(pubEK TTP) {|Agent S, Number BothAuth, Key K, Agent R, hs|}|]
58d216b32199 minor tweaks to go with the new version of the Accountability paper
paulson
parents: 14735
diff changeset
    54
  ==> Says S R {|Agent S, Agent TTP, Crypt K (Number m), Number BothAuth, 
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 23746
diff changeset
    55
                 Number cleartext, Nonce q, S2TTP|} # evs1 
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 23746
diff changeset
    56
        \<in> certified_mail"
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
    57
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    58
| CM2: --{*The recipient records @{term S2TTP} while transmitting it and her
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
    59
     password to @{term TTP} over an SSL channel.*}
15068
58d216b32199 minor tweaks to go with the new version of the Accountability paper
paulson
parents: 14735
diff changeset
    60
 "[|evs2 \<in> certified_mail;
58d216b32199 minor tweaks to go with the new version of the Accountability paper
paulson
parents: 14735
diff changeset
    61
    Gets R {|Agent S, Agent TTP, em, Number BothAuth, Number cleartext, 
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 23746
diff changeset
    62
             Nonce q, S2TTP|} \<in> set evs2;
15068
58d216b32199 minor tweaks to go with the new version of the Accountability paper
paulson
parents: 14735
diff changeset
    63
    TTP \<noteq> R;  
58d216b32199 minor tweaks to go with the new version of the Accountability paper
paulson
parents: 14735
diff changeset
    64
    hr = Hash {|Number cleartext, Nonce q, response S R q, em|} |]
58d216b32199 minor tweaks to go with the new version of the Accountability paper
paulson
parents: 14735
diff changeset
    65
  ==> 
58d216b32199 minor tweaks to go with the new version of the Accountability paper
paulson
parents: 14735
diff changeset
    66
   Notes TTP {|Agent R, Agent TTP, S2TTP, Key(RPwd R), hr|} # evs2
58d216b32199 minor tweaks to go with the new version of the Accountability paper
paulson
parents: 14735
diff changeset
    67
      \<in> certified_mail"
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
    68
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 21404
diff changeset
    69
| CM3: --{*@{term TTP} simultaneously reveals the key to the recipient and gives
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
    70
         a receipt to the sender.  The SSL channel does not authenticate 
14735
41d9efe3b5b1 removal of prime characters
paulson
parents: 14207
diff changeset
    71
         the client (@{term R}), but @{term TTP} accepts the message only 
41d9efe3b5b1 removal of prime characters
paulson
parents: 14207
diff changeset
    72
         if the given password is that of the claimed sender, @{term R}.
13922
75ae4244a596 Changes required by the certified email protocol
paulson
parents:
diff changeset
    73