src/HOL/Auth/OtwayRees.ML
author paulson
Thu Sep 23 13:06:31 1999 +0200 (1999-09-23)
changeset 7584 5be4bb8e4e3f
parent 7499 23e090051cb8
child 8215 d3eba67a9e67
permissions -rw-r--r--
tidied; added lemma restrict_to_left
paulson@1941
     1
(*  Title:      HOL/Auth/OtwayRees
paulson@1941
     2
    ID:         $Id$
paulson@1941
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@1941
     4
    Copyright   1996  University of Cambridge
paulson@1941
     5
paulson@1941
     6
Inductive relation "otway" for the Otway-Rees protocol.
paulson@1941
     7
paulson@2014
     8
Version that encrypts Nonce NB
paulson@2014
     9
paulson@1941
    10
From page 244 of
paulson@1941
    11
  Burrows, Abadi and Needham.  A Logic of Authentication.
paulson@1941
    12
  Proc. Royal Soc. 426 (1989)
paulson@1941
    13
*)
paulson@1941
    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@1996
    19
paulson@2328
    20
(*A "possibility property": there are traces that reach the end*)
paulson@5434
    21
Goal "[| B ~= Server |]   \
paulson@6308
    22
\     ==> EX NA K. EX evs: otway.          \
paulson@5114
    23
\            Says B A {|Nonce NA, Crypt (shrK A) {|Nonce NA, Key K|}|} \
paulson@5114
    24
\              : set evs";
paulson@1996
    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@2014
    31
result();
paulson@1996
    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@1996
    45
paulson@1941
    46
(**** Inductive proofs about otway ****)
paulson@1941
    47
paulson@1941
    48
(** For reasoning about the encrypted portion of messages **)
paulson@1941
    49
paulson@6308
    50
Goal "[| Gets B {|N, Agent A, Agent 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 "OR2_analz_knows_Spy";
paulson@1941
    54
paulson@6308
    55
Goal "[| Gets B {|N, X, Crypt (shrK B) X'|} : set evs;  evs : otway |] \
paulson@6308
    56
\     ==> X : analz (knows Spy evs)";
paulson@6308
    57
by (blast_tac (claset() addSDs [Gets_imp_knows_Spy RS analz.Inj]) 1);
paulson@6308
    58
qed "OR4_analz_knows_Spy";
paulson@1941
    59
paulson@5114
    60
Goal "Says Server B {|NA, X, Crypt K' {|NB,K|}|} : set evs \
paulson@6308
    61
\     ==> K : parts (knows Spy evs)";
paulson@4470
    62
by (Blast_tac 1);
paulson@6308
    63
qed "Oops_parts_knows_Spy";
paulson@1941
    64
paulson@6308
    65
bind_thm ("OR2_parts_knows_Spy",
paulson@6308
    66
          OR2_analz_knows_Spy RS (impOfSubs analz_subset_parts));
paulson@6308
    67
bind_thm ("OR4_parts_knows_Spy",
paulson@6308
    68
          OR4_analz_knows_Spy RS (impOfSubs analz_subset_parts));
paulson@2032
    69
paulson@6308
    70
(*For proving the easier theorems about X ~: parts (knows Spy evs).*)
paulson@3519
    71
fun parts_induct_tac i = 
paulson@3519
    72
    etac otway.induct i			THEN 
wenzelm@7499
    73
    ftac Oops_parts_knows_Spy (i+7) THEN
wenzelm@7499
    74
    ftac OR4_parts_knows_Spy (i+6) THEN
wenzelm@7499
    75
    ftac OR2_parts_knows_Spy (i+4) THEN 
paulson@3519
    76
    prove_simple_subgoals_tac  i;
paulson@1941
    77
paulson@1941
    78
paulson@6308
    79
(** Theorems of the form X ~: parts (knows Spy evs) imply that NOBODY
paulson@2014
    80
    sends messages containing X! **)
paulson@1941
    81
paulson@4537
    82
