src/HOL/Auth/OtwayRees.ML
author paulson
Tue Nov 11 11:16:18 1997 +0100 (1997-11-11)
changeset 4198 c63639beeff1
parent 4091 771b1f6422a8
child 4422 21238c9d363e
permissions -rw-r--r--
Fixed spelling error
paulson@1941
     1
(*  Title:      HOL/Auth/OtwayRees
paulson@1941
     2
    ID:         $Id$
paulson@1941
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@1941
     4
    Copyright   1996  University of Cambridge
paulson@1941
     5
paulson@1941
     6
Inductive relation "otway" for the Otway-Rees protocol.
paulson@1941
     7
paulson@2014
     8
Version that encrypts Nonce NB
paulson@2014
     9
paulson@1941
    10
From page 244 of
paulson@1941
    11
  Burrows, Abadi and Needham.  A Logic of Authentication.
paulson@1941
    12
  Proc. Royal Soc. 426 (1989)
paulson@1941
    13
*)
paulson@1941
    14
paulson@1941
    15
open OtwayRees;
paulson@1941
    16
paulson@1941
    17
proof_timing:=true;
paulson@1941
    18
HOL_quantifiers := false;
paulson@1941
    19
paulson@1996
    20
paulson@2328
    21
(*A "possibility property": there are traces that reach the end*)
paulson@1996
    22
goal thy 
paulson@1996
    23
 "!!A B. [| A ~= B; A ~= Server; B ~= Server |]   \
paulson@3519
    24
\        ==> EX K. EX NA. EX evs: otway.          \
paulson@2284
    25
\               Says B A {|Nonce NA, Crypt (shrK A) {|Nonce NA, Key K|}|} \
nipkow@3465
    26
\                 : set evs";
paulson@1996
    27
by (REPEAT (resolve_tac [exI,bexI] 1));
paulson@2032
    28
by (rtac (otway.Nil RS otway.OR1 RS otway.OR2 RS otway.OR3 RS otway.OR4) 2);
paulson@2516
    29
by possibility_tac;
paulson@2014
    30
result();
paulson@1996
    31
paulson@1996
    32
paulson@1941
    33
(**** Inductive proofs about otway ****)
paulson@1941
    34
paulson@1941
    35
(*Nobody sends themselves messages*)
paulson@3519
    36
goal thy "!!evs. evs : otway ==> ALL A X. Says A A X ~: set evs";
paulson@2032
    37
by (etac otway.induct 1);
paulson@1941
    38
by (Auto_tac());
paulson@1941
    39
qed_spec_mp "not_Says_to_self";
paulson@1941
    40
Addsimps [not_Says_to_self];
paulson@1941
    41
AddSEs   [not_Says_to_self RSN (2, rev_notE)];
paulson@1941
    42
paulson@1941
    43
paulson@1941
    44
(** For reasoning about the encrypted portion of messages **)
paulson@1941
    45
nipkow@3465
    46
goal thy "!!evs. Says A' B {|N, Agent A, Agent B, X|} : set evs \
paulson@3683
    47
\                ==> X : analz (spies evs)";
wenzelm@4091
    48
by (blast_tac (claset() addSDs [Says_imp_spies RS analz.Inj]) 1);
paulson@3683
    49
qed "OR2_analz_spies";
paulson@1941
    50
nipkow@3465
    51
goal thy "!!evs. Says S' B {|N, X, Crypt (shrK B) X'|} : set evs \
paulson@3683
    52
\                ==> X : analz (spies evs)";
wenzelm@4091
    53
by (blast_tac (claset() addSDs [Says_imp_spies RS analz.Inj]) 1);
paulson@3683
    54
qed "OR4_analz_spies";
paulson@1941
    55
nipkow@3465
    56
goal thy "!!evs. Says Server B {|NA, X, Crypt K' {|NB,K|}|} : set evs \
paulson@3683
    57
\                 ==> K : parts (spies evs)";
wenzelm@4091
    58
by (blast_tac (claset() addSEs spies_partsEs) 1);
paulson@3683
    59
qed "Oops_parts_spies";
paulson@1941
    60
paulson@1941
    61
(*OR2_analz... and OR4_analz... let us treat those cases using the same 
paulson@1964
    62
  argument as for the Fake case.  This is possible for most, but not all,
paulson@1964
    63
  proofs: Fake does not invent new nonces (as in OR2), and of course Fake
paulson@2032
    64
  messages originate from the Spy. *)
