src/HOL/Auth/OtwayRees_AN.ML
author paulson
Thu Jan 08 18:10:34 1998 +0100 (1998-01-08)
changeset 4537 4e835bd9fada
parent 4509 828148415197
child 4598 649bf14debe7
permissions -rw-r--r--
Expressed most Oops rules using Notes instead of Says, and other tidying
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
wenzelm@4449
    17
set proof_timing;
paulson@2090
    18
HOL_quantifiers := false;
paulson@2090
    19
paulson@4470
    20
AddEs spies_partsEs;
paulson@4470
    21
AddDs [impOfSubs analz_subset_parts];
paulson@4470
    22
AddDs [impOfSubs Fake_parts_insert];
paulson@4470
    23
paulson@2090
    24
paulson@2331
    25
(*A "possibility property": there are traces that reach the end*)
paulson@2090
    26
goal thy 
paulson@2331
    27
 "!!A B. [| A ~= B; A ~= Server; B ~= Server |]                               \
paulson@3543
    28
\        ==> EX K. EX NA. EX evs: otway.                                      \
paulson@2284
    29
\             Says B A (Crypt (shrK A) {|Nonce NA, Agent A, Agent B, Key K|}) \
nipkow@3465
    30
\             : set evs";
paulson@2090
    31
by (REPEAT (resolve_tac [exI,bexI] 1));
paulson@2090
    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@2090
    34
result();
paulson@2090
    35
paulson@2090
    36
paulson@2090
    37
(**** Inductive proofs about otway ****)
paulson@2090
    38
paulson@2090
    39
(*Nobody sends themselves messages*)
paulson@3519
    40
goal thy "!!evs. evs : otway ==> ALL A X. Says A A X ~: set evs";
paulson@2090
    41
by (etac otway.induct 1);
paulson@4477
    42
by Auto_tac;
paulson@2090
    43
qed_spec_mp "not_Says_to_self";
paulson@2090
    44
Addsimps [not_Says_to_self];
paulson@2090
    45
AddSEs   [not_Says_to_self RSN (2, rev_notE)];
paulson@2090
    46
paulson@2090
    47
paulson@2090
    48
(** For reasoning about the encrypted portion of messages **)
paulson@2090
    49
nipkow@3465
    50
goal thy "!!evs. Says S' B {|X, Crypt(shrK B) X'|} : set evs ==> \
paulson@3683
    51
\                X : analz (spies evs)";
paulson@4477
    52
by (dtac (Says_imp_spies RS analz.Inj) 1);
paulson@4470
    53
by (Blast_tac 1);
paulson@3683
    54
qed "OR4_analz_spies";
paulson@2090
    55
paulson@2284
    56
goal thy "!!evs. Says Server B {|X, Crypt K' {|NB, a, Agent B, K|}|} \
paulson@3683
    57
\                  : set evs ==> K : parts (spies evs)";
paulson@4470
    58
by (Blast_tac 1);
paulson@3683
    59
qed "Oops_parts_spies";
paulson@2090
    60
paulson@3683
    61
bind_thm ("OR4_parts_spies",
paulson@3683
    62
          OR4_analz_spies RS (impOfSubs analz_subset_parts));
paulson@2090
    63
paulson@3683
    64
(*For proving the easier theorems about X ~: parts (spies evs).*)
paulson@3519
    65
fun parts_induct_tac i = 
paulson@3519
    66
    etac otway.induct i			THEN 
paulson@3683
    67
    forward_tac [Oops_parts_spies] (i+6) THEN
paulson@3683
    68
    forward_tac [OR4_parts_spies]  (i+5) THEN
paulson@3519
    69
    prove_simple_subgoals_tac  i;
paulson@2090
    70
paulson@2090
    71
paulson@3683
    72
(** Theorems of the form X ~: parts (spies evs) imply that NOBODY
paulson@2090
    73
    sends messages containing X! **)
paulson@2090
    74
paulson@4537
    75
