src/HOL/Auth/OtwayRees.thy
author paulson
Sat Aug 17 14:55:08 2002 +0200 (2002-08-17)
changeset 13507 febb8e5d2a9d
parent 11655 923e4d0d36d5
child 13907 2bc462b99e70
permissions -rw-r--r--
tidying of Isar scripts
paulson@11251
     1
(*  Title:      HOL/Auth/OtwayRees
paulson@11251
     2
    ID:         $Id$
paulson@11251
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@11251
     4
    Copyright   1996  University of Cambridge
paulson@11251
     5
paulson@6308
     6
Inductive relation "otway" for the Otway-Rees protocol
paulson@6308
     7
extended by Gets primitive.
paulson@1941
     8
paulson@2014
     9
Version that encrypts Nonce NB
paulson@2014
    10
paulson@11251
    11
From page 244 of
paulson@11251
    12
  Burrows, Abadi and Needham.  A Logic of Authentication.
paulson@11251
    13
  Proc. Royal Soc. 426 (1989)
paulson@1941
    14
*)
paulson@1941
    15
paulson@11251
    16
theory OtwayRees = Shared:
paulson@1941
    17
paulson@6308
    18
paulson@11251
    19
consts  otway   :: "event list set"
paulson@3519
    20
inductive "otway"
paulson@11251
    21
  intros
paulson@1941
    22
         (*Initial trace is empty*)
paulson@11251
    23
   Nil:  "[] \<in> otway"
paulson@5434
    24
paulson@2032
    25
         (*The spy MAY say anything he CAN say.  We do not expect him to
paulson@1941
    26
           invent new nonces here, but he can also use NS1.  Common to
paulson@1941
    27
           all similar protocols.*)
paulson@11251
    28
   Fake: "[| evsf \<in> otway;  X \<in> synth (analz (knows Spy evsf)) |]
paulson@11251
    29
          ==> Says Spy B X  # evsf \<in> otway"
paulson@6308
    30
paulson@6308
    31
         (*A message that has been sent can be received by the
paulson@6308
    32
           intended recipient.*)
paulson@11251
    33
   Reception: "[| evsr \<in> otway;  Says A B X \<in>set evsr |]
paulson@11251
    34
               ==> Gets B X # evsr \<in> otway"
paulson@1941
    35
paulson@1941
    36
         (*Alice initiates a protocol run*)
paulson@11251
    37
   OR1:  "[| evs1 \<in> otway;  Nonce NA \<notin> used evs1 |]
paulson@11251
    38
          ==> Says A B {|Nonce NA, Agent A, Agent B,
paulson@11251
    39
                         Crypt (shrK A) {|Nonce NA, Agent A, Agent B|} |}
paulson@3659
    40
                 # evs1 : otway"
paulson@1941
    41
paulson@6333
    42
         (*Bob's response to Alice's message.  Note that NB is encrypted.*)
paulson@11251
    43
   OR2:  "[| evs2 \<in> otway;  Nonce NB \<notin> used evs2;
paulson@6308
    44
             Gets B {|Nonce NA, Agent A, Agent B, X|} : set evs2 |]
paulson@11251
    45
          ==> Says B Server
paulson@11251
    46
                  {|Nonce NA, Agent A, Agent B, X,
paulson@2451
    47
                    Crypt (shrK B)
paulson@2516
    48
                      {|Nonce NA, Nonce NB, Agent A, Agent B|}|}
paulson@3659
    49
                 # evs2 : otway"
paulson@1941
    50
paulson@1941
    51
         (*The Server receives Bob's message and checks that the three NAs
paulson@1941
    52
           match.  Then he sends a new session key to Bob with a packet for
paulson@1941
    53
           forwarding to Alice.*)
paulson@11251
    54
   OR3:  "[| evs3 \<in> otway;  Key KAB \<notin> used evs3;
paulson@11251
    55
             Gets Server
paulson@11251
    56
                  {|Nonce NA, Agent A, Agent B,
paulson@11251
    57
                    Crypt (shrK A) {|Nonce NA, Agent A, Agent B|},
paulson@2284
    58
                    Crypt (shrK B) {|Nonce NA, Nonce NB, Agent A, Agent B|}|}