paulson@1964
    65
paulson@3683
    66
bind_thm ("OR2_parts_spies",
paulson@3683
    67
          OR2_analz_spies RS (impOfSubs analz_subset_parts));
paulson@3683
    68
bind_thm ("OR4_parts_spies",
paulson@3683
    69
          OR4_analz_spies RS (impOfSubs analz_subset_parts));
paulson@2032
    70
paulson@3683
    71
(*For proving the easier theorems about X ~: parts (spies evs).*)
paulson@3519
    72
fun parts_induct_tac i = 
paulson@3519
    73
    etac otway.induct i			THEN 
paulson@3683
    74
    forward_tac [Oops_parts_spies] (i+6) THEN
paulson@3683
    75
    forward_tac [OR4_parts_spies]  (i+5) THEN
paulson@3683
    76
    forward_tac [OR2_parts_spies]  (i+3) THEN 
paulson@3519
    77
    prove_simple_subgoals_tac  i;
paulson@1941
    78
paulson@1941
    79
paulson@3683
    80
(** Theorems of the form X ~: parts (spies evs) imply that NOBODY
paulson@2014
    81
    sends messages containing X! **)
paulson@1941
    82
paulson@3121
    83
paulson@3683
    84
(*Spy never sees another agent's shared key! (unless it's bad at start)*)
paulson@1941
    85
goal thy 
paulson@3683
    86
 "!!evs. evs : otway ==> (Key (shrK A) : parts (spies evs)) = (A : bad)";
paulson@3519
    87
by (parts_induct_tac 1);
paulson@3121
    88
by (Fake_parts_insert_tac 1);
paulson@3961
    89
by (ALLGOALS Blast_tac);
paulson@2135
    90
qed "Spy_see_shrK";
paulson@2135
    91
Addsimps [Spy_see_shrK];
paulson@1941
    92
paulson@2135
    93
goal thy 
paulson@3683
    94
 "!!evs. evs : otway ==> (Key (shrK A) : analz (spies evs)) = (A : bad)";
wenzelm@4091
    95
by (auto_tac(claset() addDs [impOfSubs analz_subset_parts], simpset()));
paulson@2135
    96
qed "Spy_analz_shrK";
paulson@2135
    97
Addsimps [Spy_analz_shrK];
paulson@1941
    98
paulson@3683
    99
goal thy  "!!A. [| Key (shrK A) : parts (spies evs); evs : otway |] ==> A:bad";
wenzelm@4091
   100
by (blast_tac (claset() addDs [Spy_see_shrK]) 1);
paulson@2135
   101
qed "Spy_see_shrK_D";
paulson@1941
   102
paulson@2135
   103
bind_thm ("Spy_analz_shrK_D", analz_subset_parts RS subsetD RS Spy_see_shrK_D);
paulson@2135
   104
AddSDs [Spy_see_shrK_D, Spy_analz_shrK_D];
paulson@1941
   105
paulson@1941
   106
paulson@2516
   107
(*Nobody can have used non-existent keys!*)
paulson@3519
   108
goal thy "!!evs. evs : otway ==>          \
paulson@3683
   109
\         Key K ~: used evs --> K ~: keysFor (parts (spies evs))";
paulson@3519
   110
by (parts_induct_tac 1);
paulson@2516
   111
(*Fake*)
paulson@2516
   112
by (best_tac
wenzelm@4091
   113
      (claset() addSDs [impOfSubs (parts_insert_subset_Un RS keysFor_mono)]
paulson@3961
   114
               addIs  [impOfSubs analz_subset_parts]
paulson@3961
   115
               addDs  [impOfSubs (analz_subset_parts RS keysFor_mono)]
wenzelm@4091
   116
               addss  (simpset())) 1);
paulson@3102
   117
by (ALLGOALS Blast_tac);
paulson@2160
   118
qed_spec_mp "new_keys_not_used";
paulson@1941
   119
paulson@1941
   120
bind_thm ("new_keys_not_analzd",
paulson@2032
   121
          [analz_subset_parts RS keysFor_mono,
paulson@2032
   122
           new_keys_not_used] MRS contra_subsetD);
paulson@1941
   123
paulson@1941
   124
Addsimps [new_keys_not_used, new_keys_not_analzd];
paulson@1941
   125
paulson@1941
   126
paulson@2064
   127
paulson@2064
   128
(*** Proofs involving analz ***)
paulson@2064
   129
paulson@2135
   130
