src/HOL/Auth/OtwayRees.ML
author paulson
Tue Jul 22 11:26:02 1997 +0200 (1997-07-22)
changeset 3543 82f33248d89d
parent 3519 ab0a9fbed4c0
child 3674 65ec38fbb265
permissions -rw-r--r--
Cosmetic changes: margins, indentation, ...
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@3519
    47
\                ==> X : analz (sees Spy evs)";
paulson@3519
    48
by (blast_tac (!claset addSDs [Says_imp_sees_Spy RS analz.Inj]) 1);
paulson@2032
    49
qed "OR2_analz_sees_Spy";
paulson@1941
    50
nipkow@3465
    51
goal thy "!!evs. Says S' B {|N, X, Crypt (shrK B) X'|} : set evs \
paulson@3519
    52
\                ==> X : analz (sees Spy evs)";
paulson@3519
    53
by (blast_tac (!claset addSDs [Says_imp_sees_Spy RS analz.Inj]) 1);
paulson@2032
    54
qed "OR4_analz_sees_Spy";
paulson@1941
    55
nipkow@3465
    56
goal thy "!!evs. Says Server B {|NA, X, Crypt K' {|NB,K|}|} : set evs \
paulson@3519
    57
\                 ==> K : parts (sees Spy evs)";
paulson@3102
    58
by (blast_tac (!claset addSEs sees_Spy_partsEs) 1);
paulson@2135
    59
qed "Oops_parts_sees_Spy";
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@2032
    66
bind_thm ("OR2_parts_sees_Spy",
paulson@2032
    67
          OR2_analz_sees_Spy RS (impOfSubs analz_subset_parts));
paulson@2032
    68
bind_thm ("OR4_parts_sees_Spy",
paulson@2032
    69
          OR4_analz_sees_Spy RS (impOfSubs analz_subset_parts));
paulson@2032
    70
paulson@3519
    71
(*For proving the easier theorems about X ~: parts (sees Spy evs).*)
paulson@3519
    72
fun parts_induct_tac i = 
paulson@3519
    73
    etac otway.induct i			THEN 
paulson@3519
    74
    forward_tac [Oops_parts_sees_Spy] (i+6) THEN
paulson@3519
    75
    forward_tac [OR4_parts_sees_Spy]  (i+5) THEN
paulson@3519
    76
    forward_tac [OR2_parts_sees_Spy]  (i+3) THEN 
paulson@3519
    77
    prove_simple_subgoals_tac  i;
paulson@1941
    78
paulson@1941
    79
paulson@3519
    80
(** Theorems of the form X ~: parts (sees Spy evs) imply that NOBODY
paulson@2014
    81
    sends messages containing X! **)
paulson@1941
    82
paulson@3121
    83
paulson@2064
    84
(*Spy never sees another agent's shared key! (unless it's lost at start)*)
paulson@1941
    85
goal thy 
paulson@3519
    86
 "!!evs. evs : otway ==> (Key (shrK A) : parts (sees Spy evs)) = (A : lost)";
paulson@3519
    87
by (parts_induct_tac 1);
paulson@3121
    88
by (Fake_parts_insert_tac 1);
paulson@3121
    89
by (Blast_tac 1);
paulson@2135
    90
qed "Spy_see_shrK";
paulson@2135
    91
Addsimps [Spy_see_shrK];
paulson@1941
    92
paulson@2135
    93
goal thy 
paulson@3519
    94
 "!!evs. evs : otway ==> (Key (shrK A) : analz (sees Spy evs)) = (A : lost)";
paulson@2135
    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@3519
    99
goal thy  "!!A. [| Key (shrK A) : parts (sees Spy evs);       \
paulson@3519
   100
\                  evs : otway |] ==> A:lost";
paulson@3102
   101
by (blast_tac (!claset addDs [Spy_see_shrK]) 1);
paulson@2135
   102
qed "Spy_see_shrK_D";
paulson@1941
   103
paulson@2135
   104
bind_thm ("Spy_analz_shrK_D", analz_subset_parts RS subsetD RS Spy_see_shrK_D);
paulson@2135
   105
AddSDs [Spy_see_shrK_D, Spy_analz_shrK_D];
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@3519
   110
