src/HOL/Auth/OtwayRees_Bad.thy
author kleing
Tue, 13 May 2003 08:59:21 +0200
changeset 14024 213dcc39358f
parent 13507 febb8e5d2a9d
child 14200 d8598e24f8fa
permissions -rw-r--r--
HOL-Real -> HOL-Complex
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2002
ed423882c6a9 Bad version of Otway-Rees and the new attack on it
paulson
parents:
diff changeset
     1
(*  Title:      HOL/Auth/OtwayRees_Bad
ed423882c6a9 Bad version of Otway-Rees and the new attack on it
paulson
parents:
diff changeset
     2
    ID:         $Id$
ed423882c6a9 Bad version of Otway-Rees and the new attack on it
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
ed423882c6a9 Bad version of Otway-Rees and the new attack on it
paulson
parents:
diff changeset
     4
    Copyright   1996  University of Cambridge
ed423882c6a9 Bad version of Otway-Rees and the new attack on it
paulson
parents:
diff changeset
     5
ed423882c6a9 Bad version of Otway-Rees and the new attack on it
paulson
parents:
diff changeset
     6
Inductive relation "otway" for the Otway-Rees protocol.
ed423882c6a9 Bad version of Otway-Rees and the new attack on it
paulson
parents:
diff changeset
     7
ed423882c6a9 Bad version of Otway-Rees and the new attack on it
paulson
parents:
diff changeset
     8
The FAULTY version omitting encryption of Nonce NB, as suggested on page 247 of
ed423882c6a9 Bad version of Otway-Rees and the new attack on it
paulson
parents:
diff changeset
     9
  Burrows, Abadi and Needham.  A Logic of Authentication.
ed423882c6a9 Bad version of Otway-Rees and the new attack on it
paulson
parents:
diff changeset
    10
  Proc. Royal Soc. 426 (1989)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    11
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    12
This file illustrates the consequences of such errors.  We can still prove
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    13
impressive-looking properties such as Spy_not_see_encrypted_key, yet the
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    14
protocol is open to a middleperson attack.  Attempting to prove some key lemmas
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    15
indicates the possibility of this attack.
2002
ed423882c6a9 Bad version of Otway-Rees and the new attack on it
paulson
parents:
diff changeset
    16
*)
ed423882c6a9 Bad version of Otway-Rees and the new attack on it
paulson
parents:
diff changeset
    17
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    18
theory OtwayRees_Bad = Shared:
2052
d9f7f4b2613e Working again with new theory Shared
paulson
parents: 2032
diff changeset
    19
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    20
consts  otway   :: "event list set"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    21
inductive "otway"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    22
  intros
2002
ed423882c6a9 Bad version of Otway-Rees and the new attack on it
paulson
parents:
diff changeset
    23
         (*Initial trace is empty*)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    24
   Nil:  "[] \<in> otway"
2002
ed423882c6a9 Bad version of Otway-Rees and the new attack on it
paulson
parents:
diff changeset
    25
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 2002
diff changeset
    26
         (*The spy MAY say anything he CAN say.  We do not expect him to
2002
ed423882c6a9 Bad version of Otway-Rees and the new attack on it
paulson
parents:
diff changeset
    27
           invent new nonces here, but he can also use NS1.  Common to
ed423882c6a9 Bad version of Otway-Rees and the new attack on it
paulson
parents:
diff changeset
    28
           all similar protocols.*)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    29
   Fake: "[| evsf \<in> otway;  X \<in> synth (analz (knows Spy evsf)) |]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    30
          ==> Says Spy B X  # evsf \<in> otway"
2002
ed423882c6a9 Bad version of Otway-Rees and the new attack on it
paulson
parents:
diff changeset
    31
6308
76f3865a2b1d Added Bella's "Gets" model for Otway_Rees. Also affects some other theories.
paulson
parents: 5434
diff changeset
    32
         (*A message that has been sent can be received by the
76f3865a2b1d Added Bella's "Gets" model for Otway_Rees. Also affects some other theories.
paulson
parents: 5434
diff changeset
    33
           intended recipient.*)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    34
   Reception: "[| evsr \<in> otway;  Says A B X \<in>set evsr |]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    35
               ==> Gets B X # evsr \<in> otway"
6308
76f3865a2b1d Added Bella's "Gets" model for Otway_Rees. Also affects some other theories.
paulson
parents: 5434
diff changeset
    36