(*Spy never sees a good agent's shared key!*)
paulson@2090
    76
goal thy 
paulson@3683
    77
 "!!evs. evs : otway ==> (Key (shrK A) : parts (spies evs)) = (A : bad)";
paulson@3519
    78
by (parts_induct_tac 1);
paulson@3961
    79
by (ALLGOALS Blast_tac);
paulson@2131
    80
qed "Spy_see_shrK";
paulson@2131
    81
Addsimps [Spy_see_shrK];
paulson@2090
    82
paulson@2131
    83
goal thy 
paulson@3683
    84
 "!!evs. evs : otway ==> (Key (shrK A) : analz (spies evs)) = (A : bad)";
wenzelm@4091
    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@4470
    89
AddSDs [Spy_see_shrK RSN (2, rev_iffD1), 
paulson@4470
    90
	Spy_analz_shrK RSN (2, rev_iffD1)];
paulson@2090
    91
paulson@2090
    92
paulson@2516
    93
(*Nobody can have used non-existent keys!*)
paulson@3519
    94
goal thy "!!evs. evs : otway ==>          \
paulson@3683
    95
\         Key K ~: used evs --> K ~: keysFor (parts (spies evs))";
paulson@3519
    96
by (parts_induct_tac 1);
paulson@2516
    97
(*Fake*)
paulson@4509
    98
by (blast_tac (claset() addSDs [keysFor_parts_insert]) 1);
paulson@2516
    99
(*OR3*)
paulson@3102
   100
by (Blast_tac 1);
paulson@2160
   101
qed_spec_mp "new_keys_not_used";
paulson@2090
   102
paulson@2090
   103
bind_thm ("new_keys_not_analzd",
paulson@2090
   104
          [analz_subset_parts RS keysFor_mono,
paulson@2090
   105
           new_keys_not_used] MRS contra_subsetD);
paulson@2090
   106
paulson@2090
   107
Addsimps [new_keys_not_used, new_keys_not_analzd];
paulson@2090
   108
paulson@2090
   109
paulson@2090
   110
paulson@2090
   111
(*** Proofs involving analz ***)
paulson@2090
   112
paulson@2131
   113
(*Describes the form of K and NA when the Server sends this message.*)
paulson@2090
   114
goal thy 
paulson@2516
   115
 "!!evs. [| Says Server B                                           \
paulson@2516
   116
\              {|Crypt (shrK A) {|NA, Agent A, Agent B, Key K|},    \
paulson@2516
   117
\                Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|}   \
paulson@3466
   118
\             : set evs;                                            \
paulson@3543
   119
\           evs : otway |]                                          \
paulson@2516
   120
\        ==> K ~: range shrK & (EX i. NA = Nonce i) & (EX j. NB = Nonce j)";
paulson@2131
   121
by (etac rev_mp 1);
paulson@2131
   122
by (etac otway.induct 1);
paulson@3102
   123
by (ALLGOALS Asm_simp_tac);
paulson@3102
   124
by (Blast_tac 1);
paulson@2131
   125
qed "Says_Server_message_form";
paulson@2090
   126
paulson@2090
   127
paulson@3519
   128
(*For proofs involving analz.*)
paulson@3683
   129
val analz_spies_tac = 
paulson@3683
   130
    dtac OR4_analz_spies 6 THEN
paulson@3519
   131
    forward_tac [Says_Server_message_form] 7 THEN
paulson@2516
   132
    assume_tac 7 THEN