(*Describes the form of K and NA when the Server sends this message.  Also
paulson@2135
   131
  for Oops case.*)
paulson@2064
   132
goal thy 
paulson@3519
   133
 "!!evs. [| Says Server B {|NA, X, Crypt (shrK B) {|NB, Key K|}|} : set evs; \
paulson@3519
   134
\           evs : otway |]                                           \
paulson@2516
   135
\     ==> K ~: range shrK & (EX i. NA = Nonce i) & (EX j. NB = Nonce j)";
paulson@2135
   136
by (etac rev_mp 1);
paulson@2135
   137
by (etac otway.induct 1);
paulson@3102
   138
by (ALLGOALS Simp_tac);
paulson@3102
   139
by (ALLGOALS Blast_tac);
paulson@2135
   140
qed "Says_Server_message_form";
paulson@2064
   141
paulson@2064
   142
paulson@3519
   143
(*For proofs involving analz.*)
paulson@3683
   144
val analz_spies_tac = 
paulson@3683
   145
    dtac OR2_analz_spies 4 THEN 
paulson@3683
   146
    dtac OR4_analz_spies 6 THEN
paulson@3519
   147
    forward_tac [Says_Server_message_form] 7 THEN
paulson@2516
   148
    assume_tac 7 THEN
paulson@2451
   149
    REPEAT ((eresolve_tac [exE, conjE] ORELSE' hyp_subst_tac) 7);
paulson@1941
   150
paulson@1941
   151
paulson@1941
   152
(****
paulson@1941
   153
 The following is to prove theorems of the form
paulson@1941
   154
paulson@3683
   155
  Key K : analz (insert (Key KAB) (spies evs)) ==>
paulson@3683
   156
  Key K : analz (spies evs)
paulson@1941
   157
paulson@1941
   158
 A more general formula must be proved inductively.
paulson@1941
   159
****)
paulson@1941
   160
paulson@1941
   161
paulson@1941
   162
(** Session keys are not used to encrypt other session keys **)
paulson@1941
   163
paulson@2014
   164
(*The equality makes the induction hypothesis easier to apply*)
paulson@1941
   165
goal thy  
paulson@3519
   166
 "!!evs. evs : otway ==>                                    \
paulson@3519
   167
\  ALL K KK. KK <= Compl (range shrK) -->                   \
paulson@3683
   168
\            (Key K : analz (Key``KK Un (spies evs))) =  \
paulson@3683
   169
\            (K : KK | Key K : analz (spies evs))";
paulson@2032
   170
by (etac otway.induct 1);
paulson@3683
   171
by analz_spies_tac;
paulson@2516
   172
by (REPEAT_FIRST (resolve_tac [allI, impI]));
paulson@2516
   173
by (REPEAT_FIRST (rtac analz_image_freshK_lemma ));
paulson@2516
   174
by (ALLGOALS (asm_simp_tac analz_image_freshK_ss));
paulson@3451
   175
(*Fake*) 
paulson@3451
   176
by (spy_analz_tac 2);
paulson@2516
   177
(*Base*)
paulson@3102
   178
by (Blast_tac 1);
paulson@2516
   179
qed_spec_mp "analz_image_freshK";
paulson@1941
   180
paulson@1941
   181
paulson@1941
   182
goal thy
paulson@3519
   183
 "!!evs. [| evs : otway;  KAB ~: range shrK |] ==>          \
paulson@3683
   184
\        Key K : analz (insert (Key KAB) (spies evs)) =  \
paulson@3683
   185
\        (K = KAB | Key K : analz (spies evs))";
paulson@2516
   186
by (asm_simp_tac (analz_image_freshK_ss addsimps [analz_image_freshK]) 1);
paulson@2516
   187
qed "analz_insert_freshK";
paulson@1941
   188
paulson@1941
   189
paulson@2026
   190
(*** The Key K uniquely identifies the Server's  message. **)
paulson@2014
   191
paulson@2014
   192
goal thy 
paulson@3519
   193
 "!!evs. evs : otway ==>                                                  \
paulson@3466
   194
\   EX B' NA' NB' X'. ALL B NA NB X.                                      \
paulson@3466
   195
\     Says Server B {|NA, X, Crypt (shrK B) {|NB, K|}|} : set evs -->     \
paulson@2135
   196
\     B=B' & NA=NA' & NB=NB' & X=X'";
paulson@2032
   197
by (etac otway.induct 1);
wenzelm@4091
   198
by (ALLGOALS (asm_simp_tac (simpset() addsimps [all_conj_distrib])));
paulson@3730
   199
by (ALLGOALS Clarify_tac);
paulson@2014
   200
(*Remaining cases: OR3 and OR4*)
paulson@2014
   201
by (ex_strip_tac 2);
paulson@3102
   202
by (Best_tac 2);
paulson@2064
   203
by (expand_case_tac "K = ?y" 1);
paulson@2064
   204
by (REPEAT (ares_tac [refl,exI,impI,conjI] 2));
paulson@2516
   205
(*...we assume X is a recent message, and handle this case by contradiction*)
wenzelm@4091
   206
by (blast_tac (claset() addSEs spies_partsEs
paulson@3102
   207
                       delrules [conjI] (*no split-up into 4 subgoals*)) 1);
paulson@2014
   208
val lemma = result();
paulson@2014
   209
paulson@2014
   210
goal thy 
paulson@3543
   211
 "!!evs. [| Says Server B {|NA, X, Crypt (shrK B) {|NB, K|}|}   : set evs; \ 
paulson@3543
   212
\           Says Server B' {|NA',X',Crypt (shrK B') {|NB',K|}|} : set evs; \
paulson@3519
   213
\           evs : otway |] ==> X=X' & B=B' & NA=NA' & NB=NB'";
paulson@2417
   214
by (prove_unique_tac lemma 1);
paulson@2014
   215
qed "unique_session_keys";
paulson@2014
   216
paulson@2014
   217
paulson@2014
   218
paulson@2048
   219
(**** Authenticity properties relating to NA ****)
paulson@2014
   220
paulson@2014
   221
(*Only OR1 can have caused such a part of a message to appear.*)
paulson@2014
   222
goal thy 
paulson@3683
   223
 "!!evs. [| A ~: bad;  evs : otway |]                             \
paulson@3683
   224
\        ==> Crypt (shrK A) {|NA, Agent A, Agent B|} : parts (spies evs) --> \
paulson@2064
   225
\            Says A B {|NA, Agent A, Agent B,                      \
paulson@2284
   226
\                       Crypt (shrK A) {|NA, Agent A, Agent B|}|}  \
nipkow@3465
   227
\             : set evs";
paulson@3519
   228
by (parts_induct_tac 1);
paulson@3121
   229
by (Fake_parts_insert_tac 1);
paulson@2014
   230
qed_spec_mp "Crypt_imp_OR1";
paulson@2014
   231
paulson@2014
   232
paulson@2064
   233
(** The Nonce NA uniquely identifies A's message. **)
paulson@2014
   234
paulson@2014
   235
goal thy 
paulson@3683
   236
 "!!evs. [| evs : otway; A ~: bad |]               \
paulson@3519
   237
\ ==> EX B'. ALL B.                                 \
paulson@3683
   238
\        Crypt (shrK A) {|NA, Agent A, Agent B|} : parts (spies evs) \
paulson@2048
   239
\        --> B = B'";
paulson@3519
   240
by (parts_induct_tac 1);
paulson@3121
   241
by (Fake_parts_insert_tac 1);
wenzelm@4091
   242
by (simp_tac (simpset() addsimps [all_conj_distrib]) 1); 
paulson@2026
   243
(*OR1: creation of new Nonce.  Move assertion into global context*)
paulson@2064
   244
by (expand_case_tac "NA = ?y" 1);
wenzelm@4091
   245
by (blast_tac (claset() addSEs spies_partsEs) 1);
paulson@2014
   246
val lemma = result();
paulson@2014
   247
paulson@2014
   248
goal thy 
paulson@3683
   249
 "!!evs.[| Crypt (shrK A) {|NA, Agent A, Agent B|}: parts (spies evs); \
paulson@3683
   250
\          Crypt (shrK A) {|NA, Agent A, Agent C|}: parts (spies evs); \
paulson@3683
   251
\          evs : otway;  A ~: bad |]                                   \
paulson@2014
   252
\        ==> B = C";
paulson@2417
   253
by (prove_unique_tac lemma 1);
paulson@2048
   254
qed "unique_NA";
paulson@2014
   255
paulson@2014
   256
paulson@2014
   257
(*It is impossible to re-use a nonce in both OR1 and OR2.  This holds because
paulson@2014
   258
  OR2 encrypts Nonce NB.  It prevents the attack that can occur in the
paulson@2014
   259
  over-simplified version of this protocol: see OtwayRees_Bad.*)
paulson@2014
   260
goal thy 
paulson@3683
   261
 "!!evs. [| A ~: bad;  evs : otway |]                      \
paulson@3683
   262
\        ==> Crypt (shrK A) {|NA, Agent A, Agent B|} : parts (spies evs) --> \
paulson@3519
   263
\            Crypt (shrK A) {|NA', NA, Agent A', Agent A|}  \
paulson@3683
   264
\             ~: parts (spies evs)";
paulson@3519
   265
by (parts_induct_tac 1);
paulson@3121
   266
by (Fake_parts_insert_tac 1);
wenzelm@4091
   267
by (REPEAT (blast_tac (claset() addSEs spies_partsEs
paulson@3102
   268
                               addSDs  [impOfSubs parts_insert_subset_Un]) 1));
paulson@2014
   269
qed_spec_mp"no_nonce_OR1_OR2";
paulson@2014
   270
paulson@2014
   271
paulson@2053
   272
(*Crucial property: If the encrypted message appears, and A has used NA
paulson@2053
   273
  to start a run, then it originated with the Server!*)
paulson@2014
   274
goal thy 
paulson@3683
   275
 "!!evs. [| A ~: bad;  A ~= Spy;  evs : otway |]                      \
paulson@3683
   276
\    ==> Crypt (shrK A) {|NA, Key K|} : parts (spies evs)              \
paulson@2048
   277
\        --> Says A B {|NA, Agent A, Agent B,                          \
paulson@2284
   278
\                       Crypt (shrK A) {|NA, Agent A, Agent B|}|}      \
paulson@3466
   279
\             : set evs -->                                            \
paulson@2048
   280
\            (EX NB. Says Server B                                     \
paulson@2048
   281
\                 {|NA,                                                \
paulson@2284
   282
\                   Crypt (shrK A) {|NA, Key K|},                      \
paulson@2284
   283
\                   Crypt (shrK B) {|NB, Key K|}|}                     \
nipkow@3465
   284
\                   : set evs)";
paulson@3519
   285
by (parts_induct_tac 1);
paulson@3121
   286
by (Fake_parts_insert_tac 1);
paulson@2014
   287
(*OR1: it cannot be a new Nonce, contradiction.*)
wenzelm@4091
   288
by (blast_tac (claset() addSIs [parts_insertI] addSEs spies_partsEs) 1);
paulson@3730
   289
(*OR3 and OR4*)
wenzelm@4091
   290
by (asm_simp_tac (simpset() addsimps [ex_disj_distrib]) 1);
paulson@3730
   291
by (rtac conjI 1);
paulson@3730
   292
by (ALLGOALS Clarify_tac);
paulson@3730
   293
(*OR4*)
wenzelm@4091
   294
by (blast_tac (claset() addSIs [Crypt_imp_OR1]
paulson@3730
   295
                       addEs  spies_partsEs) 3);
paulson@3730
   296
(*OR3, two cases*)  (** LEVEL 5 **)
wenzelm@4091
   297
by (blast_tac (claset() addSEs [MPair_parts]
paulson@3730
   298
                       addSDs [Says_imp_spies RS parts.Inj]
paulson@3730
   299
                       addEs  [no_nonce_OR1_OR2 RSN (2, rev_notE)]
paulson@3730
   300
                       delrules [conjI] (*stop split-up into 4 subgoals*)) 2);
wenzelm@4091
   301
by (blast_tac (claset() addSDs [Says_imp_spies RS parts.Inj]
paulson@3730
   302
                       addSEs [MPair_parts]
paulson@3730
   303
                       addIs  [unique_NA]) 1);
paulson@2048
   304
qed_spec_mp "NA_Crypt_imp_Server_msg";
paulson@2014
   305
paulson@2014
   306
paulson@2053
   307
(*Corollary: if A receives B's OR4 message and the nonce NA agrees
paulson@2014
   308
  then the key really did come from the Server!  CANNOT prove this of the
paulson@2048
   309
  bad form of this protocol, even though we can prove
paulson@2032
   310
  Spy_not_see_encrypted_key*)
paulson@2014
   311
goal thy 
paulson@3683
   312
 "!!evs. [| Says B' A {|NA, Crypt (shrK A) {|NA, Key K|}|} : set evs; \
paulson@3683
   313
\           Says A  B {|NA, Agent A, Agent B,                       \
paulson@3683
   314
\                       Crypt (shrK A) {|NA, Agent A, Agent B|}|} : set evs; \
paulson@3683
   315
\           A ~: bad;  A ~= Spy;  evs : otway |]                  \
paulson@2053
   316
\        ==> EX NB. Says Server B                                  \
paulson@2048
   317
\                     {|NA,                                        \
paulson@2284
   318
\                       Crypt (shrK A) {|NA, Key K|},              \
paulson@2284
   319
\                       Crypt (shrK B) {|NB, Key K|}|}             \
nipkow@3465
   320
\                       : set evs";
wenzelm@4091
   321
by (blast_tac (claset() addSIs [NA_Crypt_imp_Server_msg]
paulson@3683
   322
                       addEs  spies_partsEs) 1);
paulson@2328
   323
qed "A_trusts_OR4";
paulson@2014
   324
paulson@2014
   325
paulson@2048
   326
(** Crucial secrecy property: Spy does not see the keys sent in msg OR3
paulson@2048
   327
    Does not in itself guarantee security: an attack could violate 
paulson@2048
   328
    the premises, e.g. by having A=Spy **)
paulson@2014
   329
paulson@1941
   330
goal thy 
paulson@3683
   331
 "!!evs. [| A ~: bad;  B ~: bad;  evs : otway |]                    \
paulson@3519
   332
\        ==> Says Server B                                            \
paulson@3519
   333
\              {|NA, Crypt (shrK A) {|NA, Key K|},                    \
paulson@3519
   334
\                Crypt (shrK B) {|NB, Key K|}|} : set evs -->         \
paulson@3519
   335
\            Says B Spy {|NA, NB, Key K|} ~: set evs -->              \
paulson@3683
   336
\            Key K ~: analz (spies evs)";
paulson@2032
   337
by (etac otway.induct 1);
paulson@3683
   338
by analz_spies_tac;
paulson@1964
   339
by (ALLGOALS
wenzelm@4091
   340
    (asm_simp_tac (simpset() addcongs [conj_cong] 
paulson@3674
   341
                            addsimps [analz_insert_eq, analz_insert_freshK]
paulson@3961
   342
                            addsimps (pushes@expand_ifs))));
paulson@3451
   343
(*Oops*)
wenzelm@4091
   344
by (blast_tac (claset() addSDs [unique_session_keys]) 4);
paulson@3451
   345
(*OR4*) 
paulson@3451
   346
by (Blast_tac 3);
paulson@1941
   347
(*OR3*)
wenzelm@4091
   348
by (blast_tac (claset() addSEs spies_partsEs
paulson@3451
   349
                       addIs [impOfSubs analz_subset_parts]) 2);
paulson@3451
   350
(*Fake*) 
paulson@3451
   351
by (spy_analz_tac 1);
paulson@2014
   352
val lemma = result() RS mp RS mp RSN(2,rev_notE);
paulson@2014
   353
paulson@2014
   354
goal thy 
paulson@3519
   355
 "!!evs. [| Says Server B                                           \
paulson@3519
   356
\            {|NA, Crypt (shrK A) {|NA, Key K|},                    \
paulson@3519
   357
\                  Crypt (shrK B) {|NB, Key K|}|} : set evs;        \
paulson@3519
   358
\           Says B Spy {|NA, NB, Key K|} ~: set evs;                \
paulson@3683
   359
\           A ~: bad;  B ~: bad;  evs : otway |]                  \
paulson@3683
   360