(*Spy never sees a good agent's shared key!*)
paulson@6308
    83
Goal "evs : otway ==> (Key (shrK A) : parts (knows Spy evs)) = (A : bad)";
paulson@3519
    84
by (parts_induct_tac 1);
paulson@3961
    85
by (ALLGOALS Blast_tac);
paulson@2135
    86
qed "Spy_see_shrK";
paulson@2135
    87
Addsimps [Spy_see_shrK];
paulson@1941
    88
paulson@6308
    89
Goal "evs : otway ==> (Key (shrK A) : analz (knows Spy evs)) = (A : bad)";
wenzelm@4091
    90
by (auto_tac(claset() addDs [impOfSubs analz_subset_parts], simpset()));
paulson@2135
    91
qed "Spy_analz_shrK";
paulson@2135
    92
Addsimps [Spy_analz_shrK];
paulson@1941
    93
paulson@4470
    94
AddSDs [Spy_see_shrK RSN (2, rev_iffD1), 
paulson@4470
    95
	Spy_analz_shrK RSN (2, rev_iffD1)];
paulson@1941
    96
paulson@1941
    97
paulson@2516
    98
(*Nobody can have used non-existent keys!*)
paulson@6308
    99
Goal "evs : otway ==> Key K ~: used evs --> K ~: keysFor (parts (knows Spy evs))";
paulson@3519
   100
by (parts_induct_tac 1);
paulson@2516
   101
(*Fake*)
paulson@4509
   102
by (blast_tac (claset() addSDs [keysFor_parts_insert]) 1);
paulson@4537
   103
(*OR2, OR3*)
paulson@3102
   104
by (ALLGOALS Blast_tac);
paulson@2160
   105
qed_spec_mp "new_keys_not_used";
paulson@1941
   106
paulson@1941
   107
bind_thm ("new_keys_not_analzd",
paulson@2032
   108
          [analz_subset_parts RS keysFor_mono,
paulson@2032
   109
           new_keys_not_used] MRS contra_subsetD);
paulson@1941
   110
paulson@1941
   111
Addsimps [new_keys_not_used, new_keys_not_analzd];
paulson@1941
   112
paulson@1941
   113
paulson@2064
   114
paulson@2064
   115
(*** Proofs involving analz ***)
paulson@2064
   116
paulson@2135
   117
(*Describes the form of K and NA when the Server sends this message.  Also
paulson@2135
   118
  for Oops case.*)
paulson@5278
   119
Goal "[| Says Server B {|NA, X, Crypt (shrK B) {|NB, Key K|}|} : set evs; \
paulson@5359
   120
\        evs : otway |]                                           \
paulson@2516
   121
\     ==> K ~: range shrK & (EX i. NA = Nonce i) & (EX j. NB = Nonce j)";
paulson@2135
   122
by (etac rev_mp 1);
paulson@2135
   123
by (etac otway.induct 1);
paulson@3102
   124
by (ALLGOALS Simp_tac);
paulson@3102
   125
by (ALLGOALS Blast_tac);
paulson@2135
   126
qed "Says_Server_message_form";
paulson@2064
   127
paulson@2064
   128
paulson@3519
   129
(*For proofs involving analz.*)
paulson@6308
   130
val analz_knows_Spy_tac = 
paulson@6308
   131
    dtac OR2_analz_knows_Spy 5 THEN assume_tac 5 THEN 
paulson@6308
   132
    dtac OR4_analz_knows_Spy 7 THEN assume_tac 7 THEN
wenzelm@7499
   133
    ftac Says_Server_message_form 8 THEN assume_tac 8 THEN