paulson@2451
   133
    REPEAT ((eresolve_tac [exE, conjE] ORELSE' hyp_subst_tac) 7);
paulson@2090
   134
paulson@2090
   135
paulson@2090
   136
(****
paulson@2090
   137
 The following is to prove theorems of the form
paulson@2090
   138
paulson@3683
   139
  Key K : analz (insert (Key KAB) (spies evs)) ==>
paulson@3683
   140
  Key K : analz (spies evs)
paulson@2090
   141
paulson@2090
   142
 A more general formula must be proved inductively.
paulson@2090
   143
****)
paulson@2090
   144
paulson@2090
   145
paulson@2090
   146
(** Session keys are not used to encrypt other session keys **)
paulson@2090
   147
paulson@2090
   148
(*The equality makes the induction hypothesis easier to apply*)
paulson@2090
   149
goal thy  
paulson@3519
   150
 "!!evs. evs : otway ==>                                    \
paulson@3519
   151
\  ALL K KK. KK <= Compl (range shrK) -->                   \
paulson@3683
   152
\            (Key K : analz (Key``KK Un (spies evs))) =  \
paulson@3683
   153
\            (K : KK | Key K : analz (spies evs))";
paulson@2090
   154
by (etac otway.induct 1);
paulson@3683
   155
by analz_spies_tac;
paulson@2516
   156
by (REPEAT_FIRST (resolve_tac [allI, impI]));
paulson@2516
   157
by (REPEAT_FIRST (rtac analz_image_freshK_lemma ));
paulson@2516
   158
by (ALLGOALS (asm_simp_tac analz_image_freshK_ss));
paulson@3451
   159
(*Fake*) 
paulson@4422
   160
by (spy_analz_tac 1);
paulson@2516
   161
qed_spec_mp "analz_image_freshK";
paulson@2090
   162
paulson@2090
   163
paulson@2090
   164
goal thy
paulson@3519
   165
 "!!evs. [| evs : otway;  KAB ~: range shrK |] ==>          \
paulson@3683
   166
\        Key K : analz (insert (Key KAB) (spies evs)) =  \
paulson@3683
   167
\        (K = KAB | Key K : analz (spies evs))";
paulson@2516
   168
by (asm_simp_tac (analz_image_freshK_ss addsimps [analz_image_freshK]) 1);
paulson@2516
   169
qed "analz_insert_freshK";
paulson@2090
   170
paulson@2090
   171
paulson@4155
   172
(*** The Key K uniquely identifies the Server's message. **)
paulson@2090
   173
paulson@2090
   174
goal thy 
paulson@3543
   175
 "!!evs. evs : otway ==>                                            \
paulson@3543
   176
\      EX A' B' NA' NB'. ALL A B NA NB.                             \
paulson@3543
   177
\       Says Server B                                               \
paulson@3466
   178
\         {|Crypt (shrK A) {|NA, Agent A, Agent B, K|},             \
nipkow@3465
   179
\           Crypt (shrK B) {|NB, Agent A, Agent B, K|}|} : set evs  \
paulson@2090
   180
\       --> A=A' & B=B' & NA=NA' & NB=NB'";
paulson@2090
   181
by (etac otway.induct 1);
wenzelm@4091
   182
by (ALLGOALS (asm_simp_tac (simpset() addsimps [all_conj_distrib])));
paulson@3730
   183
by (ALLGOALS Clarify_tac);
paulson@2090
   184
(*Remaining cases: OR3 and OR4*)
paulson@2090
   185
by (ex_strip_tac 2);
paulson@3102
   186
by (Blast_tac 2);
paulson@2090
   187
by (expand_case_tac "K = ?y" 1);
paulson@2090
   188
by (REPEAT (ares_tac [refl,exI,impI,conjI] 2));
paulson@2516
   189
(*...we assume X is a recent message and handle this case by contradiction*)
paulson@4509
   190
by (blast_tac (claset() addSEs spies_partsEs) 1);
paulson@2090
   191
val lemma = result();
paulson@2090
   192
paulson@2090
   193
paulson@2090
   194
goal thy 
paulson@2090
   195
"!!evs. [| Says Server B                                           \
paulson@2284
   196
\            {|Crypt (shrK A) {|NA, Agent A, Agent B, K|},         \
paulson@2284
   197
\              Crypt (shrK B) {|NB, Agent A, Agent B, K|}|}        \
paulson@3466
   198
\           : set evs;                                             \
paulson@2090
   199
\          Says Server B'                                          \
paulson@2284
   200
\            {|Crypt (shrK A') {|NA', Agent A', Agent B', K|},     \
paulson@2284
   201
\              Crypt (shrK B') {|NB', Agent A', Agent B', K|}|}    \
paulson@3466
   202
\           : set evs;                                             \
paulson@3519
   203
\          evs : otway |]                                          \
paulson@2090
   204
\       ==> A=A' & B=B' & NA=NA' & NB=NB'";
paulson@2417
   205
by (prove_unique_tac lemma 1);
paulson@2090
   206
qed "unique_session_keys";
paulson@2090
   207
paulson@2090
   208
paulson@2090
   209
paulson@2090
   210
(**** Authenticity properties relating to NA ****)
paulson@2090
   211
paulson@2090
   212
(*If the encrypted message appears then it originated with the Server!*)
paulson@2090
   213
goal thy 
paulson@3683
   214
 "!!evs. [| A ~: bad;  evs : otway |]                 \
paulson@3683
   215
\ ==> Crypt (shrK A) {|NA, Agent A, Agent B, Key K|} : parts (spies evs) \
paulson@2331
   216
\     --> (EX NB. Says Server B                                          \
paulson@2284
   217
\                  {|Crypt (shrK A) {|NA, Agent A, Agent B, Key K|},     \
paulson@2284
   218
\                    Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|}    \
nipkow@3465
   219
\                  : set evs)";
paulson@3519
   220
by (parts_induct_tac 1);
paulson@4470
   221
by (Blast_tac 1);
wenzelm@4091
   222
by (ALLGOALS (asm_simp_tac (simpset() addsimps [ex_disj_distrib])));
paulson@2090
   223
(*OR3*)
paulson@3102
   224
by (Blast_tac 1);
paulson@2090
   225
qed_spec_mp "NA_Crypt_imp_Server_msg";
paulson@2090
   226
paulson@2090
   227
paulson@2454
   228
(*Corollary: if A receives B's OR4 message then it originated with the Server.
paulson@2454
   229
  Freshness may be inferred from nonce NA.*)
paulson@2090
   230
goal thy 
paulson@2284
   231
 "!!evs. [| Says B' A (Crypt (shrK A) {|NA, Agent A, Agent B, Key K|})  \
paulson@3466
   232
\            : set evs;                                                 \
paulson@3683
   233
\           A ~: bad;  evs : otway |]                                  \
paulson@2090
   234
\        ==> EX NB. Says Server B                                       \
paulson@2284
   235
\                    {|Crypt (shrK A) {|NA, Agent A, Agent B, Key K|},  \
paulson@2284
   236
\                      Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|} \
nipkow@3465
   237
\                   : set evs";
paulson@4470
   238
by (blast_tac (claset() addSIs [NA_Crypt_imp_Server_msg]) 1);
paulson@2331
   239
qed "A_trusts_OR4";
paulson@2090
   240
paulson@2090
   241
paulson@2090
   242
(** Crucial secrecy property: Spy does not see the keys sent in msg OR3
paulson@2090
   243
    Does not in itself guarantee security: an attack could violate 
paulson@2090
   244
    the premises, e.g. by having A=Spy **)
paulson@2090
   245
paulson@2090
   246
goal thy 
paulson@4537
   247
 "!!evs. [| A ~: bad;  B ~: bad;  evs : otway |]                   \
paulson@3543
   248
\        ==> Says Server B                                         \
paulson@3543
   249
\             {|Crypt (shrK A) {|NA, Agent A, Agent B, Key K|},    \
paulson@3543
   250
\               Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|}   \
paulson@3543
   251
\            : set evs -->                                         \
paulson@4537
   252
\            Notes Spy {|NA, NB, Key K|} ~: set evs -->            \
paulson@3683
   253
\            Key K ~: analz (spies evs)";
paulson@2090
   254
by (etac otway.induct 1);
paulson@3683
   255
by analz_spies_tac;
paulson@2090
   256
by (ALLGOALS
wenzelm@4091
   257
    (asm_simp_tac (simpset() addcongs [conj_cong, if_weak_cong] 
paulson@4509
   258
                             addsimps [analz_insert_eq, analz_insert_freshK]
paulson@4509
   259
                             addsimps (pushes@expand_ifs))));
paulson@3451
   260
(*Oops*)
wenzelm@4091
   261
by (blast_tac (claset() addSDs [unique_session_keys]) 4);
paulson@3451
   262
(*OR4*) 
paulson@3451
   263
by (Blast_tac 3);
paulson@2090
   264
(*OR3*)
paulson@4470
   265
by (Blast_tac 2);
paulson@3451
   266
(*Fake*) 
paulson@3451
   267
by (spy_analz_tac 1);
paulson@2090
   268
val lemma = result() RS mp RS mp RSN(2,rev_notE);
paulson@2090
   269
paulson@2090
   270
goal thy 
paulson@2516
   271
 "!!evs. [| Says Server B                                           \
paulson@2516
   272
\              {|Crypt (shrK A) {|NA, Agent A, Agent B, Key K|},    \
paulson@2516
   273
\                Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|}   \
paulson@3466
   274
\             : set evs;                                            \
paulson@4537
   275
\           Notes Spy {|NA, NB, Key K|} ~: set evs;                 \
paulson@4537
   276
\           A ~: bad;  B ~: bad;  evs : otway |]                    \
paulson@3683
   277
