src/HOL/Auth/OtwayRees_AN.ML
author paulson
Fri Jul 11 13:32:39 1997 +0200 (1997-07-11)
changeset 3516 470626799511
parent 3466 30791e5a69c4
child 3519 ab0a9fbed4c0
permissions -rw-r--r--
Removal of monotonicity reasoning involving "lost" and the theorem
Agent_not_see_encrypted_key, which (a) is never used and (b) becomes harder
to prove when Notes is available.
paulson@2090
     1
(*  Title:      HOL/Auth/OtwayRees
paulson@2090
     2
    ID:         $Id$
paulson@2090
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@2090
     4
    Copyright   1996  University of Cambridge
paulson@2090
     5
paulson@2090
     6
Inductive relation "otway" for the Otway-Rees protocol.
paulson@2090
     7
paulson@2090
     8
Simplified version with minimal encryption but explicit messages
paulson@2090
     9
paulson@2090
    10
From page 11 of
paulson@2090
    11
  Abadi and Needham.  Prudent Engineering Practice for Cryptographic Protocols.
paulson@2090
    12
  IEEE Trans. SE 22 (1), 1996
paulson@2090
    13
*)
paulson@2090
    14
paulson@2090
    15
open OtwayRees_AN;
paulson@2090
    16
paulson@2090
    17
proof_timing:=true;
paulson@2090
    18
HOL_quantifiers := false;
paulson@2090
    19
paulson@2090
    20
paulson@2331
    21
(*A "possibility property": there are traces that reach the end*)
paulson@2090
    22
goal thy 
paulson@2331
    23
 "!!A B. [| A ~= B; A ~= Server; B ~= Server |]                               \
paulson@2331
    24
\        ==> EX K. EX NA. EX evs: otway lost.                                 \
paulson@2284
    25
\             Says B A (Crypt (shrK A) {|Nonce NA, Agent A, Agent B, Key K|}) \
nipkow@3465
    26
\             : set evs";
paulson@2090
    27
by (REPEAT (resolve_tac [exI,bexI] 1));
paulson@2090
    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@2090
    30
result();
paulson@2090
    31
paulson@2090
    32
paulson@2090
    33
(**** Inductive proofs about otway ****)
paulson@2090
    34
paulson@2090
    35
(*Nobody sends themselves messages*)
nipkow@3465
    36
goal thy "!!evs. evs : otway lost ==> ALL A X. Says A A X ~: set evs";
paulson@2090
    37
by (etac otway.induct 1);
paulson@2090
    38
by (Auto_tac());
paulson@2090
    39
qed_spec_mp "not_Says_to_self";
paulson@2090
    40
Addsimps [not_Says_to_self];
paulson@2090
    41
AddSEs   [not_Says_to_self RSN (2, rev_notE)];
paulson@2090
    42
paulson@2090
    43
paulson@2090
    44
(** For reasoning about the encrypted portion of messages **)
paulson@2090
    45
nipkow@3465
    46
goal thy "!!evs. Says S' B {|X, Crypt(shrK B) X'|} : set evs ==> \
paulson@2090
    47
\                X : analz (sees lost Spy evs)";
paulson@3102
    48
by (blast_tac (!claset addSDs [Says_imp_sees_Spy RS analz.Inj]) 1);
paulson@2090
    49
qed "OR4_analz_sees_Spy";
paulson@2090
    50
paulson@2284
    51
goal thy "!!evs. Says Server B {|X, Crypt K' {|NB, a, Agent B, K|}|} \
nipkow@3465
    52
\                  : set evs ==> K : parts (sees lost Spy evs)";
paulson@3102
    53
by (blast_tac (!claset addSEs sees_Spy_partsEs) 1);
paulson@2131
    54
qed "Oops_parts_sees_Spy";
paulson@2090
    55
paulson@2131
    56
(*OR4_analz_sees_Spy lets us treat those cases using the same 
paulson@2090
    57
  argument as for the Fake case.  This is possible for most, but not all,
paulson@2131
    58
  proofs, since Fake messages originate from the Spy. *)
paulson@2090
    59
paulson@2090
    60
bind_thm ("OR4_parts_sees_Spy",
paulson@2090
    61
          OR4_analz_sees_Spy RS (impOfSubs analz_subset_parts));
paulson@2090
    62
paulson@3121
    63
(*For proving the easier theorems about X ~: parts (sees lost Spy evs).
paulson@3121
    64
  We instantiate the variable to "lost" since leaving it as a Var would
paulson@3121
    65
  interfere with simplification.*)
paulson@3121
    66