paulson@6308
   134
    REPEAT ((eresolve_tac [exE, conjE] ORELSE' hyp_subst_tac) 8);
paulson@1941
   135
paulson@1941
   136
paulson@1941
   137
(****
paulson@1941
   138
 The following is to prove theorems of the form
paulson@1941
   139
paulson@6308
   140
  Key K : analz (insert (Key KAB) (knows Spy evs)) ==>
paulson@6308
   141
  Key K : analz (knows Spy evs)
paulson@1941
   142
paulson@1941
   143
 A more general formula must be proved inductively.
paulson@1941
   144
****)
paulson@1941
   145
paulson@1941
   146
paulson@1941
   147
(** Session keys are not used to encrypt other session keys **)
paulson@1941
   148
paulson@2014
   149
(*The equality makes the induction hypothesis easier to apply*)
paulson@5492
   150
Goal "evs : otway ==> ALL K KK. KK <= - (range shrK) -->           \
paulson@6308
   151
\                      (Key K : analz (Key``KK Un (knows Spy evs))) =  \
paulson@6308
   152
\                      (K : KK | Key K : analz (knows Spy evs))";
paulson@2032
   153
by (etac otway.induct 1);
paulson@6308
   154
by analz_knows_Spy_tac;
paulson@2516
   155
by (REPEAT_FIRST (resolve_tac [allI, impI]));
paulson@5359
   156
by (REPEAT_FIRST (rtac analz_image_freshK_lemma));
paulson@2516
   157
by (ALLGOALS (asm_simp_tac analz_image_freshK_ss));
paulson@3451
   158
(*Fake*) 
paulson@4422
   159
by (spy_analz_tac 1);
paulson@2516
   160
qed_spec_mp "analz_image_freshK";
paulson@1941
   161
paulson@1941
   162
paulson@5359
   163
Goal "[| evs : otway;  KAB ~: range shrK |]               \
paulson@6308
   164
\     ==> Key K : analz (insert (Key KAB) (knows Spy evs)) =  \
paulson@6308
   165
\         (K = KAB | Key K : analz (knows Spy evs))";
paulson@2516
   166
by (asm_simp_tac (analz_image_freshK_ss addsimps [analz_image_freshK]) 1);
paulson@2516
   167
qed "analz_insert_freshK";
paulson@1941
   168
paulson@1941
   169
paulson@2026
   170
(*** The Key K uniquely identifies the Server's  message. **)
paulson@2014
   171
paulson@5278
   172
Goal "evs : otway ==>                                                  \
paulson@5359
   173
\     EX B' NA' NB' X'. ALL B NA NB X.                                   \
paulson@5359
   174
\     Says Server B {|NA, X, Crypt (shrK B) {|NB, K|}|} : set evs -->    \
paulson@2135
   175
\     B=B' & NA=NA' & NB=NB' & X=X'";
paulson@2032
   176
by (etac otway.induct 1);
wenzelm@4091
   177
by (ALLGOALS (asm_simp_tac (simpset() addsimps [all_conj_distrib])));
paulson@3730
   178
by (ALLGOALS Clarify_tac);
paulson@2014
   179
(*Remaining cases: OR3 and OR4*)
paulson@2014
   180
by (ex_strip_tac 2);
paulson@4537
   181
by (Best_tac 2);	(*Blast_tac's too slow (in reconstruction)*)
paulson@2064
   182
by (expand_case_tac "K = ?y" 1);
paulson@2064
   183
by (REPEAT (ares_tac [refl,exI,impI,conjI] 2));
paulson@2516
   184
(*...we assume X is a recent message, and handle this case by contradiction*)
paulson@6308
   185
by (blast_tac (claset() addSEs knows_Spy_partsEs) 1);
paulson@2014
   186
val lemma = result();
paulson@2014
   187
paulson@5278
   188
Goal "[| Says Server B {|NA, X, Crypt (shrK B) {|NB, K|}|}   : set evs; \ 
paulson@5114
   189
\    Says Server B' {|NA',X',Crypt (shrK B') {|NB',K|}|} : set evs; \
paulson@5114
   190
\    evs : otway |] ==> X=X' & B=B' & NA=NA' & NB=NB'";
paulson@2417
   191
by (prove_unique_tac lemma 1);
paulson@2014
   192
qed "unique_session_keys";
paulson@2014
   193
paulson@2014
   194
paulson@2048
   195
(**** Authenticity properties relating to NA ****)
paulson@2014
   196
paulson@2014
   197
(*Only OR1 can have caused such a part of a message to appear.*)
paulson@5278
   198
Goal "[| A ~: bad;  evs : otway |]                             \
paulson@6308
   199
\ ==> Crypt (shrK A) {|NA, Agent A, Agent B|} : parts (knows Spy evs) --> \
paulson@5114
   200
\     Says A B {|NA, Agent A, Agent B,                      \
paulson@5114
   201
\                Crypt (shrK A) {|NA, Agent A, Agent B|}|}  \
paulson@5114
   202
\      : set evs";
paulson@3519
   203
by (parts_induct_tac 1);
paulson@4470
   204
by (Blast_tac 1);
paulson@2014
   205
qed_spec_mp "Crypt_imp_OR1";
paulson@2014
   206
paulson@6308
   207
Goal "[| Gets B {|NA, Agent A, Agent B,                      \
paulson@6308
   208
\                 Crypt (shrK A) {|NA, Agent A, Agent B|}|} : set evs; \
paulson@6308
   209
\        A ~: bad; evs : otway |]                             \
paulson@6308
   210
\    ==> Says A B {|NA, Agent A, Agent B,                      \
paulson@6308
   211
\                Crypt (shrK A) {|NA, Agent A, Agent B|}|}  \
paulson@6308
   212
\      : set evs";
paulson@6308
   213
by (blast_tac (claset() addDs [Crypt_imp_OR1]) 1);
paulson@6308
   214
qed"Crypt_imp_OR1_Gets";
paulson@6308
   215
paulson@2014
   216
paulson@2064
   217
(** The Nonce NA uniquely identifies A's message. **)
paulson@2014
   218
paulson@5278
   219
Goal "[| evs : otway; A ~: bad |]               \
paulson@3519
   220
\ ==> EX B'. ALL B.                                 \
paulson@6308
   221
\        Crypt (shrK A) {|NA, Agent A, Agent B|} : parts (knows Spy evs) \
paulson@2048
   222
\        --> B = B'";
paulson@3519
   223
by (parts_induct_tac 1);
paulson@4470
   224
by (Blast_tac 1);
wenzelm@4091
   225
by (simp_tac (simpset() addsimps [all_conj_distrib]) 1); 
paulson@2026
   226
(*OR1: creation of new Nonce.  Move assertion into global context*)
paulson@2064
   227
by (expand_case_tac "NA = ?y" 1);
paulson@4470
   228
by (Blast_tac 1);
paulson@2014
   229
val lemma = result();
paulson@2014
   230
paulson@6308
   231
Goal "[| Crypt (shrK A) {|NA, Agent A, Agent B|}: parts (knows Spy evs); \
paulson@6308
   232
\          Crypt (shrK A) {|NA, Agent A, Agent C|}: parts (knows Spy evs); \
paulson@3683
   233
\          evs : otway;  A ~: bad |]                                   \
paulson@2014
   234
\        ==> B = C";
paulson@2417
   235
by (prove_unique_tac lemma 1);
paulson@2048
   236
qed "unique_NA";
paulson@2014
   237
paulson@2014
   238
paulson@2014
   239
(*It is impossible to re-use a nonce in both OR1 and OR2.  This holds because
paulson@2014
   240
  OR2 encrypts Nonce NB.  It prevents the attack that can occur in the
paulson@2014
   241
  over-simplified version of this protocol: see OtwayRees_Bad.*)
paulson@5278
   242
Goal "[| A ~: bad;  evs : otway |]                      \
paulson@6308
   243
\        ==> Crypt (shrK A) {|NA, Agent A, Agent B|} : parts (knows Spy evs) --> \
paulson@3519
   244
\            Crypt (shrK A) {|NA', NA, Agent A', Agent A|}  \
paulson@6308
   245
\             ~: parts (knows Spy evs)";
paulson@3519
   246
by (parts_induct_tac 1);
paulson@6308
   247
by Auto_tac;
paulson@6308
   248
qed_spec_mp "no_nonce_OR1_OR2";
paulson@2014
   249
paulson@4470
   250
val nonce_OR1_OR2_E = no_nonce_OR1_OR2 RSN (2, rev_notE);
paulson@2014
   251
paulson@2053
   252
(*Crucial property: If the encrypted message appears, and A has used NA
paulson@2053
   253
  to start a run, then it originated with the Server!*)
paulson@5278
   254
Goal "[| A ~: bad;  evs : otway |]                                  \
paulson@6308
   255
\    ==> Crypt (shrK A) {|NA, Key K|} : parts (knows Spy evs)              \
paulson@2048
   256
\        --> Says A B {|NA, Agent A, Agent B,                          \
paulson@2284
   257
\                       Crypt (shrK A) {|NA, Agent A, Agent B|}|}      \
paulson@3466
   258
\             : set evs -->                                            \
paulson@2048
   259
\            (EX NB. Says Server B                                     \
paulson@2048
   260
\                 {|NA,                                                \
paulson@2284
   261
\                   Crypt (shrK A) {|NA, Key K|},                      \
paulson@2284
   262
\                   Crypt (shrK B) {|NB, Key K|}|}                     \
nipkow@3465
   263
\                   : set evs)";
paulson@3519
   264
by (parts_induct_tac 1);
paulson@4470
   265
by (Blast_tac 1);
paulson@2014
   266
(*OR1: it cannot be a new Nonce, contradiction.*)
paulson@4470
   267
by (Blast_tac 1);
paulson@3730
   268
(*OR3 and OR4*)
wenzelm@4091
   269
by (asm_simp_tac (simpset() addsimps [ex_disj_distrib]) 1);
paulson@3730
   270
by (rtac conjI 1);
paulson@3730
   271
by (ALLGOALS Clarify_tac);
paulson@3730
   272
(*OR4*)
paulson@4470
   273
by (blast_tac (claset() addSIs [Crypt_imp_OR1]) 3);
paulson@4470
   274
(*OR3, two cases*)  (** LEVEL 7 **)
paulson@4470
   275
by (blast_tac (claset() addSEs  [nonce_OR1_OR2_E]
paulson@4470
   276
                        delrules [conjI] (*stop split-up into 4 subgoals*)) 2);
paulson@6308
   277
by (blast_tac (claset() addIs [unique_NA]) 1);
paulson@2048
   278
qed_spec_mp "NA_Crypt_imp_Server_msg";
paulson@2014
   279
paulson@2014
   280
paulson@2053
   281
(*Corollary: if A receives B's OR4 message and the nonce NA agrees
paulson@2014
   282
  then the key really did come from the Server!  CANNOT prove this of the
paulson@2048
   283
  bad form of this protocol, even though we can prove
paulson@2032
   284
  Spy_not_see_encrypted_key*)
paulson@5278
   285
Goal "[| Says A  B {|NA, Agent A, Agent B,                       \
paulson@5114
   286
\                Crypt (shrK A) {|NA, Agent A, Agent B|}|} : set evs; \
paulson@6308
   287
