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