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