\        ==> Key K ~: analz (spies evs)";
paulson@2014
   361
by (forward_tac [Says_Server_message_form] 1 THEN assume_tac 1);
wenzelm@4091
   362
by (blast_tac (claset() addSEs [lemma]) 1);
paulson@2032
   363
qed "Spy_not_see_encrypted_key";
paulson@2032
   364
paulson@1945
   365
paulson@2048
   366
(**** Authenticity properties relating to NB ****)
paulson@2048
   367
paulson@2048
   368
(*Only OR2 can have caused such a part of a message to appear.  We do not
paulson@2194
   369
  know anything about X: it does NOT have to have the right form.*)
paulson@2048
   370
goal thy 
paulson@3683
   371
 "!!evs. [| B ~: bad;  evs : otway |]                         \
paulson@2284
   372
\        ==> Crypt (shrK B) {|NA, NB, Agent A, Agent B|}       \
paulson@3683
   373
\             : parts (spies evs) -->                       \
paulson@2194
   374
\            (EX X. Says B Server                              \
paulson@2194
   375
\             {|NA, Agent A, Agent B, X,                       \
paulson@2284
   376
\               Crypt (shrK B) {|NA, NB, Agent A, Agent B|}|}  \
nipkow@3465
   377
\             : set evs)";
paulson@3519
   378