paulson@3659
    59
               : set evs3 |]
paulson@11251
    60
          ==> Says Server B
paulson@11251
    61
                  {|Nonce NA,
paulson@2516
    62
                    Crypt (shrK A) {|Nonce NA, Key KAB|},
paulson@2516
    63
                    Crypt (shrK B) {|Nonce NB, Key KAB|}|}
paulson@3659
    64
                 # evs3 : otway"
paulson@1941
    65
paulson@1941
    66
         (*Bob receives the Server's (?) message and compares the Nonces with
paulson@5434
    67
	   those in the message he previously sent the Server.
paulson@11251
    68
           Need B \<noteq> Server because we allow messages to self.*)
paulson@11251
    69
   OR4:  "[| evs4 \<in> otway;  B \<noteq> Server;
paulson@11251
    70
             Says B Server {|Nonce NA, Agent A, Agent B, X',
paulson@2284
    71
                             Crypt (shrK B)
paulson@2284
    72
                                   {|Nonce NA, Nonce NB, Agent A, Agent B|}|}
paulson@3659
    73
               : set evs4;
paulson@6308
    74
             Gets B {|Nonce NA, X, Crypt (shrK B) {|Nonce NB, Key K|}|}
paulson@3659
    75
               : set evs4 |]
paulson@3659
    76
          ==> Says B A {|Nonce NA, X|} # evs4 : otway"
paulson@1941
    77
paulson@2135
    78
         (*This message models possible leaks of session keys.  The nonces
paulson@2135
    79
           identify the protocol run.*)
paulson@11251
    80
   Oops: "[| evso \<in> otway;
paulson@2284
    81
             Says Server B {|Nonce NA, X, Crypt (shrK B) {|Nonce NB, Key K|}|}
paulson@3659
    82
               : set evso |]
paulson@4537
    83
          ==> Notes Spy {|Nonce NA, Nonce NB, Key K|} # evso : otway"
paulson@1941
    84
paulson@11251
    85
paulson@11251
    86
declare Says_imp_knows_Spy [THEN analz.Inj, dest]
paulson@11251
    87
declare parts.Body  [dest]
paulson@11251
    88
declare analz_into_parts [dest]
paulson@11251
    89
declare Fake_parts_insert_in_Un  [dest]
paulson@11251
    90
paulson@11251
    91
paulson@11251
    92
(*A "possibility property": there are traces that reach the end*)
paulson@11251
    93
lemma "B \<noteq> Server
paulson@11251
    94
      ==> \<exists>K. \<exists>evs \<in> otway.
paulson@11251
    95
             Says B A {|Nonce NA, Crypt (shrK A) {|Nonce NA, Key K|}|}
paulson@11251
    96
               \<in> set evs"
paulson@11251
    97
apply (intro exI bexI)
paulson@11251
    98
apply (rule_tac [2] otway.Nil
paulson@11251
    99
                    [THEN otway.OR1, THEN otway.Reception,
paulson@11251
   100
                     THEN otway.OR2, THEN otway.Reception,
paulson@13507
   101
                     THEN otway.OR3, THEN otway.Reception, THEN otway.OR4], possibility)
paulson@11251
   102
done
paulson@11251
   103
paulson@11251
   104
lemma Gets_imp_Says [dest!]:
paulson@11251
   105
     "[| Gets B X \<in> set evs; evs \<in> otway |] ==> \<exists>A. Says A B X \<in> set evs"
paulson@11251
   106
apply (erule rev_mp)
paulson@13507
   107
apply (erule otway.induct, auto)
paulson@11251
   108
done
paulson@11251
   109
paulson@11251
   110
paulson@11251
   111
(**** Inductive proofs about otway ****)
paulson@11251
   112
paulson@11251
   113
(** For reasoning about the encrypted portion of messages **)
paulson@11251
   114
paulson@11251
   115
lemma OR2_analz_knows_Spy:
paulson@11251
   116
     "[| Gets B {|N, Agent A, Agent B, X|} \<in> set evs;  evs \<in> otway |]