\        Gets A {|NA, Crypt (shrK A) {|NA, Key K|}|} : set evs; \
paulson@5114
   288
\    A ~: bad;  evs : otway |]                              \
paulson@5114
   289
\ ==> EX NB. Says Server B                                  \
paulson@5114
   290
\              {|NA,                                        \
paulson@5114
   291
\                Crypt (shrK A) {|NA, Key K|},              \
paulson@5114
   292
\                Crypt (shrK B) {|NB, Key K|}|}             \
paulson@5114
   293
\                : set evs";
paulson@4470
   294
by (blast_tac (claset() addSIs [NA_Crypt_imp_Server_msg]) 1);
paulson@2328
   295
qed "A_trusts_OR4";
paulson@2014
   296
paulson@2014
   297
paulson@2048
   298
(** Crucial secrecy property: Spy does not see the keys sent in msg OR3
paulson@2048
   299
    Does not in itself guarantee security: an attack could violate 
paulson@2048
   300
    the premises, e.g. by having A=Spy **)
paulson@2014
   301
paulson@5278
   302
Goal "[| A ~: bad;  B ~: bad;  evs : otway |]                      \
paulson@5114
   303
\ ==> Says Server B                                            \
paulson@5114
   304
\       {|NA, Crypt (shrK A) {|NA, Key K|},                    \
paulson@5114
   305
\         Crypt (shrK B) {|NB, Key K|}|} : set evs -->         \
paulson@5114
   306