by (parts_induct_tac 1);
paulson@3121
   379
by (Fake_parts_insert_tac 1);
paulson@3102
   380
by (ALLGOALS Blast_tac);
paulson@2194
   381
bind_thm ("Crypt_imp_OR2", result() RSN (2,rev_mp) RS exE);
paulson@2048
   382
paulson@2048
   383
paulson@2048
   384
(** The Nonce NB uniquely identifies B's  message. **)
paulson@2048
   385
paulson@2048
   386
goal thy 
paulson@3683
   387
 "!!evs. [| evs : otway; B ~: bad |]                    \
paulson@2064
   388
\ ==> EX NA' A'. ALL NA A.                               \
paulson@3683
   389
\      Crypt (shrK B) {|NA, NB, Agent A, Agent B|} : parts(spies evs) \
paulson@2048
   390
\      --> NA = NA' & A = A'";
paulson@3519
   391
by (parts_induct_tac 1);
paulson@3121
   392
by (Fake_parts_insert_tac 1);
wenzelm@4091
   393
by (simp_tac (simpset() addsimps [all_conj_distrib]) 1); 
paulson@2048
   394
(*OR2: creation of new Nonce.  Move assertion into global context*)
paulson@2064
   395
by (expand_case_tac "NB = ?y" 1);
wenzelm@4091
   396
by (blast_tac (claset() addSEs spies_partsEs) 1);
paulson@2048
   397
val lemma = result();
paulson@2048
   398
paulson@2048
   399
goal thy 
paulson@3683
   400
 "!!evs.[| Crypt (shrK B) {|NA, NB, Agent A, Agent B|} : parts(spies evs); \
paulson@3683
   401
\          Crypt (shrK B) {|NC, NB, Agent C, Agent B|} : parts(spies evs); \
paulson@3683
   402
\          evs : otway;  B ~: bad |]             \
paulson@2048
   403