2002
ed423882c6a9 Bad version of Otway-Rees and the new attack on it
paulson
parents:
diff changeset
    37
         (*Alice initiates a protocol run*)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    38
   OR1:  "[| evs1 \<in> otway;  Nonce NA \<notin> used evs1 |]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    39
          ==> Says A B {|Nonce NA, Agent A, Agent B,
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    40
                         Crypt (shrK A) {|Nonce NA, Agent A, Agent B|} |}
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    41
                 # evs1 \<in> otway"
2002
ed423882c6a9 Bad version of Otway-Rees and the new attack on it
paulson
parents:
diff changeset
    42
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    43
         (*Bob's response to Alice's message.
6333
b1dec44d0018 deleted obsolete comments
paulson
parents: 6308
diff changeset
    44
           This variant of the protocol does NOT encrypt NB.*)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    45
   OR2:  "[| evs2 \<in> otway;  Nonce NB \<notin> used evs2;
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    46
             Gets B {|Nonce NA, Agent A, Agent B, X|} \<in> set evs2 |]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    47
          ==> Says B Server
2516
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2451
diff changeset
    48
                  {|Nonce NA, Agent A, Agent B, X, Nonce NB,
2284
80ebd1a213fd Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents: 2131
diff changeset
    49
                    Crypt (shrK B) {|Nonce NA, Agent A, Agent B|}|}
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    50
                 # evs2 \<in> otway"
2002
ed423882c6a9 Bad version of Otway-Rees and the new attack on it
paulson
parents:
diff changeset
    51
ed423882c6a9 Bad version of Otway-Rees and the new attack on it
paulson
parents:
diff changeset
    52
         (*The Server receives Bob's message and checks that the three NAs
ed423882c6a9 Bad version of Otway-Rees and the new attack on it
paulson
parents:
diff changeset
    53
           match.  Then he sends a new session key to Bob with a packet for
ed423882c6a9 Bad version of Otway-Rees and the new attack on it
paulson
parents:
diff changeset
    54
           forwarding to Alice.*)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    55
   OR3:  "[| evs3 \<in> otway;  Key KAB \<notin> used evs3;
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    56
             Gets Server
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    57
                  {|Nonce NA, Agent A, Agent B,
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    58
                    Crypt (shrK A) {|Nonce NA, Agent A, Agent B|},
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    59
                    Nonce NB,
2284
80ebd1a213fd Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents: 2131
diff changeset
    60
                    Crypt (shrK B) {|Nonce NA, Agent A, Agent B|}|}
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    61
               \<in> set evs3 |]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    62
          ==> Says Server B
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    63
                  {|Nonce NA,
2516
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2451
diff changeset
    64
                    Crypt (shrK A) {|Nonce NA, Key KAB|},
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2451
diff changeset
    65
                    Crypt (shrK B) {|Nonce NB, Key KAB|}|}
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    66
                 # evs3 \<in> otway"
2002
ed423882c6a9 Bad version of Otway-Rees and the new attack on it
paulson
parents:
diff changeset
    67
ed423882c6a9 Bad version of Otway-Rees and the new attack on it
paulson
parents:
diff changeset
    68
         (*Bob receives the Server's (?) message and compares the Nonces with
5434
9b4bed3f394c Got rid of not_Says_to_self and most uses of ~= in definitions and theorems
paulson
parents: 5359
diff changeset
    69
	   those in the message he previously sent the Server.
9b4bed3f394c Got rid of not_Says_to_self and most uses of ~= in definitions and theorems
paulson
parents: 5359
diff changeset
    70
           Need B ~= Server because we allow messages to self.*)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    71
   OR4:  "[| evs4 \<in> otway;  B ~= Server;
4522
0218c486cf07 Restored the ciphertext in OR4 in order to make the spec closer to that in
paulson
parents: 3683
diff changeset
    72
             Says B Server {|Nonce NA, Agent A, Agent B, X', Nonce NB,
0218c486cf07 Restored the ciphertext in OR4 in order to make the spec closer to that in
paulson
parents: 3683
diff changeset
    73
                             Crypt (shrK B) {|Nonce NA, Agent A, Agent B|}|}
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    74
               \<in> set evs4;
6308
76f3865a2b1d Added Bella's "Gets" model for Otway_Rees. Also affects some other theories.
paulson
parents: 5434
diff changeset
    75
             Gets B {|Nonce NA, X, Crypt (shrK B) {|Nonce NB, Key K|}|}
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    76
               \<in> set evs4 |]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    77
          ==> Says B A {|Nonce NA, X|} # evs4 \<in> otway"