\     Notes Spy {|NA, NB, Key K|} ~: set evs -->               \
paulson@6308
   307
\     Key K ~: analz (knows Spy evs)";
paulson@2032
   308
by (etac otway.induct 1);
paulson@6308
   309
by analz_knows_Spy_tac;
paulson@1964
   310
by (ALLGOALS
wenzelm@4091
   311
    (asm_simp_tac (simpset() addcongs [conj_cong] 
paulson@4509
   312
                             addsimps [analz_insert_eq, analz_insert_freshK]
paulson@5535
   313
                                      @ pushes @ split_ifs)));
paulson@3451
   314
(*Oops*)
wenzelm@4091
   315
by (blast_tac (claset() addSDs [unique_session_keys]) 4);
paulson@3451
   316
(*OR4*) 
paulson@3451
   317
by (Blast_tac 3);
paulson@1941
   318
(*OR3*)
paulson@4470
   319
by (Blast_tac 2);
paulson@3451
   320
(*Fake*) 
paulson@3451
   321
by (spy_analz_tac 1);
paulson@2014
   322
val lemma = result() RS mp RS mp RSN(2,rev_notE);
paulson@2014
   323
paulson@5114
   324
Goal "[| Says Server B                                           \
paulson@5114
   325
\         {|NA, Crypt (shrK A) {|NA, Key K|},                    \
paulson@5114
   326
\               Crypt (shrK B) {|NB, Key K|}|} : set evs;        \
paulson@5114
   327