paulson@11251
   117
      ==> X \<in> analz (knows Spy evs)"
paulson@11251
   118
by blast
paulson@11251
   119
paulson@11251
   120
lemma OR4_analz_knows_Spy:
paulson@11251
   121
     "[| Gets B {|N, X, Crypt (shrK B) X'|} \<in> set evs;  evs \<in> otway |]
paulson@11251
   122
      ==> X \<in> analz (knows Spy evs)"
paulson@11251
   123
by blast
paulson@11251
   124
paulson@11251
   125
(*These lemmas assist simplification by removing forwarded X-variables.
paulson@11251
   126
  We can replace them by rewriting with parts_insert2 and proving using
paulson@11251
   127
  dest: parts_cut, but the proofs become more difficult.*)
paulson@11251
   128
lemmas OR2_parts_knows_Spy =
paulson@11251
   129
    OR2_analz_knows_Spy [THEN analz_into_parts, standard]
paulson@11251
   130
paulson@11251
   131
(*There could be OR4_parts_knows_Spy and Oops_parts_knows_Spy, but for
paulson@11251
   132
  some reason proofs work without them!*)
paulson@11251
   133
paulson@11251
   134
paulson@11251
   135
(** Theorems of the form X \<notin> parts (knows Spy evs) imply that NOBODY
paulson@11251
   136
    sends messages containing X! **)
paulson@11251
   137
paulson@11251
   138
(*Spy never sees a good agent's shared key!*)
paulson@11251
   139
lemma Spy_see_shrK [simp]:
paulson@11251
   140
     "evs \<in> otway ==> (Key (shrK A) \<in> parts (knows Spy evs)) = (A \<in> bad)"
paulson@11251
   141
apply (erule otway.induct, force,
paulson@13507
   142
       drule_tac [4] OR2_parts_knows_Spy, simp_all, blast+)
paulson@11251
   143
done
paulson@11251
   144
paulson@11251
   145
lemma Spy_analz_shrK [simp]:
paulson@11251
   146
     "evs \<in> otway ==> (Key (shrK A) \<in> analz (knows Spy evs)) = (A \<in> bad)"
paulson@11251
   147
by auto
paulson@11251
   148
paulson@11251
   149
lemma Spy_see_shrK_D [dest!]:
paulson@11251
   150
     "[|Key (shrK A) \<in> parts (knows Spy evs);  evs \<in> otway|] ==> A \<in> bad"
paulson@11251
   151
by (blast dest: Spy_see_shrK)
paulson@11251
   152
paulson@11251
   153
paulson@11251
   154
(*** Proofs involving analz ***)
paulson@11251
   155
paulson@11251
   156
(*Describes the form of K and NA when the Server sends this message.  Also
paulson@11251
   157
  for Oops case.*)
paulson@11251
   158
lemma Says_Server_message_form:
paulson@11251
   159
     "[| Says Server B {|NA, X, Crypt (shrK B) {|NB, Key K|}|} \<in> set evs;
paulson@11251
   160
         evs \<in> otway |]
paulson@11251
   161
      ==> K \<notin> range shrK & (\<exists>i. NA = Nonce i) & (\<exists>j. NB = Nonce j)"
paulson@13507
   162
apply (erule rev_mp, erule otway.induct, simp_all, blast)
paulson@11251
   163
done
paulson@11251
   164
paulson@11251
   165
paulson@11251
   166
(****
paulson@11251
   167
 The following is to prove theorems of the form
paulson@11251
   168
paulson@11251
   169
  Key K \<in> analz (insert (Key KAB) (knows Spy evs)) ==>
paulson@11251
   170
  Key K \<in> analz (knows Spy evs)
paulson@11251
   171
paulson@11251
   172
 A more general formula must be proved inductively.
paulson@11251
   173
****)
paulson@11251
   174
paulson@11251
   175
paulson@11251
   176
(** Session keys are not used to encrypt other session keys **)
paulson@11251
   177
paulson@11251
   178
(*The equality makes the induction hypothesis easier to apply*)
paulson@11251
   179