\        ==> NC = NA & C = A";
paulson@2417
   404
by (prove_unique_tac lemma 1);
paulson@2048
   405
qed "unique_NB";
paulson@2048
   406
paulson@2048
   407
paulson@2048
   408
(*If the encrypted message appears, and B has used Nonce NB,
paulson@2048
   409
  then it originated with the Server!*)
paulson@2048
   410
goal thy 
paulson@3683
   411
 "!!evs. [| B ~: bad;  B ~= Spy;  evs : otway |]                        \
paulson@3683
   412
\    ==> Crypt (shrK B) {|NB, Key K|} : parts (spies evs)             \
paulson@2048
   413
\        --> (ALL X'. Says B Server                                      \
paulson@2048
   414
\                       {|NA, Agent A, Agent B, X',                      \
paulson@2284
   415
\                         Crypt (shrK B) {|NA, NB, Agent A, Agent B|}|}  \
paulson@3466
   416
\             : set evs                                                  \
paulson@2048
   417
\             --> Says Server B                                          \
paulson@2284
   418
\                  {|NA, Crypt (shrK A) {|NA, Key K|},                   \
paulson@2284
   419
\                        Crypt (shrK B) {|NB, Key K|}|}                  \
nipkow@3465
   420
\                   : set evs)";
paulson@3519
   421
