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