\         Key K ~: used evs --> K ~: keysFor (parts (sees Spy evs))";
paulson@3519
   111
by (parts_induct_tac 1);
paulson@2516
   112
(*Fake*)
paulson@2516
   113
by (best_tac
paulson@2516
   114
      (!claset addIs [impOfSubs analz_subset_parts]
paulson@2516
   115
               addDs [impOfSubs (analz_subset_parts RS keysFor_mono),
paulson@2516
   116
                      impOfSubs (parts_insert_subset_Un RS keysFor_mono)]
oheimb@3207
   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@3121
   145
val analz_sees_tac = 
paulson@3519
   146
    dtac OR2_analz_sees_Spy 4 THEN 
paulson@3519
   147
    dtac OR4_analz_sees_Spy 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@3519
   156
  Key K : analz (insert (Key KAB) (sees Spy evs)) ==>
paulson@3519
   157
  Key K : analz (sees Spy 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@3519
   169
\            (Key K : analz (Key``KK Un (sees Spy evs))) =  \
paulson@3519
   170
\            (K : KK | Key K : analz (sees Spy evs))";
paulson@2032
   171
by (etac otway.induct 1);
paulson@3121
   172
by analz_sees_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@3451
   177
by (spy_analz_tac 2);
paulson@2516
   178
(*Base*)
paulson@3102
   179
by (Blast_tac 1);
paulson@2516
   180
qed_spec_mp "analz_image_freshK";
paulson@1941
   181
paulson@1941
   182
paulson@1941
   183
goal thy
paulson@3519
   184
 "!!evs. [| evs : otway;  KAB ~: range shrK |] ==>          \
paulson@3519
   185
\        Key K : analz (insert (Key KAB) (sees Spy evs)) =  \
paulson@3519
   186
\        (K = KAB | Key K : analz (sees Spy evs))";
paulson@2516
   187
by (asm_simp_tac (analz_image_freshK_ss addsimps [analz_image_freshK]) 1);
paulson@2516
   188
qed "analz_insert_freshK";
paulson@1941
   189
paulson@1941
   190
paulson@2026
   191
(*** The Key K uniquely identifies the Server's  message. **)
paulson@2014
   192
paulson@2014
   193
goal thy 
paulson@3519
   194
 "!!evs. evs : otway ==>                                                  \
paulson@3466
   195
\   EX B' NA' NB' X'. ALL B NA NB X.                                      \
paulson@3466
   196
\     Says Server B {|NA, X, Crypt (shrK B) {|NB, K|}|} : set evs -->     \
paulson@2135
   197
\     B=B' & NA=NA' & NB=NB' & X=X'";
paulson@2032
   198
by (etac otway.induct 1);
paulson@2014
   199
by (ALLGOALS (asm_simp_tac (!simpset addsimps [all_conj_distrib])));
paulson@2014
   200
by (Step_tac 1);
paulson@2014
   201
(*Remaining cases: OR3 and OR4*)
paulson@2014
   202
by (ex_strip_tac 2);
paulson@3102
   203
by (Best_tac 2);
paulson@2064
   204
by (expand_case_tac "K = ?y" 1);
paulson@2064
   205
by (REPEAT (ares_tac [refl,exI,impI,conjI] 2));
paulson@2516
   206
(*...we assume X is a recent message, and handle this case by contradiction*)
paulson@3102
   207
by (blast_tac (!claset addSEs sees_Spy_partsEs
paulson@3102
   208
                       delrules [conjI] (*no split-up into 4 subgoals*)) 1);
paulson@2014
   209
val lemma = result();
paulson@2014
   210
paulson@2014
   211
goal thy 
paulson@3543
   212
 "!!evs. [| Says Server B {|NA, X, Crypt (shrK B) {|NB, K|}|}   : set evs; \ 
paulson@3543
   213
\           Says Server B' {|NA',X',Crypt (shrK B') {|NB',K|}|} : set evs; \
paulson@3519
   214
\           evs : otway |] ==> X=X' & B=B' & NA=NA' & NB=NB'";
paulson@2417
   215
by (prove_unique_tac lemma 1);
paulson@2014
   216
qed "unique_session_keys";
paulson@2014
   217
paulson@2014
   218
paulson@2014
   219
paulson@2048
   220
(**** Authenticity properties relating to NA ****)
paulson@2014
   221
paulson@2014
   222
(*Only OR1 can have caused such a part of a message to appear.*)
paulson@2014
   223
goal thy 
paulson@3519
   224
 "!!evs. [| A ~: lost;  evs : otway |]                             \
paulson@2284
   225
\        ==> Crypt (shrK A) {|NA, Agent A, Agent B|}               \
paulson@3519
   226
\             : parts (sees Spy evs) -->                           \
paulson@2064
   227
\            Says A B {|NA, Agent A, Agent B,                      \
paulson@2284
   228
\                       Crypt (shrK A) {|NA, Agent A, Agent B|}|}  \
nipkow@3465
   229
\             : set evs";
paulson@3519
   230
by (parts_induct_tac 1);
paulson@3121
   231
by (Fake_parts_insert_tac 1);
paulson@2014
   232
qed_spec_mp "Crypt_imp_OR1";
paulson@2014
   233
paulson@2014
   234
paulson@2064
   235
(** The Nonce NA uniquely identifies A's message. **)
paulson@2014
   236
paulson@2014
   237
goal thy 
paulson@3519
   238
 "!!evs. [| evs : otway; A ~: lost |]               \
paulson@3519
   239
\ ==> EX B'. ALL B.                                 \
paulson@3519
   240
\        Crypt (shrK A) {|NA, Agent A, Agent B|} : parts (sees Spy evs) \
paulson@2048
   241
\        --> B = B'";
paulson@3519
   242
by (parts_induct_tac 1);
paulson@3121
   243
by (Fake_parts_insert_tac 1);
paulson@2064
   244
by (simp_tac (!simpset addsimps [all_conj_distrib]) 1); 
paulson@2026
   245
(*OR1: creation of new Nonce.  Move assertion into global context*)
paulson@2064
   246
by (expand_case_tac "NA = ?y" 1);
paulson@3102
   247
by (blast_tac (!claset addSEs sees_Spy_partsEs) 1);
paulson@2014
   248
val lemma = result();
paulson@2014
   249
paulson@2014
   250
goal thy 
paulson@3519
   251
 "!!evs.[| Crypt (shrK A) {|NA, Agent A, Agent B|}: parts (sees Spy evs); \
paulson@3519
   252
\          Crypt (shrK A) {|NA, Agent A, Agent C|}: parts (sees Spy evs); \
paulson@3519
   253
\          evs : otway;  A ~: lost |]                                     \
paulson@2014
   254
\        ==> B = C";
paulson@2417
   255
by (prove_unique_tac lemma 1);
paulson@2048
   256
qed "unique_NA";
paulson@2014
   257
paulson@2014
   258
paulson@2014
   259
(*It is impossible to re-use a nonce in both OR1 and OR2.  This holds because
paulson@2014
   260
  OR2 encrypts Nonce NB.  It prevents the attack that can occur in the
paulson@2014
   261
  over-simplified version of this protocol: see OtwayRees_Bad.*)
paulson@2014
   262
goal thy 
paulson@3519
   263
 "!!evs. [| A ~: lost;  evs : otway |]                      \
paulson@3519
   264
\        ==> Crypt (shrK A) {|NA, Agent A, Agent B|}        \
paulson@3519
   265
\             : parts (sees Spy evs) -->                    \
paulson@3519
   266
\            Crypt (shrK A) {|NA', NA, Agent A', Agent A|}  \
paulson@3519
   267
\             ~: parts (sees Spy evs)";
paulson@3519
   268
by (parts_induct_tac 1);
paulson@3121
   269
by (Fake_parts_insert_tac 1);
paulson@3102
   270
by (REPEAT (blast_tac (!claset addSEs sees_Spy_partsEs
paulson@3102
   271
                               addSDs  [impOfSubs parts_insert_subset_Un]) 1));
paulson@2014
   272
qed_spec_mp"no_nonce_OR1_OR2";
paulson@2014
   273
paulson@2014
   274
paulson@2053
   275
(*Crucial property: If the encrypted message appears, and A has used NA
paulson@2053
   276
  to start a run, then it originated with the Server!*)
paulson@2014
   277
goal thy 
paulson@3543
   278
 "!!evs. [| A ~: lost;  A ~= Spy;  evs : otway |]                      \
paulson@3543
   279
\    ==> Crypt (shrK A) {|NA, Key K|} : parts (sees Spy evs)           \
paulson@2048
   280
\        --> Says A B {|NA, Agent A, Agent B,                          \
paulson@2284
   281
\                       Crypt (shrK A) {|NA, Agent A, Agent B|}|}      \
paulson@3466
   282
\             : set evs -->                                            \
paulson@2048
   283
\            (EX NB. Says Server B                                     \
paulson@2048
   284
\                 {|NA,                                                \
paulson@2284
   285
\                   Crypt (shrK A) {|NA, Key K|},                      \
paulson@2284
   286
\                   Crypt (shrK B) {|NB, Key K|}|}                     \
nipkow@3465
   287
\                   : set evs)";
paulson@3519
   288
by (parts_induct_tac 1);
paulson@3121
   289
by (Fake_parts_insert_tac 1);
paulson@2014
   290
(*OR1: it cannot be a new Nonce, contradiction.*)
paulson@3102
   291
by (blast_tac (!claset addSIs [parts_insertI] addSEs sees_Spy_partsEs) 1);
paulson@2064
   292
(*OR3 and OR4*) 
paulson@2014
   293
(*OR4*)
paulson@2014
   294
by (REPEAT (Safe_step_tac 2));
paulson@3102
   295
by (REPEAT (blast_tac (!claset addSDs [parts_cut]) 3));
paulson@3543
   296
by (blast_tac (!claset addSIs [Crypt_imp_OR1]
paulson@3543
   297
                       addEs  sees_Spy_partsEs) 2);
paulson@2064
   298
(*OR3*)  (** LEVEL 5 **)
paulson@2064
   299
by (asm_simp_tac (!simpset addsimps [ex_disj_distrib]) 1);
paulson@2014
   300
by (step_tac (!claset delrules [disjCI, impCE]) 1);
paulson@3102
   301
by (blast_tac (!claset addSEs [MPair_parts]
paulson@3519
   302
                      addSDs [Says_imp_sees_Spy RS parts.Inj]
paulson@2014
   303
                      addEs  [no_nonce_OR1_OR2 RSN (2, rev_notE)]
paulson@2048
   304
                      delrules [conjI] (*stop split-up into 4 subgoals*)) 2);
paulson@3519
   305
by (blast_tac (!claset addSDs [Says_imp_sees_Spy RS parts.Inj]
paulson@2048
   306
                      addSEs [MPair_parts]
paulson@3102
   307
                      addIs  [unique_NA]) 1);
paulson@2048
   308
qed_spec_mp "NA_Crypt_imp_Server_msg";
paulson@2014
   309
paulson@2014
   310
paulson@2053
   311
(*Corollary: if A receives B's OR4 message and the nonce NA agrees
paulson@2014
   312
  then the key really did come from the Server!  CANNOT prove this of the
paulson@2048
   313
  bad form of this protocol, even though we can prove
paulson@2032
   314
  Spy_not_see_encrypted_key*)
paulson@2014
   315
goal thy 
paulson@2284
   316
 "!!evs. [| Says B' A {|NA, Crypt (shrK A) {|NA, Key K|}|}         \
paulson@3466
   317
\            : set evs;                                            \
paulson@2053
   318
\           Says A B {|NA, Agent A, Agent B,                       \
paulson@2284
   319
\                      Crypt (shrK A) {|NA, Agent A, Agent B|}|}   \
paulson@3466
   320
\            : set evs;                                            \
paulson@3519
   321
\           A ~: lost;  A ~= Spy;  evs : otway |]                  \
paulson@2053
   322
\        ==> EX NB. Says Server B                                  \
paulson@2048
   323
\                     {|NA,                                        \
paulson@2284
   324
\                       Crypt (shrK A) {|NA, Key K|},              \
paulson@2284
   325
\                       Crypt (shrK B) {|NB, Key K|}|}             \
nipkow@3465
   326
\                       : set evs";
paulson@3102
   327
by (blast_tac (!claset addSIs [NA_Crypt_imp_Server_msg]
paulson@3102
   328
                       addEs  sees_Spy_partsEs) 1);
paulson@2328
   329
qed "A_trusts_OR4";
paulson@2014
   330
paulson@2014
   331
paulson@2048
   332
(** Crucial secrecy property: Spy does not see the keys sent in msg OR3
paulson@2048
   333
    Does not in itself guarantee security: an attack could violate 
paulson@2048
   334
    the premises, e.g. by having A=Spy **)
paulson@2014
   335
paulson@1941
   336
goal thy 
paulson@3519
   337
 "!!evs. [| A ~: lost;  B ~: lost;  evs : otway |]                    \
paulson@3519
   338
\        ==> Says Server B                                            \
paulson@3519
   339
\              {|NA, Crypt (shrK A) {|NA, Key K|},                    \
paulson@3519
   340
\                Crypt (shrK B) {|NB, Key K|}|} : set evs -->         \
paulson@3519
   341
\            Says B Spy {|NA, NB, Key K|} ~: set evs -->              \
paulson@3519
   342
\            Key K ~: analz (sees Spy evs)";
paulson@2032
   343
by (etac otway.induct 1);
paulson@3121
   344
by analz_sees_tac;
paulson@1964
   345
by (ALLGOALS
paulson@2516
   346
    (asm_simp_tac (!simpset addcongs [conj_cong] 
paulson@3451
   347
                            addsimps [analz_insert_eq, not_parts_not_analz, 
paulson@3451
   348
				      analz_insert_freshK]
paulson@2516
   349
                            setloop split_tac [expand_if])));
paulson@3451
   350
(*Oops*)
paulson@3451
   351
by (blast_tac (!claset addSDs [unique_session_keys]) 4);
paulson@3451
   352
(*OR4*) 
paulson@3451
   353
by (Blast_tac 3);
paulson@1941
   354
(*OR3*)
paulson@3451
   355
by (blast_tac (!claset addSEs sees_Spy_partsEs
paulson@3451
   356
                       addIs [impOfSubs analz_subset_parts]) 2);
paulson@3451
   357
(*Fake*) 
paulson@3451
   358
by (spy_analz_tac 1);
paulson@2014
   359
val lemma = result() RS mp RS mp RSN(2,rev_notE);
paulson@2014
   360
paulson@2014
   361
goal thy 
paulson@3519
   362
 "!!evs. [| Says Server B                                           \
paulson@3519
   363
\            {|NA, Crypt (shrK A) {|NA, Key K|},                    \
paulson@3519
   364
\                  Crypt (shrK B) {|NB, Key K|}|} : set evs;        \
paulson@3519
   365
\           Says B Spy {|NA, NB, Key K|} ~: set evs;                \
paulson@3519
   366
\           A ~: lost;  B ~: lost;  evs : otway |]                  \
paulson@3519
   367
\        ==> Key K ~: analz (sees Spy evs)";
paulson@2014
   368
by (forward_tac [Says_Server_message_form] 1 THEN assume_tac 1);
paulson@3102
   369
by (blast_tac (!claset addSEs [lemma]) 1);
paulson@2032
   370
qed "Spy_not_see_encrypted_key";
paulson@2032
   371
paulson@1945
   372
paulson@2048
   373
(**** Authenticity properties relating to NB ****)
paulson@2048
   374
paulson@2048
   375
(*Only OR2 can have caused such a part of a message to appear.  We do not
paulson@2194
   376
  know anything about X: it does NOT have to have the right form.*)
paulson@2048
   377
goal thy 
paulson@3519
   378
 "!!evs. [| B ~: lost;  evs : otway |]                         \
paulson@2284
   379
\        ==> Crypt (shrK B) {|NA, NB, Agent A, Agent B|}       \
paulson@3519
   380
\             : parts (sees Spy evs) -->                       \
paulson@2194
   381
\            (EX X. Says B Server                              \
paulson@2194
   382
\             {|NA, Agent A, Agent B, X,                       \
paulson@2284
   383
\               Crypt (shrK B) {|NA, NB, Agent A, Agent B|}|}  \
nipkow@3465
   384
\             : set evs)";
paulson@3519
   385
by (parts_induct_tac 1);
paulson@3121
   386
by (Fake_parts_insert_tac 1);
paulson@3102
   387
by (ALLGOALS Blast_tac);
paulson@2194
   388
bind_thm ("Crypt_imp_OR2", result() RSN (2,rev_mp) RS exE);
paulson@2048
   389
paulson@2048
   390
paulson@2048
   391
(** The Nonce NB uniquely identifies B's  message. **)
paulson@2048
   392
paulson@2048
   393
goal thy 
paulson@3519
   394
 "!!evs. [| evs : otway; B ~: lost |]                    \
paulson@2064
   395
\ ==> EX NA' A'. ALL NA A.                               \
paulson@3519
   396
\      Crypt (shrK B) {|NA, NB, Agent A, Agent B|} : parts(sees Spy evs) \
paulson@2048
   397
\      --> NA = NA' & A = A'";
paulson@3519
   398
by (parts_induct_tac 1);
paulson@3121
   399
by (Fake_parts_insert_tac 1);
paulson@2064
   400
by (simp_tac (!simpset addsimps [all_conj_distrib]) 1); 
paulson@2048
   401
(*OR2: creation of new Nonce.  Move assertion into global context*)
paulson@2064
   402
by (expand_case_tac "NB = ?y" 1);
paulson@3102
   403
by (blast_tac (!claset addSEs sees_Spy_partsEs) 1);
paulson@2048
   404
val lemma = result();
paulson@2048
   405
paulson@2048
   406
goal thy 
paulson@2284
   407
 "!!evs.[| Crypt (shrK B) {|NA, NB, Agent A, Agent B|} \
paulson@3519
   408
\                  : parts(sees Spy evs);         \
paulson@2284
   409
\          Crypt (shrK B) {|NC, NB, Agent C, Agent B|} \
paulson@3519
   410
\                  : parts(sees Spy evs);         \
paulson@3519
   411
\          evs : otway;  B ~: lost |]             \
paulson@2048
   412
\        ==> NC = NA & C = A";
paulson@2417
   413
by (prove_unique_tac lemma 1);
paulson@2048
   414
qed "unique_NB";
paulson@2048
   415
paulson@2048
   416
paulson@2048
   417
(*If the encrypted message appears, and B has used Nonce NB,
paulson@2048
   418
  then it originated with the Server!*)
paulson@2048
   419
goal thy 
paulson@3519
   420
 "!!evs. [| B ~: lost;  B ~= Spy;  evs : otway |]                        \
paulson@3519
   421
\    ==> Crypt (shrK B) {|NB, Key K|} : parts (sees Spy evs)             \
paulson@2048
   422
\        --> (ALL X'. Says B Server                                      \
paulson@2048
   423
\                       {|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@2284
   427
\                  {|NA, Crypt (shrK A) {|NA, Key K|},                   \
paulson@2284
   428
\                        Crypt (shrK B) {|NB, Key K|}|}                  \
nipkow@3465
   429
\                   : set evs)";
paulson@3519
   430
by (parts_induct_tac 1);
paulson@3121
   431
by (Fake_parts_insert_tac 1);
paulson@2048
   432
(*OR1: it cannot be a new Nonce, contradiction.*)
paulson@3102
   433
by (blast_tac (!claset addSIs [parts_insertI] addSEs sees_Spy_partsEs) 1);
paulson@2048
   434
(*OR4*)
paulson@3102
   435
by (blast_tac (!claset addSEs [MPair_parts, Crypt_imp_OR2]) 2);
paulson@2194
   436
(*OR3*)
paulson@2048
   437
by (step_tac (!claset delrules [disjCI, impCE]) 1);
paulson@3102
   438
by (blast_tac (!claset delrules [conjI] (*stop split-up*)) 3); 
paulson@3519
   439
by (blast_tac (!claset addSDs [Says_imp_sees_Spy RS parts.Inj]
paulson@3102
   440
                       addSEs [MPair_parts]
paulson@3102
   441
                       addDs  [unique_NB]) 2);
paulson@3102
   442
by (blast_tac (!claset addSEs [MPair_parts, no_nonce_OR1_OR2 RSN (2, rev_notE)]
paulson@3519
   443
                       addSDs [Says_imp_sees_Spy RS parts.Inj]
paulson@3102
   444
                       delrules [conjI, impCE] (*stop split-up*)) 1);
paulson@2048
   445
qed_spec_mp "NB_Crypt_imp_Server_msg";
paulson@2048
   446
paulson@2048
   447
paulson@2048
   448
(*Guarantee for B: if it gets a message with matching NB then the Server
paulson@2048
   449
  has sent the correct message.*)
paulson@2048
   450
goal thy 
paulson@3519
   451
 "!!evs. [| B ~: lost;  B ~= Spy;  evs : otway;                    \
paulson@2837
   452
\           Says S' B {|NA, X, Crypt (shrK B) {|NB, Key K|}|}      \
paulson@3466
   453
\            : set evs;                                            \
paulson@2048
   454
\           Says B Server {|NA, Agent A, Agent B, X',              \
paulson@2284
   455
\                           Crypt (shrK B) {|NA, NB, Agent A, Agent B|} |} \
paulson@3466
   456
\            : set evs |]                                          \
paulson@2048
   457
\        ==> Says Server B                                         \
paulson@2048
   458
\                 {|NA,                                            \
paulson@2284
   459
\                   Crypt (shrK A) {|NA, Key K|},                  \
paulson@2284
   460
\                   Crypt (shrK B) {|NB, Key K|}|}                 \
nipkow@3465
   461
\                   : set evs";
paulson@3102
   462
by (blast_tac (!claset addSIs [NB_Crypt_imp_Server_msg]
paulson@3102
   463
                       addSEs sees_Spy_partsEs) 1);
paulson@2328
   464
qed "B_trusts_OR3";
paulson@2048
   465
paulson@2048
   466
paulson@2328
   467
B_trusts_OR3 RS Spy_not_see_encrypted_key;
paulson@2048
   468
paulson@2048
   469
paulson@1945
   470
goal thy 
paulson@3519
   471
 "!!evs. [| B ~: lost;  evs : otway |]                           \
paulson@3519
   472
\        ==> Says Server B                                       \
paulson@3519
   473
\              {|NA, Crypt (shrK A) {|NA, Key K|},               \
paulson@3519
   474
\                Crypt (shrK B) {|NB, Key K|}|} : set evs -->    \
paulson@3519
   475
\            (EX X. Says B Server {|NA, Agent A, Agent B, X,     \
paulson@2284
   476
\                            Crypt (shrK B) {|NA, NB, Agent A, Agent B|} |} \
nipkow@3465
   477
\            : set evs)";
paulson@2032
   478
by (etac otway.induct 1);
paulson@3102
   479
by (ALLGOALS Asm_simp_tac);
paulson@3519
   480
by (blast_tac (!claset addDs [Says_imp_sees_Spy RS parts.Inj]
paulson@3102
   481
		       addSEs [MPair_parts, Crypt_imp_OR2]) 3);
paulson@3102
   482
by (ALLGOALS Blast_tac);
paulson@2194
   483
bind_thm ("OR3_imp_OR2", result() RSN (2,rev_mp) RS exE);
paulson@2194
   484
paulson@2194
   485
paulson@2194
   486
(*After getting and checking OR4, agent A can trust that B has been active.
paulson@2194
   487
  We could probably prove that X has the expected form, but that is not
paulson@2194
   488
  strictly necessary for authentication.*)
paulson@2194
   489
goal thy 
paulson@3466
   490
 "!!evs. [| Says B' A {|NA, Crypt (shrK A) {|NA, Key K|}|} : set evs;       \
paulson@3466
   491
\           Says A B {|NA, Agent A, Agent B,                                \
paulson@3466
   492
\                      Crypt (shrK A) {|NA, Agent A, Agent B|}|} : set evs; \
paulson@3519
   493
\           A ~: lost;  A ~= Spy;  B ~: lost;  evs : otway |]               \
paulson@3466
   494
\        ==> EX NB X. Says B Server {|NA, Agent A, Agent B, X,              \
paulson@2284
   495
\                              Crypt (shrK B)  {|NA, NB, Agent A, Agent B|} |}\
nipkow@3465
   496
\            : set evs";
paulson@3102
   497
by (blast_tac (!claset addSDs  [A_trusts_OR4]
paulson@3102
   498
                       addSEs [OR3_imp_OR2]) 1);
paulson@2194
   499
qed "A_auths_B";