\        ==> Key K ~: analz (spies evs)";
paulson@2090
   278
by (forward_tac [Says_Server_message_form] 1 THEN assume_tac 1);
wenzelm@4091
   279
by (blast_tac (claset() addSEs [lemma]) 1);
paulson@2090
   280
qed "Spy_not_see_encrypted_key";
paulson@2090
   281
paulson@2090
   282
paulson@2090
   283
(**** Authenticity properties relating to NB ****)
paulson@2090
   284
paulson@2090
   285
(*If the encrypted message appears then it originated with the Server!*)
paulson@2090
   286
goal thy 
paulson@3683
   287
 "!!evs. [| B ~: bad;  evs : otway |]                                 \
paulson@3683
   288
\    ==> Crypt (shrK B) {|NB, Agent A, Agent B, Key K|} : parts (spies evs) \
paulson@2090
   289
\        --> (EX NA. Says Server B                                          \
paulson@2284
   290
\                     {|Crypt (shrK A) {|NA, Agent A, Agent B, Key K|},     \
paulson@2284
   291
\                       Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|}    \
nipkow@3465
   292
\                     : set evs)";
paulson@3519
   293
by (parts_induct_tac 1);
paulson@4470
   294
by (Blast_tac 1);
wenzelm@4091
   295
by (ALLGOALS (asm_simp_tac (simpset() addsimps [ex_disj_distrib])));
paulson@2090
   296
(*OR3*)
paulson@3102
   297
by (Blast_tac 1);
paulson@2090
   298
qed_spec_mp "NB_Crypt_imp_Server_msg";
paulson@2090
   299
paulson@2090
   300
paulson@2454
   301
(*Guarantee for B: if it gets a well-formed certificate then the Server
paulson@2454
   302
  has sent the correct message in round 3.*)
paulson@2090
   303
goal thy 
paulson@3683
   304
 "!!evs. [| B ~: bad;  evs : otway;                                        \
paulson@2837
   305
\           Says S' B {|X, Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|} \
paulson@3466
   306
\            : set evs |]                                                   \
paulson@2106
   307
\        ==> EX NA. Says Server B                                           \
paulson@2284
   308
\                     {|Crypt (shrK A) {|NA, Agent A, Agent B, Key K|},     \
paulson@2284
   309
\                       Crypt (shrK B) {|NB, Agent A, Agent B, Key K|}|}    \
nipkow@3465
   310
\                     : set evs";
paulson@4470
   311
by (blast_tac (claset() addSIs [NB_Crypt_imp_Server_msg]) 1);
paulson@2331
   312
qed "B_trusts_OR3";