by (parts_induct_tac 1);
paulson@3121
   422
by (Fake_parts_insert_tac 1);
paulson@2048
   423
(*OR1: it cannot be a new Nonce, contradiction.*)
wenzelm@4091
   424
by (blast_tac (claset() addSIs [parts_insertI] addSEs spies_partsEs) 1);
paulson@2048
   425
(*OR4*)
wenzelm@4091
   426
by (blast_tac (claset() addSEs [MPair_parts, Crypt_imp_OR2]) 2);
paulson@2194
   427
(*OR3*)
wenzelm@4091
   428
by (safe_tac (claset() delrules [disjCI, impCE]));
wenzelm@4091
   429
by (blast_tac (claset() delrules [conjI] (*stop split-up*)) 3); 
wenzelm@4091
   430
by (blast_tac (claset() addSDs [Says_imp_spies RS parts.Inj]
paulson@3102
   431
                       addSEs [MPair_parts]
paulson@3102
   432
                       addDs  [unique_NB]) 2);
wenzelm@4091
   433
by (blast_tac (claset() addSEs [MPair_parts, no_nonce_OR1_OR2 RSN (2, rev_notE)]
paulson@3683
   434
                       addSDs [Says_imp_spies RS parts.Inj]
paulson@3102
   435
                       delrules [conjI, impCE] (*stop split-up*)) 1);