val parts_induct_tac = 
paulson@3121
    67
    let val tac = forw_inst_tac [("lost","lost")] 
paulson@3121
    68
    in  etac otway.induct	   1 THEN 
paulson@3121
    69
        tac OR4_parts_sees_Spy     6 THEN
paulson@3121
    70
        tac Oops_parts_sees_Spy    7 THEN
paulson@3121
    71
	prove_simple_subgoals_tac  1
paulson@3121
    72
    end;
paulson@2090
    73
paulson@2090
    74
paulson@2090
    75
(** Theorems of the form X ~: parts (sees lost Spy evs) imply that NOBODY
paulson@2090
    76
    sends messages containing X! **)
paulson@2090
    77
paulson@2090
    78
(*Spy never sees another agent's shared key! (unless it's lost at start)*)
paulson@2090
    79
goal thy 
paulson@2131
    80
 "!!evs. evs : otway lost \
paulson@2131
    81
\        ==> (Key (shrK A) : parts (sees lost Spy evs)) = (A : lost)";
paulson@3121
    82
by parts_induct_tac;
paulson@3121
    83
by (Fake_parts_insert_tac 1);
paulson@3121
    84
by (Blast_tac 1);
paulson@2131
    85
qed "Spy_see_shrK";
paulson@2131
    86
Addsimps [Spy_see_shrK];
paulson@2090
    87
paulson@2131
    88
goal thy 
paulson@2131
    89
 "!!evs. evs : otway lost \
paulson@2131
    90
\        ==> (Key (shrK A) : analz (sees lost Spy evs)) = (A : lost)";
paulson@2131
    91
by (auto_tac(!claset addDs [impOfSubs analz_subset_parts], !simpset));
paulson@2131
    92
qed "Spy_analz_shrK";
paulson@2131
    93
Addsimps [Spy_analz_shrK];
paulson@2090
    94
paulson@2131
    95
goal thy  "!!A. [| Key (shrK A) : parts (sees lost Spy evs);       \
paulson@2131
    96
\                  evs : otway lost |] ==> A:lost";
paulson@3102
    97
by (blast_tac (!claset addDs [Spy_see_shrK]) 1);
paulson@2131
    98
qed "Spy_see_shrK_D";
paulson@2090
    99
paulson@2131
   100
bind_thm ("Spy_analz_shrK_D", analz_subset_parts RS subsetD RS Spy_see_shrK_D);
paulson@2131
   101
AddSDs [Spy_see_shrK_D, Spy_analz_shrK_D];
paulson@2090
   102
paulson@2090
   103
paulson@2516
   104
(*Nobody can have used non-existent keys!*)
paulson@2516
   105
goal thy "!!evs. evs : otway lost ==>          \
paulson@2516
   106
\         Key K ~: used evs --> K ~: keysFor (parts (sees lost Spy evs))";
paulson@3121
   107
by parts_induct_tac;
paulson@2516
   108
(*Fake*)
paulson@2516
   109
by (best_tac
paulson@2516
   110
      (!claset addIs [impOfSubs analz_subset_parts]
paulson@2516
   111
               addDs [impOfSubs (analz_subset_parts RS keysFor_mono),
paulson@2516
   112
                      impOfSubs (parts_insert_subset_Un RS keysFor_mono)]
oheimb@3207
   113
               addss (!simpset)) 1);
paulson@2516
   114
(*OR3*)
paulson@3102
   115
by (Blast_tac 1);
paulson@2160
   116
qed_spec_mp "new_keys_not_used";
paulson@2090
   117
paulson@2090
   118
bind_thm ("new_keys_not_analzd",
paulson@2090
   119
          [analz_subset_parts RS keysFor_mono,
paulson@2090
   120
           new_keys_not_used] MRS contra_subsetD);
paulson@2090
   121
paulson@2090
   122
Addsimps [new_keys_not_used, new_keys_not_analzd];
paulson@2090
   123
paulson@2090
   124
paulson@2090
   125
paulson@2090
   126
(*** Proofs involving analz ***)
paulson@2090
   127
paulson@2131
   128
(*Describes the form of K and NA when the Server sends this message.*)
paulson@2090
   129
goal thy 
paulson@2516
   130
 "!!evs. [| Says Server B                                           \
paulson@2516
   131
\              {|Crypt (shrK A) {|NA, Agent A, Agent B, Key K|},    \
paulson@2516
   132
\                Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|}   \
paulson@3466
   133
\             : set evs;                                            \
paulson@2516
   134
\           evs : otway lost |]                                     \
paulson@2516
   135
