src/HOL/Auth/OtwayRees_AN.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@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@3543
    24
\        ==> EX K. EX NA. EX evs: otway.                                      \
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*)
paulson@3519
    36
goal thy "!!evs. evs : otway ==> 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@3519
    47
\                X : analz (sees 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|}|} \
paulson@3519
    52
\                  : set evs ==> K : parts (sees 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@3519
    63
(*For proving the easier theorems about X ~: parts (sees Spy evs).*)
paulson@3519
    64
fun parts_induct_tac i = 
paulson@3519
    65
    etac otway.induct i			THEN 
paulson@3519
    66
    forward_tac [Oops_parts_sees_Spy] (i+6) THEN
paulson@3519
    67
    forward_tac [OR4_parts_sees_Spy]  (i+5) THEN
paulson@3519
    68
    prove_simple_subgoals_tac  i;
paulson@2090
    69
paulson@2090
    70
paulson@3519
    71
(** Theorems of the form X ~: parts (sees Spy evs) imply that NOBODY
paulson@2090
    72
    sends messages containing X! **)
paulson@2090
    73
paulson@2090
    74
(*Spy never sees another agent's shared key! (unless it's lost at start)*)
paulson@2090
    75
goal thy 
paulson@3519
    76
 "!!evs. evs : otway ==> (Key (shrK A) : parts (sees Spy evs)) = (A : lost)";
paulson@3519
    77
by (parts_induct_tac 1);
paulson@3121
    78
by (Fake_parts_insert_tac 1);
paulson@3121
    79
by (Blast_tac 1);
paulson@2131
    80
qed "Spy_see_shrK";
paulson@2131
    81
Addsimps [Spy_see_shrK];
paulson@2090
    82
paulson@2131
    83
goal thy 
paulson@3519
    84
 "!!evs. evs : otway ==> (Key (shrK A) : analz (sees Spy evs)) = (A : lost)";
paulson@2131
    85
by (auto_tac(!claset addDs [impOfSubs analz_subset_parts], !simpset));
paulson@2131
    86
qed "Spy_analz_shrK";
paulson@2131
    87
Addsimps [Spy_analz_shrK];
paulson@2090
    88
paulson@3519
    89
goal thy  "!!A. [| Key (shrK A) : parts (sees Spy evs);       \
paulson@3519
    90
\                  evs : otway |] ==> A:lost";
paulson@3102
    91
by (blast_tac (!claset addDs [Spy_see_shrK]) 1);
paulson@2131
    92
qed "Spy_see_shrK_D";
paulson@2090
    93
paulson@2131
    94
bind_thm ("Spy_analz_shrK_D", analz_subset_parts RS subsetD RS Spy_see_shrK_D);
paulson@2131
    95
AddSDs [Spy_see_shrK_D, Spy_analz_shrK_D];
paulson@2090
    96
paulson@2090
    97
paulson@2516
    98
(*Nobody can have used non-existent keys!*)
paulson@3519
    99
goal thy "!!evs. evs : otway ==>          \
paulson@3519
   100
\         Key K ~: used evs --> K ~: keysFor (parts (sees Spy evs))";
paulson@3519
   101
by (parts_induct_tac 1);
paulson@2516
   102
(*Fake*)
paulson@2516
   103
by (best_tac
paulson@2516
   104
      (!claset addIs [impOfSubs analz_subset_parts]
paulson@2516
   105
               addDs [impOfSubs (analz_subset_parts RS keysFor_mono),
paulson@2516
   106
                      impOfSubs (parts_insert_subset_Un RS keysFor_mono)]
oheimb@3207
   107
               addss (!simpset)) 1);
paulson@2516
   108
(*OR3*)
paulson@3102
   109
by (Blast_tac 1);
paulson@2160
   110
qed_spec_mp "new_keys_not_used";
paulson@2090
   111
paulson@2090
   112
bind_thm ("new_keys_not_analzd",
paulson@2090
   113
          [analz_subset_parts RS keysFor_mono,
paulson@2090
   114
           new_keys_not_used] MRS contra_subsetD);
paulson@2090
   115
paulson@2090
   116
Addsimps [new_keys_not_used, new_keys_not_analzd];
paulson@2090
   117
paulson@2090
   118
paulson@2090
   119
paulson@2090
   120
(*** Proofs involving analz ***)
paulson@2090
   121
paulson@2131
   122
(*Describes the form of K and NA when the Server sends this message.*)
paulson@2090
   123
goal thy 
paulson@2516
   124
 "!!evs. [| Says Server B                                           \
paulson@2516
   125
\              {|Crypt (shrK A) {|NA, Agent A, Agent B, Key K|},    \
paulson@2516
   126
\                Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|}   \
paulson@3466
   127