lemma analz_image_freshK [rule_format]:
paulson@11251
   180
 "evs \<in> otway ==>
paulson@11251
   181
   \<forall>K KK. KK <= -(range shrK) -->
paulson@11251
   182
          (Key K \<in> analz (Key`KK Un (knows Spy evs))) =
paulson@11251
   183
          (K \<in> KK | Key K \<in> analz (knows Spy evs))"
paulson@11251
   184
apply (erule otway.induct, force)
paulson@11251
   185
apply (frule_tac [7] Says_Server_message_form)
paulson@11251
   186
apply (drule_tac [6] OR4_analz_knows_Spy)
paulson@13507
   187
apply (drule_tac [4] OR2_analz_knows_Spy, analz_freshK, spy_analz)
paulson@11251
   188
done
paulson@11251
   189
paulson@11251
   190
paulson@11251
   191
lemma analz_insert_freshK:
paulson@11251
   192
  "[| evs \<in> otway;  KAB \<notin> range shrK |] ==>
wenzelm@11655
   193
      (Key K \<in> analz (insert (Key KAB) (knows Spy evs))) =
paulson@11251
   194
      (K = KAB | Key K \<in> analz (knows Spy evs))"
paulson@11251
   195
by (simp only: analz_image_freshK analz_image_freshK_simps)
paulson@11251
   196
paulson@11251
   197
paulson@11251
   198
(*** The Key K uniquely identifies the Server's  message. **)
paulson@11251
   199
paulson@11251
   200
lemma unique_session_keys:
paulson@11251
   201
     "[| Says Server B {|NA, X, Crypt (shrK B) {|NB, K|}|}   \<in> set evs;
paulson@11251
   202
         Says Server B' {|NA',X',Crypt (shrK B') {|NB',K|}|} \<in> set evs;
paulson@11251
   203
         evs \<in> otway |] ==> X=X' & B=B' & NA=NA' & NB=NB'"
paulson@11251
   204
apply (erule rev_mp)
paulson@11251
   205
apply (erule rev_mp)
paulson@11251
   206
apply (erule otway.induct, simp_all)
paulson@11251
   207
(*Remaining cases: OR3 and OR4*)
paulson@11251
   208
apply blast+
paulson@11251
   209
done
paulson@11251
   210
paulson@11251
   211
paulson@11251
   212
(**** Authenticity properties relating to NA ****)
paulson@11251
   213
paulson@11251
   214
(*Only OR1 can have caused such a part of a message to appear.*)
paulson@11251
   215
lemma Crypt_imp_OR1 [rule_format]:
paulson@11251
   216
 "[| A \<notin> bad;  evs \<in> otway |]
paulson@11251
   217
  ==> Crypt (shrK A) {|NA, Agent A, Agent B|} \<in> parts (knows Spy evs) -->
paulson@11251
   218
      Says A B {|NA, Agent A, Agent B,
paulson@11251
   219
                 Crypt (shrK A) {|NA, Agent A, Agent B|}|}
paulson@11251
   220
        \<in> set evs"
paulson@11251
   221
apply (erule otway.induct, force,
paulson@13507
   222
       drule_tac [4] OR2_parts_knows_Spy, simp_all, blast+)
paulson@11251
   223
done
paulson@11251
   224
paulson@11251
   225
lemma Crypt_imp_OR1_Gets:
paulson@11251
   226
     "[| Gets B {|NA, Agent A, Agent B,
paulson@11251
   227
                  Crypt (shrK A) {|NA, Agent A, Agent B|}|} \<in> set evs;
paulson@11251
   228
         A \<notin> bad; evs \<in> otway |]
paulson@11251
   229
       ==> Says A B {|NA, Agent A, Agent B,
paulson@11251
   230
                      Crypt (shrK A) {|NA, Agent A, Agent B|}|}
paulson@11251
   231
             \<in> set evs"
paulson@11251
   232
by (blast dest: Crypt_imp_OR1)
paulson@11251
   233
paulson@11251
   234
paulson@11251
   235
(** The Nonce NA uniquely identifies A's message. **)
paulson@11251
   236
paulson@11251
   237
lemma unique_NA:
paulson@11251
   238
     "[| Crypt (shrK A) {|NA, Agent A, Agent B|} \<in> parts (knows Spy evs);
paulson@11251
   239
         Crypt (shrK A) {|NA, Agent A, Agent C|} \<in> parts (knows Spy evs);
paulson@11251
   240
         evs \<in> otway;  A \<notin> bad |]
paulson@11251
   241
      ==> B = C"
paulson@11251
   242
apply (erule rev_mp, erule rev_mp)
paulson@11251
   243
apply (erule otway.induct, force,
paulson@13507
   244
       drule_tac [4] OR2_parts_knows_Spy, simp_all, blast+)
paulson@11251
   245
done
paulson@11251
   246
paulson@11251
   247
paulson@11251
   248
(*It is impossible to re-use a nonce in both OR1 and OR2.  This holds because
paulson@11251
   249
  OR2 encrypts Nonce NB.  It prevents the attack that can occur in the
paulson@11251
   250
  over-simplified version of this protocol: see OtwayRees_Bad.*)
paulson@11251
   251
lemma no_nonce_OR1_OR2:
paulson@11251
   252
   "[| Crypt (shrK A) {|NA, Agent A, Agent B|} \<in> parts (knows Spy evs);
paulson@11251
   253
       A \<notin> bad;  evs \<in> otway |]
paulson@11251
   254
    ==> Crypt (shrK A) {|NA', NA, Agent A', Agent A|} \<notin> parts (knows Spy evs)"
paulson@11251
   255
apply (erule rev_mp)
paulson@11251
   256
apply (erule otway.induct, force,
paulson@13507
   257
       drule_tac [4] OR2_parts_knows_Spy, simp_all, blast+)
paulson@11251
   258
done
paulson@11251
   259
paulson@11251
   260
(*Crucial property: If the encrypted message appears, and A has used NA
paulson@11251
   261
  to start a run, then it originated with the Server!*)
paulson@11251
   262
lemma NA_Crypt_imp_Server_msg [rule_format]:
paulson@11251
   263
     "[| A \<notin> bad;  evs \<in> otway |]
paulson@11251
   264
      ==> Says A B {|NA, Agent A, Agent B,
paulson@11251
   265
                     Crypt (shrK A) {|NA, Agent A, Agent B|}|} \<in> set evs -->
paulson@11251
   266
          Crypt (shrK A) {|NA, Key K|} \<in> parts (knows Spy evs)
paulson@11251
   267
          --> (\<exists>NB. Says Server B
paulson@11251
   268
                         {|NA,
paulson@11251
   269
                           Crypt (shrK A) {|NA, Key K|},
paulson@11251
   270
                           Crypt (shrK B) {|NB, Key K|}|} \<in> set evs)"
paulson@11251
   271
apply (erule otway.induct, force,
paulson@13507
   272
       drule_tac [4] OR2_parts_knows_Spy, simp_all, blast)
paulson@11251
   273
(*OR1: it cannot be a new Nonce, contradiction.*)
paulson@11251
   274
apply blast
paulson@11251
   275
(*OR3*)
paulson@11251
   276
apply (blast dest!: no_nonce_OR1_OR2 intro: unique_NA)
paulson@11251
   277
(*OR4*)
paulson@11251
   278
apply (blast intro!: Crypt_imp_OR1)
paulson@11251
   279
done
paulson@11251
   280
paulson@11251
   281
paulson@11251
   282
(*Corollary: if A receives B's OR4 message and the nonce NA agrees
paulson@11251
   283
  then the key really did come from the Server!  CANNOT prove this of the
paulson@11251
   284
  bad form of this protocol, even though we can prove
paulson@11251
   285
  Spy_not_see_encrypted_key*)
paulson@11251
   286
lemma A_trusts_OR4:
paulson@11251
   287
     "[| Says A  B {|NA, Agent A, Agent B,
paulson@11251
   288
                     Crypt (shrK A) {|NA, Agent A, Agent B|}|} \<in> set evs;
paulson@11251
   289
         Says B' A {|NA, Crypt (shrK A) {|NA, Key K|}|} \<in> set evs;
paulson@11251
   290
     A \<notin> bad;  evs \<in> otway |]
paulson@11251
   291
  ==> \<exists>NB. Says Server B
paulson@11251
   292
               {|NA,
paulson@11251
   293
                 Crypt (shrK A) {|NA, Key K|},
paulson@11251
   294
                 Crypt (shrK B) {|NB, Key K|}|}
paulson@11251
   295
                 \<in> set evs"
paulson@11251
   296
by (blast intro!: NA_Crypt_imp_Server_msg)
paulson@11251
   297
paulson@11251
   298
paulson@11251
   299
(** Crucial secrecy property: Spy does not see the keys sent in msg OR3
paulson@11251
   300
    Does not in itself guarantee security: an attack could violate
paulson@11251
   301
    the premises, e.g. by having A=Spy **)
paulson@11251
   302
paulson@11251
   303
lemma secrecy_lemma:
paulson@11251
   304
 "[| A \<notin> bad;  B \<notin> bad;  evs \<in> otway |]
paulson@11251
   305
  ==> Says Server B
paulson@11251
   306
        {|NA, Crypt (shrK A) {|NA, Key K|},
paulson@11251
   307
          Crypt (shrK B) {|NB, Key K|}|} \<in> set evs -->
paulson@11251
   308
      Notes Spy {|NA, NB, Key K|} \<notin> set evs -->
paulson@11251
   309
      Key K \<notin> analz (knows Spy evs)"
paulson@11251
   310
apply (erule otway.induct, force)
paulson@11251
   311
apply (frule_tac [7] Says_Server_message_form)
paulson@11251
   312
apply (drule_tac [6] OR4_analz_knows_Spy)
paulson@11251
   313
apply (drule_tac [4] OR2_analz_knows_Spy)
paulson@13507
   314
apply (simp_all add: analz_insert_eq analz_insert_freshK pushes, spy_analz)  (*Fake*)
paulson@11251
   315
(*OR3, OR4, Oops*)
paulson@11251
   316
apply (blast dest: unique_session_keys)+
paulson@11251
   317
done
paulson@11251
   318
paulson@11251
   319
lemma Spy_not_see_encrypted_key:
paulson@11251
   320
     "[| Says Server B
paulson@11251
   321
          {|NA, Crypt (shrK A) {|NA, Key K|},
paulson@11251
   322
                Crypt (shrK B) {|NB, Key K|}|} \<in> set evs;
paulson@11251
   323
         Notes Spy {|NA, NB, Key K|} \<notin> set evs;
paulson@11251
   324
         A \<notin> bad;  B \<notin> bad;  evs \<in> otway |]
paulson@11251
   325
      ==> Key K \<notin> analz (knows Spy evs)"
paulson@11251
   326
by (blast dest: Says_Server_message_form secrecy_lemma)
paulson@11251
   327
paulson@11251
   328
paulson@11251
   329
(*A's guarantee.  The Oops premise quantifies over NB because A cannot know
paulson@11251
   330
  what it is.*)
paulson@11251
   331
lemma A_gets_good_key:
paulson@11251
   332
     "[| Says A  B {|NA, Agent A, Agent B,
paulson@11251
   333
                     Crypt (shrK A) {|NA, Agent A, Agent B|}|} \<in> set evs;
paulson@11251
   334
         Says B' A {|NA, Crypt (shrK A) {|NA, Key K|}|} \<in> set evs;
paulson@11251
   335
         \<forall>NB. Notes Spy {|NA, NB, Key K|} \<notin> set evs;
paulson@11251
   336
         A \<notin> bad;  B \<notin> bad;  evs \<in> otway |]
paulson@11251
   337
      ==> Key K \<notin> analz (knows Spy evs)"
paulson@11251
   338
by (blast dest!: A_trusts_OR4 Spy_not_see_encrypted_key)
paulson@11251
   339
paulson@11251
   340
paulson@11251
   341
paulson@11251
   342
(**** Authenticity properties relating to NB ****)
paulson@11251
   343
paulson@11251
   344
(*Only OR2 can have caused such a part of a message to appear.  We do not
paulson@11251
   345
  know anything about X: it does NOT have to have the right form.*)
paulson@11251
   346
lemma Crypt_imp_OR2:
paulson@11251
   347
     "[| Crypt (shrK B) {|NA, NB, Agent A, Agent B|} \<in> parts (knows Spy evs);
paulson@11251
   348
         B \<notin> bad;  evs \<in> otway |]
paulson@11251
   349
      ==> \<exists>X. Says B Server
paulson@11251
   350
                 {|NA, Agent A, Agent B, X,
paulson@11251
   351
                   Crypt (shrK B) {|NA, NB, Agent A, Agent B|}|}
paulson@11251
   352
                 \<in> set evs"
paulson@11251
   353
apply (erule rev_mp)
paulson@11251
   354
apply (erule otway.induct, force,
paulson@13507
   355
       drule_tac [4] OR2_parts_knows_Spy, simp_all, blast+)
paulson@11251
   356
done
paulson@11251
   357
paulson@11251
   358
paulson@11251
   359
(** The Nonce NB uniquely identifies B's  message. **)
paulson@11251
   360
paulson@11251
   361
lemma unique_NB:
paulson@11251
   362
     "[| Crypt (shrK B) {|NA, NB, Agent A, Agent B|} \<in> parts(knows Spy evs);
paulson@11251
   363
         Crypt (shrK B) {|NC, NB, Agent C, Agent B|} \<in> parts(knows Spy evs);
paulson@11251
   364
           evs \<in> otway;  B \<notin> bad |]
paulson@11251
   365
         ==> NC = NA & C = A"
paulson@11251
   366
apply (erule rev_mp, erule rev_mp)
paulson@11251
   367
apply (erule otway.induct, force,
paulson@11251
   368
       drule_tac [4] OR2_parts_knows_Spy, simp_all)
paulson@11251
   369
(*Fake, OR2*)
paulson@11251
   370
apply blast+
paulson@11251
   371
done
paulson@11251
   372
paulson@11251
   373
(*If the encrypted message appears, and B has used Nonce NB,
paulson@11251
   374
  then it originated with the Server!  Quite messy proof.*)
paulson@11251
   375
lemma NB_Crypt_imp_Server_msg [rule_format]:
paulson@11251
   376
 "[| B \<notin> bad;  evs \<in> otway |]
paulson@11251
   377
  ==> Crypt (shrK B) {|NB, Key K|} \<in> parts (knows Spy evs)
paulson@11251
   378
      --> (\<forall>X'. Says B Server
paulson@11251
   379
                     {|NA, Agent A, Agent B, X',
paulson@11251
   380
                       Crypt (shrK B) {|NA, NB, Agent A, Agent B|}|}
paulson@11251
   381
           \<in> set evs
paulson@11251
   382
           --> Says Server B
paulson@11251
   383
                {|NA, Crypt (shrK A) {|NA, Key K|},
paulson@11251
   384
                      Crypt (shrK B) {|NB, Key K|}|}
paulson@11251
   385
                    \<in> set evs)"
paulson@11251
   386
apply simp
paulson@11251
   387
apply (erule otway.induct, force,
paulson@13507
   388
       drule_tac [4] OR2_parts_knows_Spy, simp_all, blast)
paulson@11251
   389
(*OR1: it cannot be a new Nonce, contradiction.*)
paulson@11251
   390
(*OR2*)
paulson@11251
   391
apply blast
paulson@11251
   392
(*OR3: needs elim: MPair_parts or it takes forever!*)
paulson@11251
   393
apply (blast dest: unique_NB dest!: no_nonce_OR1_OR2)
paulson@11251
   394
(*OR4*)
paulson@11251
   395
apply (blast dest!: Crypt_imp_OR2)
paulson@11251
   396
done
paulson@11251
   397
paulson@11251
   398
paulson@11251
   399
(*Guarantee for B: if it gets a message with matching NB then the Server
paulson@11251
   400
  has sent the correct message.*)
paulson@11251
   401
lemma B_trusts_OR3:
paulson@11251
   402
     "[| Says B Server {|NA, Agent A, Agent B, X',
paulson@11251
   403
                         Crypt (shrK B) {|NA, NB, Agent A, Agent B|} |}
paulson@11251
   404
           \<in> set evs;
paulson@11251
   405
         Gets B {|NA, X, Crypt (shrK B) {|NB, Key K|}|} \<in> set evs;
paulson@11251
   406
         B \<notin> bad;  evs \<in> otway |]
paulson@11251
   407
      ==> Says Server B
paulson@11251
   408
               {|NA,
paulson@11251
   409
                 Crypt (shrK A) {|NA, Key K|},
paulson@11251
   410
                 Crypt (shrK B) {|NB, Key K|}|}
paulson@11251
   411
                 \<in> set evs"
paulson@11251
   412
by (blast intro!: NB_Crypt_imp_Server_msg)
paulson@11251
   413
paulson@11251
   414
paulson@11251
   415
(*The obvious combination of B_trusts_OR3 with Spy_not_see_encrypted_key*)
paulson@11251
   416
lemma B_gets_good_key:
paulson@11251
   417
     "[| Says B Server {|NA, Agent A, Agent B, X',
paulson@11251
   418
                         Crypt (shrK B) {|NA, NB, Agent A, Agent B|} |}
paulson@11251
   419
           \<in> set evs;
paulson@11251
   420
         Gets B {|NA, X, Crypt (shrK B) {|NB, Key K|}|} \<in> set evs;
paulson@11251
   421
         Notes Spy {|NA, NB, Key K|} \<notin> set evs;
paulson@11251
   422
         A \<notin> bad;  B \<notin> bad;  evs \<in> otway |]
paulson@11251
   423
      ==> Key K \<notin> analz (knows Spy evs)"
paulson@11251
   424
by (blast dest!: B_trusts_OR3 Spy_not_see_encrypted_key)
paulson@11251
   425
paulson@11251
   426
paulson@11251
   427
lemma OR3_imp_OR2:
paulson@11251
   428
     "[| Says Server B
paulson@11251
   429
              {|NA, Crypt (shrK A) {|NA, Key K|},
paulson@11251
   430
                Crypt (shrK B) {|NB, Key K|}|} \<in> set evs;
paulson@11251
   431
         B \<notin> bad;  evs \<in> otway |]
paulson@11251
   432
  ==> \<exists>X. Says B Server {|NA, Agent A, Agent B, X,
paulson@11251
   433
                            Crypt (shrK B) {|NA, NB, Agent A, Agent B|} |}
paulson@11251
   434
              \<in> set evs"
paulson@11251
   435
apply (erule rev_mp)
paulson@11251
   436
apply (erule otway.induct, simp_all)
paulson@11251
   437
apply (blast dest!: Crypt_imp_OR2)+
paulson@11251
   438
done
paulson@11251
   439
paulson@11251
   440
paulson@11251
   441
(*After getting and checking OR4, agent A can trust that B has been active.
paulson@11251
   442
  We could probably prove that X has the expected form, but that is not
paulson@11251
   443
  strictly necessary for authentication.*)
paulson@11251
   444
lemma A_auths_B:
paulson@11251
   445
     "[| Says B' A {|NA, Crypt (shrK A) {|NA, Key K|}|} \<in> set evs;
paulson@11251
   446
         Says A  B {|NA, Agent A, Agent B,
paulson@11251
   447
                     Crypt (shrK A) {|NA, Agent A, Agent B|}|} \<in> set evs;
paulson@11251
   448
         A \<notin> bad;  B \<notin> bad;  evs \<in> otway |]
paulson@11251
   449
  ==> \<exists>NB X. Says B Server {|NA, Agent A, Agent B, X,
paulson@11251
   450
                               Crypt (shrK B)  {|NA, NB, Agent A, Agent B|} |}
paulson@11251
   451
                 \<in> set evs"
paulson@11251
   452
by (blast dest!: A_trusts_OR4 OR3_imp_OR2)
paulson@11251
   453
paulson@1941
   454
end