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