\        Notes Spy {|NA, NB, Key K|} ~: set evs;                 \
paulson@5114
   328
\        A ~: bad;  B ~: bad;  evs : otway |]                    \
paulson@6308
   329
\     ==> Key K ~: analz (knows Spy evs)";
wenzelm@7499
   330
by (ftac Says_Server_message_form 1 THEN assume_tac 1);
wenzelm@4091
   331
by (blast_tac (claset() addSEs [lemma]) 1);
paulson@2032
   332
qed "Spy_not_see_encrypted_key";
paulson@2032
   333
paulson@1945
   334
paulson@4598
   335
(*A's guarantee.  The Oops premise quantifies over NB because A cannot know
paulson@4598
   336
  what it is.*)
paulson@5114
   337
Goal "[| Says A  B {|NA, Agent A, Agent B,                       \
paulson@5114
   338
\                    Crypt (shrK A) {|NA, Agent A, Agent B|}|} : set evs; \
paulson@6308
   339
\        Gets A {|NA, Crypt (shrK A) {|NA, Key K|}|} : set evs; \
paulson@5114
   340
\        ALL NB. Notes Spy {|NA, NB, Key K|} ~: set evs;         \
paulson@5114
   341
\        A ~: bad;  B ~: bad;  evs : otway |]                    \
paulson@6308
   342
\     ==> Key K ~: analz (knows Spy evs)";
paulson@4598
   343
by (blast_tac (claset() addSDs [A_trusts_OR4, Spy_not_see_encrypted_key]) 1);
paulson@4598
   344
qed "A_gets_good_key";
paulson@4598
   345
paulson@4598
   346
paulson@2048
   347
(**** Authenticity properties relating to NB ****)
paulson@2048
   348
paulson@2048
   349
(*Only OR2 can have caused such a part of a message to appear.  We do not
paulson@2194
   350
  know anything about X: it does NOT have to have the right form.*)
paulson@5278
   351
Goal "[| B ~: bad;  evs : otway |]                         \
paulson@5114
   352
\     ==> Crypt (shrK B) {|NA, NB, Agent A, Agent B|}       \
paulson@6308
   353
\          : parts (knows Spy evs) -->                       \
paulson@5114
   354
\         (EX X. Says B Server                              \
paulson@5114
   355
\          {|NA, Agent A, Agent B, X,                       \
paulson@5114
   356
\            Crypt (shrK B) {|NA, NB, Agent A, Agent B|}|}  \
paulson@5114
   357
\          : set evs)";
paulson@3519
   358
by (parts_induct_tac 1);
paulson@3102
   359
by (ALLGOALS Blast_tac);
paulson@2194
   360
bind_thm ("Crypt_imp_OR2", result() RSN (2,rev_mp) RS exE);
paulson@2048
   361
paulson@2048
   362
paulson@2048
   363