paulson@2048
   436
qed_spec_mp "NB_Crypt_imp_Server_msg";
paulson@2048
   437
paulson@2048
   438
paulson@2048
   439
(*Guarantee for B: if it gets a message with matching NB then the Server
paulson@2048
   440
  has sent the correct message.*)
paulson@2048
   441
goal thy 
paulson@3683
   442
 "!!evs. [| B ~: bad;  B ~= Spy;  evs : otway;                    \
paulson@3683
   443
\           Says S' B {|NA, X, Crypt (shrK B) {|NB, Key K|}|} : set evs; \
paulson@2048
   444
\           Says B Server {|NA, Agent A, Agent B, X',              \
paulson@2284
   445
\                           Crypt (shrK B) {|NA, NB, Agent A, Agent B|} |} \
paulson@3466
   446
\            : set evs |]                                          \
paulson@2048
   447
\        ==> Says Server B                                         \
paulson@2048
   448
\                 {|NA,                                            \
paulson@2284
   449
\                   Crypt (shrK A) {|NA, Key K|},                  \
paulson@2284
   450
\                   Crypt (shrK B) {|NB, Key K|}|}                 \
nipkow@3465
   451
\                   : set evs";
wenzelm@4091
   452
by (blast_tac (claset() addSIs [NB_Crypt_imp_Server_msg]
paulson@3683
   453
                       addSEs spies_partsEs) 1);
paulson@2328
   454
qed "B_trusts_OR3";
paulson@2048
   455
paulson@2048
   456
paulson@2328
   457
B_trusts_OR3 RS Spy_not_see_encrypted_key;
paulson@2048
   458
paulson@2048
   459
paulson@1945
   460
goal thy 
paulson@3683
   461
 "!!evs. [| B ~: bad;  evs : otway |]                           \
paulson@3519
   462
\        ==> Says Server B                                       \
paulson@3519
   463
\              {|NA, Crypt (shrK A) {|NA, Key K|},               \
paulson@3519
   464
\                Crypt (shrK B) {|NB, Key K|}|} : set evs -->    \
paulson@3519
   465
\            (EX X. Says B Server {|NA, Agent A, Agent B, X,     \
paulson@2284
   466
\                            Crypt (shrK B) {|NA, NB, Agent A, Agent B|} |} \
nipkow@3465
   467
\            : set evs)";
paulson@2032
   468
by (etac otway.induct 1);
paulson@3102
   469
by (ALLGOALS Asm_simp_tac);
wenzelm@4091
   470
by (blast_tac (claset() addDs [Says_imp_spies RS parts.Inj]
paulson@3102
   471
		       addSEs [MPair_parts, Crypt_imp_OR2]) 3);
paulson@3102
   472
by (ALLGOALS Blast_tac);
paulson@2194
   473
bind_thm ("OR3_imp_OR2", result() RSN (2,rev_mp) RS exE);
paulson@2194
   474
paulson@2194
   475
paulson@2194
   476
(*After getting and checking OR4, agent A can trust that B has been active.
paulson@2194
   477
  We could probably prove that X has the expected form, but that is not
paulson@2194
   478
  strictly necessary for authentication.*)
paulson@2194
   479
goal thy 
paulson@3466
   480
 "!!evs. [| Says B' A {|NA, Crypt (shrK A) {|NA, Key K|}|} : set evs;       \
paulson@3466
   481
\           Says A B {|NA, Agent A, Agent B,                                \
paulson@3466
   482
\                      Crypt (shrK A) {|NA, Agent A, Agent B|}|} : set evs; \
paulson@3683
   483
\           A ~: bad;  A ~= Spy;  B ~: bad;  evs : otway |]               \
paulson@3466
   484
\        ==> EX NB X. Says B Server {|NA, Agent A, Agent B, X,              \
paulson@2284
   485
\                              Crypt (shrK B)  {|NA, NB, Agent A, Agent B|} |}\
nipkow@3465
   486
\            : set evs";
wenzelm@4091
   487
by (blast_tac (claset() addSDs  [A_trusts_OR4]
paulson@3102
   488
                       addSEs [OR3_imp_OR2]) 1);
paulson@2194
   489
qed "A_auths_B";