2002
ed423882c6a9 Bad version of Otway-Rees and the new attack on it
paulson
parents:
diff changeset
    78
2131
3106a99d30a5 Changing from the Reveal to the Oops rule
paulson
parents: 2108
diff changeset
    79
         (*This message models possible leaks of session keys.  The nonces
3106a99d30a5 Changing from the Reveal to the Oops rule
paulson
parents: 2108
diff changeset
    80
           identify the protocol run.*)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    81
   Oops: "[| evso \<in> otway;
2284
80ebd1a213fd Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents: 2131
diff changeset
    82
             Says Server B {|Nonce NA, X, Crypt (shrK B) {|Nonce NB, Key K|}|}
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    83
               \<in> set evso |]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    84
          ==> Notes Spy {|Nonce NA, Nonce NB, Key K|} # evso \<in> otway"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    85
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    86
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    87
declare Says_imp_knows_Spy [THEN analz.Inj, dest]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    88
declare parts.Body  [dest]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    89
declare analz_into_parts [dest]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    90
declare Fake_parts_insert_in_Un  [dest]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    91
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    92
(*A "possibility property": there are traces that reach the end*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    93
lemma "B \<noteq> Server
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    94
      ==> \<exists>K. \<exists>NA. \<exists>evs \<in> otway.
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    95
            Says B A {|Nonce NA, Crypt (shrK A) {|Nonce NA, Key K|}|}
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    96
              \<in> set evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    97
apply (intro exI bexI)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    98
apply (rule_tac [2] otway.Nil
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    99
                    [THEN otway.OR1, THEN otway.Reception,
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   100
                     THEN otway.OR2, THEN otway.Reception,
13507
febb8e5d2a9d tidying of Isar scripts
paulson
parents: 11655
diff changeset
   101
                     THEN otway.OR3, THEN otway.Reception, THEN otway.OR4], possibility)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   102
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   103
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   104
lemma Gets_imp_Says [dest!]:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   105
     "[| Gets B X \<in> set evs; evs \<in> otway |] ==> \<exists>A. Says A B X \<in> set evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   106
apply (erule rev_mp)
13507
febb8e5d2a9d tidying of Isar scripts
paulson
parents: 11655
diff changeset
   107
apply (erule otway.induct, auto)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   108
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   109
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   110
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   111
(**** Inductive proofs about otway ****)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   112
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   113
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   114
(** For reasoning about the encrypted portion of messages **)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   115
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   116
lemma OR2_analz_knows_Spy:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   117
     "[| Gets B {|N, Agent A, Agent B, X|} \<in> set evs;  evs \<in> otway |]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   118
      ==> X \<in> analz (knows Spy evs)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   119
by blast
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   120
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   121
lemma OR4_analz_knows_Spy:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   122
     "[| Gets B {|N, X, Crypt (shrK B) X'|} \<in> set evs;  evs \<in> otway |]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   123
      ==> X \<in> analz (knows Spy evs)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   124
by blast
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   125
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   126
lemma Oops_parts_knows_Spy:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   127
     "Says Server B {|NA, X, Crypt K' {|NB,K|}|} \<in> set evs
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   128
      ==> K \<in> parts (knows Spy evs)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   129
by blast
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   130
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   131
(*Forwarding lemma: see comments in OtwayRees.thy*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   132
lemmas OR2_parts_knows_Spy =
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   133
    OR2_analz_knows_Spy [THEN analz_into_parts, standard]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   134
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   135
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   136
(** Theorems of the form X \<notin> parts (knows Spy evs) imply that NOBODY
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   137
    sends messages containing X! **)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   138
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   139
(*Spy never sees a good agent's shared key!*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   140
lemma Spy_see_shrK [simp]:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   141
     "evs \<in> otway ==> (Key (shrK A) \<in> parts (knows Spy evs)) = (A \<in> bad)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   142
apply (erule otway.induct, force,
13507
febb8e5d2a9d tidying of Isar scripts
paulson
parents: 11655
diff changeset
   143
       drule_tac [4] OR2_parts_knows_Spy, simp_all, blast+)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   144
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   145
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   146
lemma Spy_analz_shrK [simp]:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   147
     "evs \<in> otway ==> (Key (shrK A) \<in> analz (knows Spy evs)) = (A \<in> bad)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   148
by auto
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   149
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   150
lemma Spy_see_shrK_D [dest!]:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   151
     "[|Key (shrK A) \<in> parts (knows Spy evs);  evs \<in> otway|] ==> A \<in> bad"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   152
by (blast dest: Spy_see_shrK)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   153
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   154
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   155
(*** Proofs involving analz ***)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   156
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   157
(*Describes the form of K and NA when the Server sends this message.  Also
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   158
  for Oops case.*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   159
lemma Says_Server_message_form:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   160
     "[| Says Server B {|NA, X, Crypt (shrK B) {|NB, Key K|}|} \<in> set evs;
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   161
         evs \<in> otway |]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   162
      ==> K \<notin> range shrK & (\<exists>i. NA = Nonce i) & (\<exists>j. NB = Nonce j)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   163
apply (erule rev_mp)
13507
febb8e5d2a9d tidying of Isar scripts
paulson
parents: 11655
diff changeset
   164
apply (erule otway.induct, simp_all, blast)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   165
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   166
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   167
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   168
(****
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   169
 The following is to prove theorems of the form
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   170
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   171
  Key K \<in> analz (insert (Key KAB) (knows Spy evs)) ==>
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   172
  Key K \<in> analz (knows Spy evs)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   173
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   174
 A more general formula must be proved inductively.
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   175
****)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   176
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   177
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   178
(** Session keys are not used to encrypt other session keys **)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   179
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   180
(*The equality makes the induction hypothesis easier to apply*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   181
lemma analz_image_freshK [rule_format]:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   182
 "evs \<in> otway ==>
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   183
   \<forall>K KK. KK <= -(range shrK) -->
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   184
          (Key K \<in> analz (Key`KK Un (knows Spy evs))) =
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   185
          (K \<in> KK | Key K \<in> analz (knows Spy evs))"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   186
apply (erule otway.induct, force)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   187
apply (frule_tac [7] Says_Server_message_form)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   188
apply (drule_tac [6] OR4_analz_knows_Spy)
13507
febb8e5d2a9d tidying of Isar scripts
paulson
parents: 11655
diff changeset
   189
apply (drule_tac [4] OR2_analz_knows_Spy, analz_freshK, spy_analz)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   190
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   191
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   192
lemma analz_insert_freshK:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   193
  "[| evs \<in> otway;  KAB \<notin> range shrK |] ==>
11655
923e4d0d36d5 tuned parentheses in relational expressions;
wenzelm
parents: 11251
diff changeset
   194
      (Key K \<in> analz (insert (Key KAB) (knows Spy evs))) =
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   195
      (K = KAB | Key K \<in> analz (knows Spy evs))"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   196
by (simp only: analz_image_freshK analz_image_freshK_simps)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   197
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   198
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   199
(*** The Key K uniquely identifies the Server's  message. **)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   200
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   201
lemma unique_session_keys:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   202
     "[| Says Server B {|NA, X, Crypt (shrK B) {|NB, K|}|}   \<in> set evs;
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   203
         Says Server B' {|NA',X',Crypt (shrK B') {|NB',K|}|} \<in> set evs;
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   204
         evs \<in> otway |] ==> X=X' & B=B' & NA=NA' & NB=NB'"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   205
apply (erule rev_mp)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   206
apply (erule rev_mp)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   207
apply (erule otway.induct, simp_all)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   208
(*Remaining cases: OR3 and OR4*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   209
apply blast+
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   210
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   211
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   212
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   213
(** Crucial secrecy property: Spy does not see the keys sent in msg OR3
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   214
    Does not in itself guarantee security: an attack could violate
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   215
    the premises, e.g. by having A=Spy **)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   216
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   217
lemma secrecy_lemma:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   218
 "[| A \<notin> bad;  B \<notin> bad;  evs \<in> otway |]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   219
  ==> Says Server B
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   220
        {|NA, Crypt (shrK A) {|NA, Key K|},
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   221
          Crypt (shrK B) {|NB, Key K|}|} \<in> set evs -->
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   222
      Notes Spy {|NA, NB, Key K|} \<notin> set evs -->
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   223
      Key K \<notin> analz (knows Spy evs)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   224
apply (erule otway.induct, force)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   225
apply (frule_tac [7] Says_Server_message_form)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   226
apply (drule_tac [6] OR4_analz_knows_Spy)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   227
apply (drule_tac [4] OR2_analz_knows_Spy)
13507
febb8e5d2a9d tidying of Isar scripts
paulson
parents: 11655
diff changeset
   228
apply (simp_all add: analz_insert_eq analz_insert_freshK pushes, spy_analz)  (*Fake*)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   229
(*OR3, OR4, Oops*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   230
apply (blast dest: unique_session_keys)+
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   231
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   232
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   233
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   234
lemma Spy_not_see_encrypted_key:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   235
     "[| Says Server B
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   236
          {|NA, Crypt (shrK A) {|NA, Key K|},
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   237
                Crypt (shrK B) {|NB, Key K|}|} \<in> set evs;
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   238
         Notes Spy {|NA, NB, Key K|} \<notin> set evs;
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   239
         A \<notin> bad;  B \<notin> bad;  evs \<in> otway |]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   240
      ==> Key K \<notin> analz (knows Spy evs)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   241
by (blast dest: Says_Server_message_form secrecy_lemma)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   242
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   243
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   244
(*** Attempting to prove stronger properties ***)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   245
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   246
(*Only OR1 can have caused such a part of a message to appear.
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   247
  The premise A \<noteq> B prevents OR2's similar-looking cryptogram from being
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   248
  picked up.  Original Otway-Rees doesn't need it.*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   249
lemma Crypt_imp_OR1 [rule_format]:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   250
     "[| A \<notin> bad;  A \<noteq> B;  evs \<in> otway |]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   251
      ==> Crypt (shrK A) {|NA, Agent A, Agent B|} \<in> parts (knows Spy evs) -->
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   252
          Says A B {|NA, Agent A, Agent B,
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   253
                     Crypt (shrK A) {|NA, Agent A, Agent B|}|}  \<in> set evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   254
apply (erule otway.induct, force,
13507
febb8e5d2a9d tidying of Isar scripts
paulson
parents: 11655
diff changeset
   255
       drule_tac [4] OR2_parts_knows_Spy, simp_all, blast+)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   256
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   257
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   258
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   259
(*Crucial property: If the encrypted message appears, and A has used NA
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   260
  to start a run, then it originated with the Server!
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   261
  The premise A \<noteq> B allows use of Crypt_imp_OR1*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   262
(*Only it is FALSE.  Somebody could make a fake message to Server
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   263
          substituting some other nonce NA' for NB.*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   264
lemma "[| A \<notin> bad;  A \<noteq> B;  evs \<in> otway |]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   265
       ==> Crypt (shrK A) {|NA, Key K|} \<in> parts (knows Spy evs) -->
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   266
           Says A B {|NA, Agent A, Agent B,
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   267
                      Crypt (shrK A) {|NA, Agent A, Agent B|}|}
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   268
            \<in> set evs -->
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   269
           (\<exists>B NB. Says Server B
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   270
                {|NA,
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   271
                  Crypt (shrK A) {|NA, Key K|},
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   272
                  Crypt (shrK B) {|NB, Key K|}|}  \<in> set evs)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   273
apply (erule otway.induct, force,
13507
febb8e5d2a9d tidying of Isar scripts
paulson
parents: 11655
diff changeset
   274
       drule_tac [4] OR2_parts_knows_Spy, simp_all)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   275
(*Fake*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   276
apply blast
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   277
(*OR1: it cannot be a new Nonce, contradiction.*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   278
apply blast
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   279
(*OR3 and OR4*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   280
apply (simp_all add: ex_disj_distrib)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   281
(*OR4*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   282
prefer 2 apply (blast intro!: Crypt_imp_OR1)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   283
(*OR3*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   284
apply clarify
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   285
(*The hypotheses at this point suggest an attack in which nonce NB is used
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   286
  in two different roles:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   287
          Gets Server
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   288
           {|Nonce NA, Agent Aa, Agent A,
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   289
             Crypt (shrK Aa) {|Nonce NA, Agent Aa, Agent A|}, Nonce NB,
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   290
             Crypt (shrK A) {|Nonce NA, Agent Aa, Agent A|}|}
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   291
          \<in> set evs3
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   292
          Says A B
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   293
           {|Nonce NB, Agent A, Agent B,
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   294
             Crypt (shrK A) {|Nonce NB, Agent A, Agent B|}|}
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   295
          \<in> set evs3;
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   296
*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   297
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   298
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   299
(*Thus the key property A_can_trust probably fails too.*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   300
oops
2002
ed423882c6a9 Bad version of Otway-Rees and the new attack on it
paulson
parents:
diff changeset
   301
ed423882c6a9 Bad version of Otway-Rees and the new attack on it
paulson
parents:
diff changeset
   302
end