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