\             : set evs;                                            \
paulson@3543
   128
\           evs : otway |]                                          \
paulson@2516
   129
\        ==> K ~: range shrK & (EX i. NA = Nonce i) & (EX j. NB = Nonce j)";
paulson@2131
   130
by (etac rev_mp 1);
paulson@2131
   131
by (etac otway.induct 1);
paulson@3102
   132
by (ALLGOALS Asm_simp_tac);
paulson@3102
   133
by (Blast_tac 1);
paulson@2131
   134
qed "Says_Server_message_form";
paulson@2090
   135
paulson@2090
   136
paulson@3519
   137
(*For proofs involving analz.*)
paulson@3121
   138
val analz_sees_tac = 
paulson@3519
   139
    dtac OR4_analz_sees_Spy 6 THEN
paulson@3519
   140
    forward_tac [Says_Server_message_form] 7 THEN
paulson@2516
   141
    assume_tac 7 THEN
paulson@2451
   142
    REPEAT ((eresolve_tac [exE, conjE] ORELSE' hyp_subst_tac) 7);
paulson@2090
   143
paulson@2090
   144
paulson@2090
   145
(****
paulson@2090
   146
 The following is to prove theorems of the form
paulson@2090
   147
paulson@3519
   148
  Key K : analz (insert (Key KAB) (sees Spy evs)) ==>
paulson@3519
   149
  Key K : analz (sees Spy evs)
paulson@2090
   150
paulson@2090
   151
 A more general formula must be proved inductively.
paulson@2090
   152
****)
paulson@2090
   153
paulson@2090
   154
paulson@2090
   155
(** Session keys are not used to encrypt other session keys **)
paulson@2090
   156
paulson@2090
   157
(*The equality makes the induction hypothesis easier to apply*)
paulson@2090
   158
goal thy  
paulson@3519
   159
 "!!evs. evs : otway ==>                                    \
paulson@3519
   160
\  ALL K KK. KK <= Compl (range shrK) -->                   \
paulson@3519
   161
\            (Key K : analz (Key``KK Un (sees Spy evs))) =  \
paulson@3519
   162
\            (K : KK | Key K : analz (sees Spy evs))";
paulson@2090
   163
by (etac otway.induct 1);
paulson@3121
   164
by analz_sees_tac;
paulson@2516
   165
by (REPEAT_FIRST (resolve_tac [allI, impI]));
paulson@2516
   166
by (REPEAT_FIRST (rtac analz_image_freshK_lemma ));
paulson@2516
   167
by (ALLGOALS (asm_simp_tac analz_image_freshK_ss));
paulson@3451
   168
(*Fake*) 
paulson@3451
   169
by (spy_analz_tac 2);
paulson@2516
   170
(*Base*)
paulson@3102
   171
by (Blast_tac 1);
paulson@2516
   172
qed_spec_mp "analz_image_freshK";
paulson@2090
   173
paulson@2090
   174
paulson@2090
   175
goal thy
paulson@3519
   176
 "!!evs. [| evs : otway;  KAB ~: range shrK |] ==>          \
paulson@3519
   177
\        Key K : analz (insert (Key KAB) (sees Spy evs)) =  \
paulson@3519
   178
\        (K = KAB | Key K : analz (sees Spy evs))";
paulson@2516
   179
by (asm_simp_tac (analz_image_freshK_ss addsimps [analz_image_freshK]) 1);
paulson@2516
   180
qed "analz_insert_freshK";
paulson@2090
   181
paulson@2090
   182
paulson@2090
   183
(*** The Key K uniquely identifies the Server's  message. **)
paulson@2090
   184
paulson@2090
   185
goal thy 
paulson@3543
   186
 "!!evs. evs : otway ==>                                            \
paulson@3543
   187
\      EX A' B' NA' NB'. ALL A B NA NB.                             \
paulson@3543
   188
\       Says Server B                                               \
paulson@3466
   189
\         {|Crypt (shrK A) {|NA, Agent A, Agent B, K|},             \
nipkow@3465
   190
\           Crypt (shrK B) {|NB, Agent A, Agent B, K|}|} : set evs  \
paulson@2090
   191
\       --> A=A' & B=B' & NA=NA' & NB=NB'";
paulson@2090
   192
by (etac otway.induct 1);
paulson@2090
   193
by (ALLGOALS (asm_simp_tac (!simpset addsimps [all_conj_distrib])));
paulson@2090
   194
by (Step_tac 1);
paulson@2090
   195
(*Remaining cases: OR3 and OR4*)
paulson@2090
   196
by (ex_strip_tac 2);
paulson@3102
   197
by (Blast_tac 2);
paulson@2090
   198
by (expand_case_tac "K = ?y" 1);
paulson@2090
   199
by (REPEAT (ares_tac [refl,exI,impI,conjI] 2));
paulson@2516
   200
(*...we assume X is a recent message and handle this case by contradiction*)
paulson@3102
   201
by (blast_tac (!claset addSEs sees_Spy_partsEs
paulson@3102
   202
                       delrules[conjI] (*prevent splitup into 4 subgoals*)) 1);
paulson@2090
   203
val lemma = result();
paulson@2090
   204
paulson@2090
   205
paulson@2090
   206
goal thy 
paulson@2090
   207
"!!evs. [| Says Server B                                           \
paulson@2284
   208
\            {|Crypt (shrK A) {|NA, Agent A, Agent B, K|},         \
paulson@2284
   209
\              Crypt (shrK B) {|NB, Agent A, Agent B, K|}|}        \
paulson@3466
   210
\           : set evs;                                             \
paulson@2090
   211
\          Says Server B'                                          \
paulson@2284
   212
\            {|Crypt (shrK A') {|NA', Agent A', Agent B', K|},     \
paulson@2284
   213
\              Crypt (shrK B') {|NB', Agent A', Agent B', K|}|}    \
paulson@3466
   214
\           : set evs;                                             \
paulson@3519
   215
\          evs : otway |]                                          \
paulson@2090
   216
\       ==> A=A' & B=B' & NA=NA' & NB=NB'";
paulson@2417
   217
by (prove_unique_tac lemma 1);
paulson@2090
   218
qed "unique_session_keys";
paulson@2090
   219
paulson@2090
   220
paulson@2090
   221
paulson@2090
   222
(**** Authenticity properties relating to NA ****)
paulson@2090
   223
paulson@2090
   224
(*If the encrypted message appears then it originated with the Server!*)
paulson@2090
   225
goal thy 
paulson@3519
   226
 "!!evs. [| A ~: lost;  evs : otway |]                 \
paulson@3519
   227
\ ==> Crypt (shrK A) {|NA, Agent A, Agent B, Key K|}   \
paulson@3519
   228
\      : parts (sees Spy evs)                          \
paulson@2331
   229
\     --> (EX NB. Says Server B                                          \
paulson@2284
   230
\                  {|Crypt (shrK A) {|NA, Agent A, Agent B, Key K|},     \
paulson@2284
   231
\                    Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|}    \
nipkow@3465
   232
\                  : set evs)";
paulson@3519
   233
by (parts_induct_tac 1);
paulson@3121
   234
by (Fake_parts_insert_tac 1);
paulson@2090
   235
by (ALLGOALS (asm_simp_tac (!simpset addsimps [ex_disj_distrib])));
paulson@2090
   236
(*OR3*)
paulson@3102
   237
by (Blast_tac 1);
paulson@2090
   238
qed_spec_mp "NA_Crypt_imp_Server_msg";
paulson@2090
   239
paulson@2090
   240
paulson@2454
   241
(*Corollary: if A receives B's OR4 message then it originated with the Server.
paulson@2454
   242
  Freshness may be inferred from nonce NA.*)
paulson@2090
   243
goal thy 
paulson@2284
   244
 "!!evs. [| Says B' A (Crypt (shrK A) {|NA, Agent A, Agent B, Key K|})  \
paulson@3466
   245
\            : set evs;                                                 \
paulson@3519
   246
\           A ~: lost;  evs : otway |]                                  \
paulson@2090
   247
\        ==> EX NB. Says Server B                                       \
paulson@2284
   248
\                    {|Crypt (shrK A) {|NA, Agent A, Agent B, Key K|},  \
paulson@2284
   249
\                      Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|} \
nipkow@3465
   250
\                   : set evs";
paulson@3102
   251
by (blast_tac (!claset addSIs [NA_Crypt_imp_Server_msg]
paulson@2516
   252
                      addEs  sees_Spy_partsEs) 1);
paulson@2331
   253
qed "A_trusts_OR4";
paulson@2090
   254
paulson@2090
   255
paulson@2090
   256
(** Crucial secrecy property: Spy does not see the keys sent in msg OR3
paulson@2090
   257
    Does not in itself guarantee security: an attack could violate 
paulson@2090
   258
    the premises, e.g. by having A=Spy **)
paulson@2090
   259
paulson@2090
   260
goal thy 
paulson@3543
   261
 "!!evs. [| A ~: lost;  B ~: lost;  evs : otway |]                 \
paulson@3543
   262
\        ==> Says Server B                                         \
paulson@3543
   263
\             {|Crypt (shrK A) {|NA, Agent A, Agent B, Key K|},    \
paulson@3543
   264
\               Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|}   \
paulson@3543
   265
\            : set evs -->                                         \
paulson@3543
   266
\            Says B Spy {|NA, NB, Key K|} ~: set evs -->           \
paulson@3519
   267
\            Key K ~: analz (sees Spy evs)";
paulson@2090
   268
by (etac otway.induct 1);
paulson@3121
   269
by analz_sees_tac;
paulson@2090
   270
by (ALLGOALS
paulson@2516
   271
    (asm_simp_tac (!simpset addcongs [conj_cong] 
paulson@3451
   272
                            addsimps [analz_insert_eq, not_parts_not_analz, 
paulson@3451
   273
				      analz_insert_freshK]
paulson@2516
   274
                            setloop split_tac [expand_if])));
paulson@3451
   275
(*Oops*)
paulson@3451
   276
by (blast_tac (!claset addSDs [unique_session_keys]) 4);
paulson@3451
   277
(*OR4*) 
paulson@3451
   278
by (Blast_tac 3);
paulson@2090
   279
(*OR3*)
paulson@3102
   280
by (blast_tac (!claset addSEs sees_Spy_partsEs
paulson@3102
   281
                       addIs [impOfSubs analz_subset_parts]) 2);
paulson@3451
   282
(*Fake*) 
paulson@3451
   283
by (spy_analz_tac 1);
paulson@2090
   284
val lemma = result() RS mp RS mp RSN(2,rev_notE);
paulson@2090
   285
paulson@2090
   286
goal thy 
paulson@2516
   287
 "!!evs. [| Says Server B                                           \
paulson@2516
   288
\              {|Crypt (shrK A) {|NA, Agent A, Agent B, Key K|},    \
paulson@2516
   289
\                Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|}   \
paulson@3466
   290
\             : set evs;                                            \
paulson@3466
   291
\           Says B Spy {|NA, NB, Key K|} ~: set evs;                \
paulson@3519
   292
\           A ~: lost;  B ~: lost;  evs : otway |]                  \
paulson@3519
   293