\        ==> K ~: range shrK & (EX i. NA = Nonce i) & (EX j. NB = Nonce j)";
paulson@2131
   136
by (etac rev_mp 1);
paulson@2131
   137
by (etac otway.induct 1);
paulson@3102
   138
by (ALLGOALS Asm_simp_tac);
paulson@3102
   139
by (Blast_tac 1);
paulson@2131
   140
qed "Says_Server_message_form";
paulson@2090
   141
paulson@2090
   142
paulson@2090
   143
(*For proofs involving analz.  We again instantiate the variable to "lost".*)
paulson@3121
   144
val analz_sees_tac = 
paulson@2090
   145
    dres_inst_tac [("lost","lost")] OR4_analz_sees_Spy 6 THEN
paulson@2131
   146
    forw_inst_tac [("lost","lost")] Says_Server_message_form 7 THEN
paulson@2516
   147
    assume_tac 7 THEN
paulson@2451
   148
    REPEAT ((eresolve_tac [exE, conjE] ORELSE' hyp_subst_tac) 7);
paulson@2090
   149
paulson@2090
   150
paulson@2090
   151
(****
paulson@2090
   152
 The following is to prove theorems of the form
paulson@2090
   153
paulson@2516
   154
  Key K : analz (insert (Key KAB) (sees lost Spy evs)) ==>
paulson@2451
   155
  Key K : analz (sees lost Spy evs)
paulson@2090
   156
paulson@2090
   157
 A more general formula must be proved inductively.
paulson@2090
   158
****)
paulson@2090
   159
paulson@2090
   160
paulson@2090
   161
(** Session keys are not used to encrypt other session keys **)
paulson@2090
   162
paulson@2090
   163
(*The equality makes the induction hypothesis easier to apply*)
paulson@2090
   164
goal thy  
paulson@3466
   165
 "!!evs. evs : otway lost ==>                                    \
paulson@3466
   166
\  ALL K KK. KK <= Compl (range shrK) -->                        \
paulson@3466
   167
\            (Key K : analz (Key``KK Un (sees lost Spy evs))) =  \
paulson@2516
   168
\            (K : KK | Key K : analz (sees lost Spy evs))";
paulson@2090
   169
by (etac otway.induct 1);
paulson@3121
   170
by analz_sees_tac;
paulson@2516
   171
by (REPEAT_FIRST (resolve_tac [allI, impI]));
paulson@2516
   172
by (REPEAT_FIRST (rtac analz_image_freshK_lemma ));
paulson@2516
   173
by (ALLGOALS (asm_simp_tac analz_image_freshK_ss));
paulson@3451
   174
(*Fake*) 
paulson@3451
   175
by (spy_analz_tac 2);
paulson@2516
   176
(*Base*)
paulson@3102
   177
by (Blast_tac 1);
paulson@2516
   178
qed_spec_mp "analz_image_freshK";
paulson@2090
   179
paulson@2090
   180
paulson@2090
   181
goal thy
paulson@3466
   182
 "!!evs. [| evs : otway lost;  KAB ~: range shrK |] ==>          \
paulson@3466
   183
\        Key K : analz (insert (Key KAB) (sees lost Spy evs)) =  \
paulson@2516
   184
\        (K = KAB | Key K : analz (sees lost Spy evs))";
paulson@2516
   185
by (asm_simp_tac (analz_image_freshK_ss addsimps [analz_image_freshK]) 1);
paulson@2516
   186
qed "analz_insert_freshK";
paulson@2090
   187
paulson@2090
   188
paulson@2090
   189
(*** The Key K uniquely identifies the Server's  message. **)
paulson@2090
   190
paulson@2090
   191
goal thy 
paulson@2331
   192
 "!!evs. evs : otway lost ==>                              \
paulson@2090
   193
\      EX A' B' NA' NB'. ALL A B NA NB.                    \
paulson@3466
   194
\       Says Server B                                      \
paulson@3466
   195
\         {|Crypt (shrK A) {|NA, Agent A, Agent B, K|},             \
nipkow@3465
   196
\           Crypt (shrK B) {|NB, Agent A, Agent B, K|}|} : set evs  \
paulson@2090
   197
\       --> A=A' & B=B' & NA=NA' & NB=NB'";
paulson@2090
   198
by (etac otway.induct 1);
paulson@2090
   199
by (ALLGOALS (asm_simp_tac (!simpset addsimps [all_conj_distrib])));
paulson@2090
   200
by (Step_tac 1);
paulson@2090
   201
(*Remaining cases: OR3 and OR4*)
paulson@2090
   202
by (ex_strip_tac 2);
paulson@3102
   203
by (Blast_tac 2);
paulson@2090
   204
by (expand_case_tac "K = ?y" 1);
paulson@2090
   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] (*prevent splitup into 4 subgoals*)) 1);
