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