\        ==> Key K ~: analz (sees Spy evs)";
paulson@2090
   294
by (forward_tac [Says_Server_message_form] 1 THEN assume_tac 1);
paulson@2891
   295
by (blast_tac (!claset addSEs [lemma]) 1);
paulson@2090
   296
qed "Spy_not_see_encrypted_key";
paulson@2090
   297
paulson@2090
   298
paulson@2090
   299
(**** Authenticity properties relating to NB ****)
paulson@2090
   300
paulson@2090
   301
(*If the encrypted message appears then it originated with the Server!*)
paulson@2090
   302
goal thy 
paulson@3519
   303
 "!!evs. [| B ~: lost;  evs : otway |]                                 \
paulson@3519
   304
\    ==> Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}                \
paulson@3519
   305
\         : parts (sees Spy evs)                                       \
paulson@2090
   306
\        --> (EX NA. Says Server B                                          \
paulson@2284
   307
\                     {|Crypt (shrK A) {|NA, Agent A, Agent B, Key K|},     \
paulson@2284
   308
\                       Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|}    \
nipkow@3465
   309
\                     : set evs)";
paulson@3519
   310
by (parts_induct_tac 1);
paulson@3121
   311
by (Fake_parts_insert_tac 1);
paulson@2090
   312
by (ALLGOALS (asm_simp_tac (!simpset addsimps [ex_disj_distrib])));
paulson@2090
   313
(*OR3*)
paulson@3102
   314
by (Blast_tac 1);
paulson@2090
   315
qed_spec_mp "NB_Crypt_imp_Server_msg";
paulson@2090
   316
paulson@2090
   317
paulson@2454
   318
(*Guarantee for B: if it gets a well-formed certificate then the Server
paulson@2454
   319
  has sent the correct message in round 3.*)
paulson@2090
   320
goal thy 
paulson@3519
   321
 "!!evs. [| B ~: lost;  evs : otway;                                        \
paulson@2837
   322
\           Says S' B {|X, Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|} \
paulson@3466
   323
\            : set evs |]                                                   \
paulson@2106
   324
\        ==> EX NA. Says Server B                                           \
paulson@2284
   325
\                     {|Crypt (shrK A) {|NA, Agent A, Agent B, Key K|},     \
paulson@2284
   326
\                       Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|}    \
nipkow@3465
   327
\                     : set evs";
paulson@3102
   328
by (blast_tac (!claset addSIs [NB_Crypt_imp_Server_msg]
paulson@3102
   329
                       addEs  sees_Spy_partsEs) 1);
paulson@2331
   330
qed "B_trusts_OR3";