paulson@2090
   209
val lemma = result();
paulson@2090
   210
paulson@2090
   211
paulson@2090
   212
goal thy 
paulson@2090
   213
"!!evs. [| Says Server B                                           \
paulson@2284
   214
\            {|Crypt (shrK A) {|NA, Agent A, Agent B, K|},         \
paulson@2284
   215
\              Crypt (shrK B) {|NB, Agent A, Agent B, K|}|}        \
paulson@3466
   216
\           : set evs;                                             \
paulson@2090
   217
\          Says Server B'                                          \
paulson@2284
   218
\            {|Crypt (shrK A') {|NA', Agent A', Agent B', K|},     \
paulson@2284
   219
\              Crypt (shrK B') {|NB', Agent A', Agent B', K|}|}    \
paulson@3466
   220
\           : set evs;                                             \
paulson@2090
   221
\          evs : otway lost |]                                     \
paulson@2090
   222
\       ==> A=A' & B=B' & NA=NA' & NB=NB'";
paulson@2417
   223
by (prove_unique_tac lemma 1);
paulson@2090
   224
qed "unique_session_keys";
paulson@2090
   225
paulson@2090
   226
paulson@2090
   227
paulson@2090
   228
(**** Authenticity properties relating to NA ****)
paulson@2090
   229
paulson@2090
   230
(*If the encrypted message appears then it originated with the Server!*)
paulson@2090
   231
goal thy 
paulson@2090
   232
 "!!evs. [| A ~: lost;  evs : otway lost |]                 \
paulson@2284
   233
\ ==> Crypt (shrK A) {|NA, Agent A, Agent B, Key K|}        \
paulson@2090
   234
\      : parts (sees lost Spy evs)                          \
paulson@2331
   235
\     --> (EX NB. Says Server B                                          \
paulson@2284
   236
\                  {|Crypt (shrK A) {|NA, Agent A, Agent B, Key K|},     \
paulson@2284
   237
\                    Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|}    \
nipkow@3465
   238
\                  : set evs)";
paulson@3121
   239
by parts_induct_tac;
paulson@3121
   240
by (Fake_parts_insert_tac 1);
paulson@2090
   241
by (ALLGOALS (asm_simp_tac (!simpset addsimps [ex_disj_distrib])));
paulson@2090
   242
(*OR3*)
paulson@3102
   243
by (Blast_tac 1);
paulson@2090
   244
qed_spec_mp "NA_Crypt_imp_Server_msg";
paulson@2090
   245
paulson@2090
   246
paulson@2454
   247
(*Corollary: if A receives B's OR4 message then it originated with the Server.
paulson@2454
   248
  Freshness may be inferred from nonce NA.*)
paulson@2090
   249
goal thy 
paulson@2284
   250
 "!!evs. [| Says B' A (Crypt (shrK A) {|NA, Agent A, Agent B, Key K|})  \
paulson@3466
   251
\            : set evs;                                                 \
paulson@2090
   252
\           A ~: lost;  evs : otway lost |]                             \
paulson@2090
   253
\        ==> EX NB. Says Server B                                       \
paulson@2284
   254
\                    {|Crypt (shrK A) {|NA, Agent A, Agent B, Key K|},  \
paulson@2284
   255
\                      Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|} \
nipkow@3465
   256
\                   : set evs";
paulson@3102
   257
by (blast_tac (!claset addSIs [NA_Crypt_imp_Server_msg]
paulson@2516
   258
                      addEs  sees_Spy_partsEs) 1);
paulson@2331
   259
qed "A_trusts_OR4";
paulson@2090
   260
paulson@2090
   261
paulson@2090
   262
(** Crucial secrecy property: Spy does not see the keys sent in msg OR3
paulson@2090
   263
    Does not in itself guarantee security: an attack could violate 
paulson@2090
   264
    the premises, e.g. by having A=Spy **)
paulson@2090
   265
paulson@2090
   266
goal thy 
paulson@2166
   267
 "!!evs. [| A ~: lost;  B ~: lost;  evs : otway lost |]                    \
paulson@2090
   268
\        ==> Says Server B                                                 \
paulson@2284
   269
\             {|Crypt (shrK A) {|NA, Agent A, Agent B, Key K|},            \
paulson@2284
   270
\               Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|}           \
paulson@3466
   271