(** The Nonce NB uniquely identifies B's  message. **)
paulson@2048
   364
paulson@5114
   365
Goal "[| evs : otway; B ~: bad |]  \
paulson@4598
   366
\ ==> EX NA' A'. ALL NA A.            \
paulson@6308
   367
\      Crypt (shrK B) {|NA, NB, Agent A, Agent B|} : parts(knows Spy evs) \
paulson@2048
   368
\      --> NA = NA' & A = A'";
paulson@3519
   369
by (parts_induct_tac 1);
paulson@4470
   370
by (Blast_tac 1);
wenzelm@4091
   371
by (simp_tac (simpset() addsimps [all_conj_distrib]) 1); 
paulson@2048
   372
(*OR2: creation of new Nonce.  Move assertion into global context*)
paulson@2064
   373
by (expand_case_tac "NB = ?y" 1);
paulson@4470
   374
by (Blast_tac 1);
paulson@2048
   375
val lemma = result();
paulson@2048
   376
paulson@6308
   377
Goal "[| Crypt (shrK B) {|NA, NB, Agent A, Agent B|} : parts(knows Spy evs); \
paulson@6308
   378
\          Crypt (shrK B) {|NC, NB, Agent C, Agent B|} : parts(knows Spy evs); \
paulson@3683
   379
\          evs : otway;  B ~: bad |]             \
paulson@2048
   380
\        ==> NC = NA & C = A";
paulson@2417
   381
by (prove_unique_tac lemma 1);
paulson@2048
   382
qed "unique_NB";
paulson@2048
   383
paulson@2048
   384
(*If the encrypted message appears, and B has used Nonce NB,
paulson@2048
   385
  then it originated with the Server!*)
paulson@5114
   386
Goal "[| B ~: bad;  evs : otway |]                                    \
paulson@6308
   387
\ ==> Crypt (shrK B) {|NB, Key K|} : parts (knows Spy evs)                \
paulson@5114
   388
\     --> (ALL X'. Says B Server                                      \
paulson@5114
   389
\                    {|NA, Agent A, Agent B, X',                      \
paulson@5114
   390
\                      Crypt (shrK B) {|NA, NB, Agent A, Agent B|}|}  \
paulson@5114
   391
\          : set evs                                                  \
paulson@5114
   392
\          --> Says Server B                                          \
paulson@5114
   393
\               {|NA, Crypt (shrK A) {|NA, Key K|},                   \
paulson@5114
   394
\                     Crypt (shrK B) {|NB, Key K|}|}                  \
nipkow@3465
   395
\                   : set evs)";
paulson@3519
   396
by (parts_induct_tac 1);
paulson@4470
   397
by (Blast_tac 1);
paulson@2048
   398
(*OR1: it cannot be a new Nonce, contradiction.*)
paulson@4470
   399
by (Blast_tac 1);
paulson@2048
   400
(*OR4*)
paulson@4470
   401
by (blast_tac (claset() addSEs [Crypt_imp_OR2]) 2);
paulson@2194
   402
(*OR3*)
paulson@4470
   403
(*Provable in 38s by the single command
paulson@4470
   404
    by (blast_tac (claset() addDs  [unique_NB] addEs[nonce_OR1_OR2_E]) 1);
paulson@4470
   405
*)
wenzelm@4091
   406
by (safe_tac (claset() delrules [disjCI, impCE]));
paulson@4470
   407
by (Blast_tac 3); 
paulson@6308
   408
by (blast_tac (claset() addSDs  [unique_NB]
paulson@6308
   409
                        delrules [impCE] (*stop split-up*)) 2);
paulson@4470
   410
by (blast_tac (claset() addSEs [nonce_OR1_OR2_E]
paulson@4470
   411
                        delrules [conjI] (*stop split-up*)) 1);
paulson@2048
   412
qed_spec_mp "NB_Crypt_imp_Server_msg";
paulson@2048
   413
paulson@2048
   414
paulson@2048
   415
(*Guarantee for B: if it gets a message with matching NB then the Server
paulson@2048
   416
  has sent the correct message.*)
paulson@5114
   417
Goal "[| Says B Server {|NA, Agent A, Agent B, X',              \
paulson@5114
   418
\                        Crypt (shrK B) {|NA, NB, Agent A, Agent B|} |} \
paulson@5114
   419