\            : set evs -->                                                 \
paulson@3466
   272
\            Says B Spy {|NA, NB, Key K|} ~: set evs -->                   \
paulson@2090
   273
\            Key K ~: analz (sees lost Spy evs)";
paulson@2090
   274
by (etac otway.induct 1);
paulson@3121
   275
by analz_sees_tac;
paulson@2090
   276
by (ALLGOALS
paulson@2516
   277
    (asm_simp_tac (!simpset addcongs [conj_cong] 
paulson@3451
   278
                            addsimps [analz_insert_eq, not_parts_not_analz, 
paulson@3451
   279
				      analz_insert_freshK]
paulson@2516
   280
                            setloop split_tac [expand_if])));
paulson@3451
   281
(*Oops*)
paulson@3451
   282
by (blast_tac (!claset addSDs [unique_session_keys]) 4);
paulson@3451
   283
(*OR4*) 
paulson@3451
   284
by (Blast_tac 3);
paulson@2090
   285
(*OR3*)
paulson@3102
   286
by (blast_tac (!claset addSEs sees_Spy_partsEs
paulson@3102
   287
                       addIs [impOfSubs analz_subset_parts]) 2);
paulson@3451
   288
(*Fake*) 
paulson@3451
   289
by (spy_analz_tac 1);
paulson@2090
   290
val lemma = result() RS mp RS mp RSN(2,rev_notE);
paulson@2090
   291
paulson@2090
   292
goal thy 
paulson@2516
   293
 "!!evs. [| Says Server B                                           \
paulson@2516
   294
\              {|Crypt (shrK A) {|NA, Agent A, Agent B, Key K|},    \
paulson@2516
   295
\                Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|}   \
paulson@3466
   296
\             : set evs;                                            \
paulson@3466
   297
\           Says B Spy {|NA, NB, Key K|} ~: set evs;                \
paulson@2516
   298
\           A ~: lost;  B ~: lost;  evs : otway lost |]             \
paulson@2516
   299
\        ==> Key K ~: analz (sees lost Spy evs)";
paulson@2090
   300
by (forward_tac [Says_Server_message_form] 1 THEN assume_tac 1);
paulson@2891
   301
by (blast_tac (!claset addSEs [lemma]) 1);
paulson@2090
   302
qed "Spy_not_see_encrypted_key";
paulson@2090
   303
paulson@2090
   304
paulson@2090
   305
(**** Authenticity properties relating to NB ****)
paulson@2090
   306
paulson@2090
   307
(*If the encrypted message appears then it originated with the Server!*)
paulson@2090
   308
goal thy 
paulson@2106
   309
 "!!evs. [| B ~: lost;  evs : otway lost |]                                 \
paulson@2284
   310
\    ==> Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}                     \
paulson@2106
   311
\         : parts (sees lost Spy evs)                                       \
paulson@2090
   312
\        --> (EX NA. Says Server B                                          \
paulson@2284
   313
\                     {|Crypt (shrK A) {|NA, Agent A, Agent B, Key K|},     \
paulson@2284
   314
\                       Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|}    \
nipkow@3465
   315
\                     : set evs)";
paulson@3121
   316
by parts_induct_tac;
paulson@3121
   317
by (Fake_parts_insert_tac 1);
paulson@2090
   318
by (ALLGOALS (asm_simp_tac (!simpset addsimps [ex_disj_distrib])));
paulson@2090
   319
(*OR3*)
paulson@3102
   320
by (Blast_tac 1);
paulson@2090
   321
qed_spec_mp "NB_Crypt_imp_Server_msg";
paulson@2090
   322
paulson@2090
   323
paulson@2454
   324
(*Guarantee for B: if it gets a well-formed certificate then the Server
paulson@2454
   325
  has sent the correct message in round 3.*)
paulson@2090
   326
goal thy 
paulson@2106
   327
 "!!evs. [| B ~: lost;  evs : otway lost;                                   \
paulson@2837
   328
\           Says S' B {|X, Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|} \
paulson@3466
   329
\            : set evs |]                                                   \
paulson@2106
   330
\        ==> EX NA. Says Server B                                           \
paulson@2284
   331
\                     {|Crypt (shrK A) {|NA, Agent A, Agent B, Key K|},     \
paulson@2284
   332
\                       Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|}    \
nipkow@3465
   333
\                     : set evs";
paulson@3102
   334
by (blast_tac (!claset addSIs [NB_Crypt_imp_Server_msg]
paulson@3102
   335
                       addEs  sees_Spy_partsEs) 1);
paulson@2331
   336
qed "B_trusts_OR3";