\         : set evs;                                            \
paulson@6308
   420
\        Gets B {|NA, X, Crypt (shrK B) {|NB, Key K|}|} : set evs;   \
paulson@5114
   421
\        B ~: bad;  evs : otway |]                              \
paulson@5114
   422
\     ==> Says Server B                                         \
paulson@5114
   423
\              {|NA,                                            \
paulson@5114
   424
\                Crypt (shrK A) {|NA, Key K|},                  \
paulson@5114
   425
\                Crypt (shrK B) {|NB, Key K|}|}                 \
paulson@5114
   426
\                : set evs";
paulson@4470
   427
by (blast_tac (claset() addSIs [NB_Crypt_imp_Server_msg]) 1);
paulson@2328
   428
qed "B_trusts_OR3";
paulson@2048
   429
paulson@2048
   430
paulson@4598
   431
(*The obvious combination of B_trusts_OR3 with Spy_not_see_encrypted_key*)
paulson@5114
   432
Goal "[| Says B Server {|NA, Agent A, Agent B, X',              \
paulson@5114
   433
\                        Crypt (shrK B) {|NA, NB, Agent A, Agent B|} |} \
paulson@5114
   434
\          : set evs;                                           \
paulson@6308
   435
\        Gets B {|NA, X, Crypt (shrK B) {|NB, Key K|}|} : set evs;   \
paulson@5114
   436
\        Notes Spy {|NA, NB, Key K|} ~: set evs;                \
paulson@5114
   437
\        A ~: bad;  B ~: bad;  evs : otway |]                   \
paulson@6308
   438
\     ==> Key K ~: analz (knows Spy evs)";
paulson@4598
   439
by (blast_tac (claset() addSDs [B_trusts_OR3, Spy_not_see_encrypted_key]) 1);
paulson@4598
   440
qed "B_gets_good_key";
paulson@2048
   441
paulson@2048
   442
paulson@5114
   443
Goal "[| B ~: bad;  evs : otway |]                            \
paulson@5114
   444
\     ==> Says Server B                                       \
paulson@5114
   445
\           {|NA, Crypt (shrK A) {|NA, Key K|},               \
paulson@5114
   446
\             Crypt (shrK B) {|NB, Key K|}|} : set evs -->    \
paulson@5114
   447
\         (EX X. Says B Server {|NA, Agent A, Agent B, X,     \
paulson@5114
   448
\                         Crypt (shrK B) {|NA, NB, Agent A, Agent B|} |} \
paulson@5114
   449
\         : set evs)";
paulson@2032
   450
by (etac otway.induct 1);
paulson@3102
   451
by (ALLGOALS Asm_simp_tac);
paulson@4470
   452
by (blast_tac (claset() addSEs [Crypt_imp_OR2]) 3);
paulson@3102
   453
by (ALLGOALS Blast_tac);
paulson@2194
   454
bind_thm ("OR3_imp_OR2", result() RSN (2,rev_mp) RS exE);
paulson@2194
   455
paulson@2194
   456
paulson@2194
   457
(*After getting and checking OR4, agent A can trust that B has been active.
paulson@2194
   458
  We could probably prove that X has the expected form, but that is not
paulson@2194
   459
  strictly necessary for authentication.*)
paulson@6308
   460
Goal "[| Gets A {|NA, Crypt (shrK A) {|NA, Key K|}|} : set evs;        \
paulson@5114
   461
\        Says A  B {|NA, Agent A, Agent B,                                \
paulson@5114
   462
\                    Crypt (shrK A) {|NA, Agent A, Agent B|}|} : set evs; \
paulson@5114
   463
\        A ~: bad;  B ~: bad;  evs : otway |]                             \
paulson@5114
   464
\     ==> EX NB X. Says B Server {|NA, Agent A, Agent B, X,               \
paulson@5114
   465
\                           Crypt (shrK B)  {|NA, NB, Agent A, Agent B|} |}\
paulson@5114
   466
\         : set evs";
paulson@4470
   467
by (blast_tac (claset() addSDs [A_trusts_OR4]
paulson@4470
   468
                        addSEs [OR3_imp_OR2]) 1);
paulson@2194
   469
qed "A_auths_B";