src/HOL/Auth/TLS.ML
author paulson
Wed Oct 01 12:07:24 1997 +0200 (1997-10-01)
changeset 3758 188a4fbfaf55
parent 3745 4c5d3b1ddc75
child 3760 77f71f650433
permissions -rw-r--r--
Exchanged the M and SID fields of the FINISHED messages to simplify proofs;
deleted unused theorems
paulson@3474
     1
(*  Title:      HOL/Auth/TLS
paulson@3474
     2
    ID:         $Id$
paulson@3474
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@3474
     4
    Copyright   1997  University of Cambridge
paulson@3474
     5
paulson@3480
     6
Protocol goals: 
paulson@3480
     7
* M, serverK(NA,NB,M) and clientK(NA,NB,M) will be known only to the two
paulson@3480
     8
     parties (though A is not necessarily authenticated).
paulson@3480
     9
paulson@3685
    10
* B upon receiving CertVerify knows that A is present (But this
paulson@3480
    11
    message is optional!)
paulson@3474
    12
paulson@3685
    13
* A upon receiving ServerFinished knows that B is present
paulson@3480
    14
paulson@3480
    15
* Each party who has received a FINISHED message can trust that the other
paulson@3729
    16
  party agrees on all message components, including PA and PB (thus foiling
paulson@3480
    17
  rollback attacks).
paulson@3474
    18
*)
paulson@3474
    19
paulson@3704
    20
paulson@3474
    21
open TLS;
paulson@3474
    22
paulson@3474
    23
proof_timing:=true;
paulson@3474
    24
HOL_quantifiers := false;
paulson@3474
    25
paulson@3519
    26
(** We mostly DO NOT unfold the definition of "certificate".  The attached
paulson@3519
    27
    lemmas unfold it lazily, when "certificate B KB" occurs in appropriate
paulson@3519
    28
    contexts.
paulson@3519
    29
**)
paulson@3519
    30
paulson@3519
    31
goalw thy [certificate_def] 
paulson@3519
    32
    "parts (insert (certificate B KB) H) =  \
paulson@3519
    33
\    parts (insert (Crypt (priK Server) {|Agent B, Key KB|}) H)";
paulson@3519
    34
by (rtac refl 1);
paulson@3519
    35
qed "parts_insert_certificate";
paulson@3474
    36
paulson@3519
    37
goalw thy [certificate_def] 
paulson@3519
    38
    "analz (insert (certificate B KB) H) =  \
paulson@3519
    39
\    analz (insert (Crypt (priK Server) {|Agent B, Key KB|}) H)";
paulson@3519
    40
by (rtac refl 1);
paulson@3519
    41
qed "analz_insert_certificate";
paulson@3519
    42
Addsimps [parts_insert_certificate, analz_insert_certificate];
paulson@3519
    43
paulson@3519
    44
goalw thy [certificate_def] 
paulson@3519
    45
    "(X = certificate B KB) = (Crypt (priK Server) {|Agent B, Key KB|} = X)";
paulson@3480
    46
by (Blast_tac 1);
paulson@3519
    47
qed "eq_certificate_iff";
paulson@3519
    48
AddIffs [eq_certificate_iff];
paulson@3519
    49
paulson@3480
    50
paulson@3474
    51
(*Injectiveness of key-generating functions*)
paulson@3677
    52
AddIffs [inj_PRF RS inj_eq, inj_sessionK RS inj_eq];
paulson@3474
    53
paulson@3677
    54
(* invKey(sessionK x) = sessionK x*)
paulson@3677
    55
Addsimps [isSym_sessionK, rewrite_rule [isSymKey_def] isSym_sessionK];
paulson@3480
    56
paulson@3474
    57
paulson@3474
    58
(*** clientK and serverK make symmetric keys; no clashes with pubK or priK ***)
paulson@3474
    59
paulson@3677
    60
goal thy "pubK A ~= sessionK arg";
paulson@3474
    61
br notI 1;
paulson@3474
    62
by (dres_inst_tac [("f","isSymKey")] arg_cong 1);
paulson@3474
    63
by (Full_simp_tac 1);
paulson@3677
    64
qed "pubK_neq_sessionK";
paulson@3474
    65
paulson@3677
    66
goal thy "priK A ~= sessionK arg";
paulson@3474
    67
br notI 1;
paulson@3474
    68
by (dres_inst_tac [("f","isSymKey")] arg_cong 1);
paulson@3474
    69
by (Full_simp_tac 1);
paulson@3677
    70
qed "priK_neq_sessionK";
paulson@3474
    71
paulson@3677
    72
val keys_distinct = [pubK_neq_sessionK, priK_neq_sessionK];
paulson@3515
    73
AddIffs (keys_distinct @ (keys_distinct RL [not_sym]));
paulson@3474
    74
paulson@3474
    75
paulson@3474
    76
(**** Protocol Proofs ****)
paulson@3474
    77
paulson@3474
    78
(*A "possibility property": there are traces that reach the end.
paulson@3474
    79
  This protocol has three end points and six messages to consider.*)
paulson@3474
    80
paulson@3672
    81
paulson@3672
    82
(** These proofs make the further assumption that the Nonce_supply nonces 
paulson@3672
    83
	(which have the form  @ N. Nonce N ~: used evs)
paulson@3672
    84
    lie outside the range of PRF.  This assumption seems reasonable, but
paulson@3672
    85
    as it is needed only for the possibility theorems, it is not taken
paulson@3672
    86
    as an axiom.
paulson@3672
    87
**)
paulson@3672
    88
paulson@3672
    89
paulson@3685
    90
(*Possibility property ending with ClientAccepts.*)
paulson@3474
    91
goal thy 
paulson@3672
    92
 "!!A B. [| ALL evs. (@ N. Nonce N ~: used evs) ~: range PRF;  \
paulson@3685
    93
\           A ~= B |] ==> EX SID M. EX evs: tls.    \
paulson@3685
    94
\  Notes A {|Number SID, Agent A, Agent B, Nonce M|} : set evs";
paulson@3474
    95
by (REPEAT (resolve_tac [exI,bexI] 1));
paulson@3745
    96
by (rtac (tls.Nil RS tls.ClientHello RS tls.ServerHello RS tls.Certificate RS
paulson@3745
    97
	  tls.ClientKeyExch RS tls.ClientFinished RS tls.ServerFinished RS
paulson@3745
    98
	  tls.ClientAccepts) 2);
paulson@3474
    99
by possibility_tac;
paulson@3672
   100
by (REPEAT (Blast_tac 1));
paulson@3474
   101
result();
paulson@3474
   102
paulson@3685
   103
(*And one for ServerAccepts.  Either FINISHED message may come first.*)
paulson@3474
   104
goal thy 
paulson@3672
   105
 "!!A B. [| ALL evs. (@ N. Nonce N ~: used evs) ~: range PRF;  \
paulson@3729
   106
\           A ~= B |] ==> EX SID NA PA NB PB M. EX evs: tls.    \
paulson@3685
   107
\  Notes B {|Number SID, Agent A, Agent B, Nonce M|} : set evs";
paulson@3474
   108
by (REPEAT (resolve_tac [exI,bexI] 1));
paulson@3745
   109
by (rtac (tls.Nil RS tls.ClientHello RS tls.ServerHello RS tls.Certificate RS
paulson@3745
   110
	  tls.ClientKeyExch RS tls.ServerFinished RS tls.ClientFinished RS
paulson@3745
   111
	  tls.ServerAccepts) 2);
paulson@3474
   112
by possibility_tac;
paulson@3672
   113
by (REPEAT (Blast_tac 1));
paulson@3474
   114
result();
paulson@3474
   115
paulson@3474
   116
(*Another one, for CertVerify (which is optional)*)
paulson@3474
   117
goal thy 
paulson@3672
   118
 "!!A B. [| ALL evs. (@ N. Nonce N ~: used evs) ~: range PRF;  \
paulson@3672
   119
\           A ~= B |] ==> EX NB PMS. EX evs: tls.   \
paulson@3729
   120
\  Says A B (Crypt (priK A) (Hash{|Nonce NB, Agent B, Nonce PMS|})) : set evs";
paulson@3474
   121
by (REPEAT (resolve_tac [exI,bexI] 1));
paulson@3745
   122
by (rtac (tls.Nil RS tls.ClientHello RS tls.ServerHello RS tls.Certificate RS
paulson@3745
   123
	  tls.ClientKeyExch RS tls.CertVerify) 2);
paulson@3474
   124
by possibility_tac;
paulson@3672
   125
by (REPEAT (Blast_tac 1));
paulson@3474
   126
result();
paulson@3474
   127
paulson@3685
   128
(*Another one, for session resumption (both ServerResume and ClientResume) *)
paulson@3685
   129
goal thy 
paulson@3685
   130
 "!!A B. [| evs0 : tls;     \
paulson@3685
   131
\           Notes A {|Number SID, Agent A, Agent B, Nonce M|} : set evs0; \
paulson@3685
   132
\           Notes B {|Number SID, Agent A, Agent B, Nonce M|} : set evs0; \
paulson@3685
   133
\           ALL evs. (@ N. Nonce N ~: used evs) ~: range PRF;  \
paulson@3729
   134
\           A ~= B |] ==> EX NA PA NB PB. EX evs: tls.    \
paulson@3685
   135
\  Says A B (Crypt (clientK(NA,NB,M))                           \
paulson@3758
   136
\            (Hash{|Number SID, Nonce M,             \
paulson@3729
   137
\                   Nonce NA, Number PA, Agent A,      \
paulson@3729
   138
\                   Nonce NB, Number PB, Agent B|})) : set evs";
paulson@3685
   139
by (REPEAT (resolve_tac [exI,bexI] 1));
paulson@3745
   140
by (etac (tls.ClientHello RS tls.ServerHello RS tls.ServerResume RS 
paulson@3745
   141
	  tls.ClientResume) 2);
paulson@3685
   142
by possibility_tac;
paulson@3685
   143
by (REPEAT (Blast_tac 1));
paulson@3685
   144
result();
paulson@3685
   145
paulson@3685
   146
paulson@3474
   147
paulson@3474
   148
(**** Inductive proofs about tls ****)
paulson@3474
   149
paulson@3474
   150
(*Nobody sends themselves messages*)
paulson@3474
   151
goal thy "!!evs. evs : tls ==> ALL A X. Says A A X ~: set evs";
paulson@3474
   152
by (etac tls.induct 1);
paulson@3474
   153
by (Auto_tac());
paulson@3474
   154
qed_spec_mp "not_Says_to_self";
paulson@3474
   155
Addsimps [not_Says_to_self];
paulson@3474
   156
AddSEs   [not_Says_to_self RSN (2, rev_notE)];
paulson@3474
   157
paulson@3474
   158
paulson@3519
   159
(*Induction for regularity theorems.  If induction formula has the form
paulson@3683
   160
   X ~: analz (spies evs) --> ... then it shortens the proof by discarding
paulson@3683
   161
   needless information about analz (insert X (spies evs))  *)
paulson@3519
   162
fun parts_induct_tac i = 
paulson@3519
   163
    etac tls.induct i
paulson@3519
   164
    THEN 
paulson@3519
   165
    REPEAT (FIRSTGOAL analz_mono_contra_tac)
paulson@3519
   166
    THEN 
paulson@3519
   167
    fast_tac (!claset addss (!simpset)) i THEN
paulson@3704
   168
    ALLGOALS (asm_simp_tac (!simpset setloop split_tac [expand_if]));
paulson@3519
   169
paulson@3519
   170
paulson@3683
   171
(** Theorems of the form X ~: parts (spies evs) imply that NOBODY
paulson@3474
   172
    sends messages containing X! **)
paulson@3474
   173
paulson@3683
   174
(*Spy never sees another agent's private key! (unless it's bad at start)*)
paulson@3474
   175
goal thy 
paulson@3683
   176
 "!!evs. evs : tls ==> (Key (priK A) : parts (spies evs)) = (A : bad)";
paulson@3519
   177
by (parts_induct_tac 1);
paulson@3474
   178
by (Fake_parts_insert_tac 1);
paulson@3474
   179
qed "Spy_see_priK";
paulson@3474
   180
Addsimps [Spy_see_priK];
paulson@3474
   181
paulson@3474
   182
goal thy 
paulson@3683
   183
 "!!evs. evs : tls ==> (Key (priK A) : analz (spies evs)) = (A : bad)";
paulson@3474
   184
by (auto_tac(!claset addDs [impOfSubs analz_subset_parts], !simpset));
paulson@3474
   185
qed "Spy_analz_priK";
paulson@3474
   186
Addsimps [Spy_analz_priK];
paulson@3474
   187
paulson@3745
   188
goal thy  "!!A. [| Key (priK A) : parts (spies evs);  evs : tls |] ==> A:bad";
paulson@3474
   189
by (blast_tac (!claset addDs [Spy_see_priK]) 1);
paulson@3474
   190
qed "Spy_see_priK_D";
paulson@3474
   191
paulson@3474
   192
bind_thm ("Spy_analz_priK_D", analz_subset_parts RS subsetD RS Spy_see_priK_D);
paulson@3474
   193
AddSDs [Spy_see_priK_D, Spy_analz_priK_D];
paulson@3474
   194
paulson@3474
   195
paulson@3515
   196
(*This lemma says that no false certificates exist.  One might extend the
paulson@3519
   197
  model to include bogus certificates for the agents, but there seems
paulson@3515
   198
  little point in doing so: the loss of their private keys is a worse
paulson@3515
   199
  breach of security.*)
paulson@3515
   200
goalw thy [certificate_def]
paulson@3745
   201
 "!!evs. evs : tls ==> certificate B KB : parts (spies evs) --> KB = pubK B";
paulson@3519
   202
by (parts_induct_tac 1);
paulson@3519
   203
by (Fake_parts_insert_tac 1);
paulson@3515
   204
bind_thm ("Server_cert_pubB", result() RSN (2, rev_mp));
paulson@3515
   205
paulson@3515
   206
paulson@3745
   207
(*Replace key KB in ClientKeyExch by (pubK B) *)
paulson@3745
   208
val ClientKeyExch_tac = 
paulson@3745
   209
    forward_tac [Says_imp_spies RS parts.Inj RS Server_cert_pubB]
paulson@3515
   210
    THEN' assume_tac
paulson@3515
   211
    THEN' hyp_subst_tac;
paulson@3515
   212
paulson@3515
   213
fun analz_induct_tac i = 
paulson@3515
   214
    etac tls.induct i   THEN
paulson@3745
   215
    ClientKeyExch_tac  (i+6)  THEN	(*ClientKeyExch*)
paulson@3515
   216
    ALLGOALS (asm_simp_tac 
paulson@3672
   217
              (!simpset addcongs [if_weak_cong]
paulson@3515
   218
                        setloop split_tac [expand_if]))  THEN
paulson@3515
   219
    (*Remove instances of pubK B:  the Spy already knows all public keys.
paulson@3515
   220
      Combining the two simplifier calls makes them run extremely slowly.*)
paulson@3515
   221
    ALLGOALS (asm_simp_tac 
paulson@3672
   222
              (!simpset addcongs [if_weak_cong]
paulson@3672
   223
			addsimps [insert_absorb]
paulson@3515
   224
                        setloop split_tac [expand_if]));
paulson@3515
   225
paulson@3515
   226
paulson@3758
   227
(*** Properties of items found in Notes ***)
paulson@3515
   228
paulson@3515
   229
goal thy "!!evs. [| Notes A {|Agent B, X|} : set evs;  evs : tls |]  \
paulson@3683
   230
\                ==> Crypt (pubK B) X : parts (spies evs)";
paulson@3515
   231
by (etac rev_mp 1);
paulson@3515
   232
by (analz_induct_tac 1);
paulson@3515
   233
by (blast_tac (!claset addIs [parts_insertI]) 1);
paulson@3683
   234
qed "Notes_Crypt_parts_spies";
paulson@3515
   235
paulson@3758
   236
(*C may be either A or B*)
paulson@3685
   237
goal thy
paulson@3758
   238
 "!!evs. [| Notes C {|s, Agent A, Agent B, Nonce(PRF(PMS,NA,NB))|} : set evs; \
paulson@3758
   239
\           evs : tls     \
paulson@3685
   240
\        |] ==> Crypt (pubK B) (Nonce PMS) : parts (spies evs)";
paulson@3685
   241
by (etac rev_mp 1);
paulson@3685
   242
by (parts_induct_tac 1);
paulson@3711
   243
by (ALLGOALS Clarify_tac);
paulson@3685
   244
(*Fake*)
paulson@3685
   245
by (blast_tac (!claset addIs [parts_insertI]) 1);
paulson@3685
   246
(*Client, Server Accept*)
paulson@3685
   247
by (REPEAT (blast_tac (!claset addSEs spies_partsEs
paulson@3685
   248
                               addSDs [Notes_Crypt_parts_spies]) 1));
paulson@3685
   249
qed "Notes_master_imp_Crypt_PMS";
paulson@3685
   250
paulson@3685
   251
(*Compared with the theorem above, both premise and conclusion are stronger*)
paulson@3685
   252
goal thy
paulson@3758
   253
 "!!evs. [| Notes A {|s, Agent A, Agent B, Nonce(PRF(PMS,NA,NB))|} : set evs;\
paulson@3758
   254
\           evs : tls     \
paulson@3685
   255
\        |] ==> Notes A {|Agent B, Nonce PMS|} : set evs";
paulson@3685
   256
by (etac rev_mp 1);
paulson@3685
   257
by (parts_induct_tac 1);
paulson@3685
   258
(*ServerAccepts*)
paulson@3685
   259
by (Fast_tac 1);	(*Blast_tac's very slow here*)
paulson@3685
   260
qed "Notes_master_imp_Notes_PMS";
paulson@3685
   261
paulson@3685
   262
paulson@3685
   263
(*** Protocol goal: if B receives CertVerify, then A sent it ***)
paulson@3474
   264
paulson@3745
   265
(*B can check A's signature if he has received A's certificate.*)
paulson@3519
   266
goal thy
paulson@3745
   267
 "!!evs. [| X : parts (spies evs);          \
paulson@3745
   268
\           X = Crypt (priK A) (Hash{|nb, Agent B, pms|});      \
paulson@3745
   269
\           evs : tls;  A ~: bad |]                       \
paulson@3745
   270
\    ==> Says A B X : set evs";
paulson@3745
   271
by (etac rev_mp 1);
paulson@3480
   272
by (hyp_subst_tac 1);
paulson@3519
   273
by (parts_induct_tac 1);
paulson@3474
   274
by (Fake_parts_insert_tac 1);
paulson@3745
   275
val lemma = result();
paulson@3745
   276
paulson@3745
   277
(*Final version: B checks X using the distributed KA instead of priK A*)
paulson@3745
   278
goal thy
paulson@3745
   279
 "!!evs. [| X : parts (spies evs);          \
paulson@3745
   280
\           X = Crypt (invKey KA) (Hash{|nb, Agent B, pms|});      \
paulson@3745
   281
\           certificate A KA : parts (spies evs);       \
paulson@3745
   282
\           evs : tls;  A ~: bad |]                       \
paulson@3745
   283
\    ==> Says A B X : set evs";
paulson@3745
   284
by (blast_tac (!claset addSDs [Server_cert_pubB] addSIs [lemma]) 1);
paulson@3745
   285
qed "TrustCertVerify";
paulson@3474
   286
paulson@3474
   287
paulson@3685
   288
(*If CertVerify is present then A has chosen PMS.*)
paulson@3506
   289
goal thy
paulson@3745
   290
 "!!evs. [| Crypt (priK A) (Hash{|nb, Agent B, Nonce PMS|})  \
paulson@3683
   291
\             : parts (spies evs);                                \
paulson@3683
   292
\           evs : tls;  A ~: bad |]                                      \
paulson@3672
   293
\        ==> Notes A {|Agent B, Nonce PMS|} : set evs";
paulson@3515
   294
be rev_mp 1;
paulson@3519
   295
by (parts_induct_tac 1);
paulson@3519
   296
by (Fake_parts_insert_tac 1);
paulson@3745
   297
val lemma = result();
paulson@3745
   298
paulson@3745
   299
(*Final version using the distributed KA instead of priK A*)
paulson@3745
   300
goal thy
paulson@3745
   301
 "!!evs. [| Crypt (invKey KA) (Hash{|nb, Agent B, Nonce PMS|})  \
paulson@3745
   302
\             : parts (spies evs);                                \
paulson@3745
   303
\           certificate A KA : parts (spies evs);       \
paulson@3745
   304
\           evs : tls;  A ~: bad |]                                      \
paulson@3745
   305
\        ==> Notes A {|Agent B, Nonce PMS|} : set evs";
paulson@3745
   306
by (blast_tac (!claset addSDs [Server_cert_pubB] addSIs [lemma]) 1);
paulson@3515
   307
qed "UseCertVerify";
paulson@3474
   308
paulson@3480
   309
paulson@3687
   310
(*Key compromise lemma needed to prove analz_image_keys.
paulson@3687
   311
  No collection of keys can help the spy get new private keys.*)
paulson@3480
   312
goal thy  
paulson@3480
   313
 "!!evs. evs : tls ==>                                    \
paulson@3683
   314
\  ALL KK. (Key(priK B) : analz (Key``KK Un (spies evs))) =  \
paulson@3687
   315
\          (priK B : KK | B : bad)";
paulson@3480
   316
by (etac tls.induct 1);
paulson@3515
   317
by (ALLGOALS
paulson@3519
   318
    (asm_simp_tac (analz_image_keys_ss
paulson@3677
   319
		   addsimps (analz_insert_certificate::keys_distinct))));
paulson@3480
   320
(*Fake*) 
paulson@3480
   321
by (spy_analz_tac 2);
paulson@3480
   322
(*Base*)
paulson@3480
   323
by (Blast_tac 1);
paulson@3480
   324
qed_spec_mp "analz_image_priK";
paulson@3480
   325
paulson@3480
   326
paulson@3745
   327
(*slightly speeds up the big simplification below*)
paulson@3745
   328
goal thy "!!evs. KK <= range sessionK ==> priK B ~: KK";
paulson@3745
   329
by (Blast_tac 1);
paulson@3745
   330
val range_sessionkeys_not_priK = result();
paulson@3745
   331
paulson@3480
   332
(*Lemma for the trivial direction of the if-and-only-if*)
paulson@3480
   333
goal thy  
paulson@3480
   334
 "!!evs. (X : analz (G Un H)) --> (X : analz H)  ==> \
paulson@3480
   335
\        (X : analz (G Un H))  =  (X : analz H)";
paulson@3480
   336
by (blast_tac (!claset addIs [impOfSubs analz_mono]) 1);
paulson@3480
   337
val lemma = result();
paulson@3480
   338
paulson@3687
   339
(** It is a mystery to me why the following formulation is actually slower
paulson@3687
   340
    in simplification:
paulson@3687
   341
paulson@3687
   342
\    ALL Z. (Nonce N : analz (Key``(sessionK``Z) Un (spies evs))) = \
paulson@3687
   343
\           (Nonce N : analz (spies evs))";
paulson@3687
   344
paulson@3687
   345
More so as it can take advantage of unconditional rewrites such as 
paulson@3687
   346
     priK B ~: sessionK``Z
paulson@3687
   347
**)
paulson@3687
   348
paulson@3480
   349
goal thy  
paulson@3480
   350
 "!!evs. evs : tls ==>                                 \
paulson@3677
   351
\    ALL KK. KK <= range sessionK -->           \
paulson@3683
   352
\            (Nonce N : analz (Key``KK Un (spies evs))) = \
paulson@3683
   353
\            (Nonce N : analz (spies evs))";
paulson@3480
   354
by (etac tls.induct 1);
paulson@3745
   355
by (ClientKeyExch_tac 7);
paulson@3480
   356
by (REPEAT_FIRST (resolve_tac [allI, impI]));
paulson@3515
   357
by (REPEAT_FIRST (rtac lemma));
paulson@3745
   358
by (ALLGOALS    (*23 seconds*)
paulson@3515
   359
    (asm_simp_tac (analz_image_keys_ss 
paulson@3677
   360
		   addsimps [range_sessionkeys_not_priK, 
paulson@3677
   361
			     analz_image_priK, analz_insert_certificate])));
paulson@3515
   362
by (ALLGOALS (asm_simp_tac (!simpset addsimps [insert_absorb])));
paulson@3480
   363
(*Fake*) 
paulson@3480
   364
by (spy_analz_tac 2);
paulson@3480
   365
(*Base*)
paulson@3480
   366
by (Blast_tac 1);
paulson@3480
   367
qed_spec_mp "analz_image_keys";
paulson@3480
   368
paulson@3687
   369
(*Knowing some session keys is no help in getting new nonces*)
paulson@3687
   370
goal thy
paulson@3687
   371
 "!!evs. evs : tls ==>          \
paulson@3687
   372
\        Nonce N : analz (insert (Key (sessionK z)) (spies evs)) =  \
paulson@3687
   373
\        (Nonce N : analz (spies evs))";
paulson@3687
   374
by (asm_simp_tac (analz_image_keys_ss addsimps [analz_image_keys]) 1);
paulson@3687
   375
qed "analz_insert_key";
paulson@3687
   376
Addsimps [analz_insert_key];
paulson@3480
   377
paulson@3672
   378
goal thy "!!evs. evs : tls ==> Notes A {|Agent B, Nonce (PRF x)|} ~: set evs";
paulson@3672
   379
by (parts_induct_tac 1);
paulson@3745
   380
(*ClientKeyExch: PMS is assumed to differ from any PRF.*)
paulson@3672
   381
by (Blast_tac 1);
paulson@3672
   382
qed "no_Notes_A_PRF";
paulson@3672
   383
Addsimps [no_Notes_A_PRF];
paulson@3672
   384
paulson@3672
   385
paulson@3683
   386
goal thy "!!evs. [| Nonce (PRF (PMS,NA,NB)) : parts (spies evs);  \
paulson@3672
   387
\                   evs : tls |]  \
paulson@3683
   388
\                ==> Nonce PMS : parts (spies evs)";
paulson@3672
   389
by (etac rev_mp 1);
paulson@3672
   390
by (parts_induct_tac 1);
paulson@3683
   391
by (ALLGOALS (asm_simp_tac (!simpset addsimps [parts_insert_spies])));
paulson@3672
   392
by (Fake_parts_insert_tac 1);
paulson@3677
   393
(*Six others, all trivial or by freshness*)
paulson@3683
   394
by (REPEAT (blast_tac (!claset addSDs [Notes_Crypt_parts_spies]
paulson@3683
   395
                               addSEs spies_partsEs) 1));
paulson@3672
   396
qed "MS_imp_PMS";
paulson@3672
   397
AddSDs [MS_imp_PMS];
paulson@3672
   398
paulson@3672
   399
paulson@3474
   400
paulson@3745
   401
(*** Protocol goal: serverK(Na,Nb,M) and clientK(Na,Nb,M) remain secure ***)
paulson@3474
   402
paulson@3677
   403
(** Some lemmas about session keys, comprising clientK and serverK **)
paulson@3515
   404
paulson@3515
   405
paulson@3704
   406
(*Lemma: session keys are never used if PMS is fresh.  
paulson@3704
   407
  Nonces don't have to agree, allowing session resumption.
paulson@3704
   408
  Converse doesn't hold; revealing PMS doesn't force the keys to be sent.
paulson@3704
   409
  THEY ARE NOT SUITABLE AS SAFE ELIM RULES.*)
paulson@3704
   410
goal thy 
paulson@3704
   411
 "!!evs. [| Nonce PMS ~: parts (spies evs);  \
paulson@3704
   412
\           K = sessionK((Na, Nb, PRF(PMS,NA,NB)), b);  \
paulson@3704
   413
\           evs : tls |]             \
paulson@3704
   414
\  ==> Key K ~: parts (spies evs) & (ALL Y. Crypt K Y ~: parts (spies evs))";
paulson@3704
   415
by (etac rev_mp 1);
paulson@3704
   416
by (hyp_subst_tac 1);
paulson@3704
   417
by (analz_induct_tac 1);
paulson@3704
   418
(*SpyKeys*)
paulson@3704
   419
by (blast_tac (!claset addSEs spies_partsEs) 3);
paulson@3704
   420
(*Fake*)
paulson@3704
   421
by (simp_tac (!simpset addsimps [parts_insert_spies]) 2);
paulson@3704
   422
by (Fake_parts_insert_tac 2);
paulson@3704
   423
(** LEVEL 6 **)
paulson@3704
   424
(*Oops*)
paulson@3704
   425
by (fast_tac (!claset addSEs [MPair_parts]
paulson@3704
   426
		       addDs  [Says_imp_spies RS parts.Inj]
paulson@3704
   427
		       addss (!simpset)) 6);
paulson@3704
   428
by (REPEAT 
paulson@3704
   429
    (blast_tac (!claset addSDs [Notes_Crypt_parts_spies, 
paulson@3704
   430
				Notes_master_imp_Crypt_PMS]
paulson@3704
   431
                        addSEs spies_partsEs) 1));
paulson@3704
   432
val lemma = result();
paulson@3704
   433
paulson@3704
   434
goal thy 
paulson@3704
   435
 "!!evs. [| Nonce PMS ~: parts (spies evs);  evs : tls |]             \
paulson@3704
   436
\  ==> Key (sessionK((Na, Nb, PRF(PMS,NA,NB)), b)) ~: parts (spies evs)";
paulson@3704
   437
by (blast_tac (!claset addDs [lemma]) 1);
paulson@3704
   438
qed "PMS_sessionK_not_spied";
paulson@3704
   439
paulson@3704
   440
goal thy 
paulson@3704
   441
 "!!evs. [| Nonce PMS ~: parts (spies evs);  evs : tls |]             \
paulson@3704
   442
\  ==> Crypt (sessionK((Na, Nb, PRF(PMS,NA,NB)), b)) Y ~: parts (spies evs)";
paulson@3704
   443
by (blast_tac (!claset addDs [lemma]) 1);
paulson@3704
   444
qed "PMS_Crypt_sessionK_not_spied";
paulson@3704
   445
paulson@3704
   446
paulson@3704
   447
(*Lemma: write keys are never sent if M (MASTER SECRET) is secure.  
paulson@3704
   448
  Converse doesn't hold; betraying M doesn't force the keys to be sent!
paulson@3704
   449
  The strong Oops condition can be weakened later by unicity reasoning, 
paulson@3704
   450
	with some effort.*)
paulson@3474
   451
goal thy 
paulson@3686
   452
 "!!evs. [| ALL A. Says A Spy (Key (sessionK((NA,NB,M),b))) ~: set evs; \
paulson@3686
   453
\           Nonce M ~: analz (spies evs);  evs : tls |]   \
paulson@3686
   454
\        ==> Key (sessionK((NA,NB,M),b)) ~: parts (spies evs)";
paulson@3686
   455
by (etac rev_mp 1);
paulson@3480
   456
by (etac rev_mp 1);
paulson@3745
   457
by (analz_induct_tac 1);        (*17 seconds*)
paulson@3686
   458
(*Oops*)
paulson@3686
   459
by (Blast_tac 4);
paulson@3480
   460
(*SpyKeys*)
paulson@3683
   461
by (blast_tac (!claset addDs [Says_imp_spies RS analz.Inj]) 3);
paulson@3480
   462
(*Fake*) 
paulson@3480
   463
by (spy_analz_tac 2);
paulson@3480
   464
(*Base*)
paulson@3480
   465
by (Blast_tac 1);
paulson@3704
   466
qed "sessionK_not_spied";
paulson@3704
   467
Addsimps [sessionK_not_spied];
paulson@3515
   468
paulson@3515
   469
paulson@3672
   470
(*** Unicity results for PMS, the pre-master-secret ***)
paulson@3515
   471
paulson@3672
   472
(*PMS determines B.  Proof borrowed from NS_Public/unique_NA and from Yahalom*)
paulson@3515
   473
goal thy 
paulson@3683
   474
 "!!evs. [| Nonce PMS ~: analz (spies evs);  evs : tls |]   \
paulson@3515
   475
\        ==> EX B'. ALL B.   \
paulson@3683
   476
\              Crypt (pubK B) (Nonce PMS) : parts (spies evs) --> B=B'";
paulson@3515
   477
by (etac rev_mp 1);
paulson@3519
   478
by (parts_induct_tac 1);
paulson@3519
   479
by (Fake_parts_insert_tac 1);
paulson@3745
   480
(*ClientKeyExch*)
paulson@3745
   481
by (ClientKeyExch_tac 1);
paulson@3519
   482
by (asm_simp_tac (!simpset addsimps [all_conj_distrib]) 1);
paulson@3672
   483
by (expand_case_tac "PMS = ?y" 1 THEN
paulson@3519
   484
    blast_tac (!claset addSEs partsEs) 1);
paulson@3515
   485
val lemma = result();
paulson@3515
   486
paulson@3515
   487
goal thy 
paulson@3683
   488
 "!!evs. [| Crypt(pubK B)  (Nonce PMS) : parts (spies evs); \
paulson@3683
   489
\           Crypt(pubK B') (Nonce PMS) : parts (spies evs); \
paulson@3683
   490
\           Nonce PMS ~: analz (spies evs);                 \
paulson@3515
   491
\           evs : tls |]                                          \
paulson@3515
   492
\        ==> B=B'";
paulson@3515
   493
by (prove_unique_tac lemma 1);
paulson@3704
   494
qed "Crypt_unique_PMS";
paulson@3704
   495
paulson@3515
   496
paulson@3685
   497
(** It is frustrating that we need two versions of the unicity results.
paulson@3704
   498
    But Notes A {|Agent B, Nonce PMS|} determines both A and B.  Sometimes
paulson@3704
   499
    we have only the weaker assertion Crypt(pubK B) (Nonce PMS), which 
paulson@3704
   500
    determines B alone, and only if PMS is secret.
paulson@3685
   501
**)
paulson@3515
   502
paulson@3677
   503
(*In A's internal Note, PMS determines A and B.*)
paulson@3704
   504
goal thy "!!evs. evs : tls               \
paulson@3704
   505
\                ==> EX A' B'. ALL A B.  \
paulson@3704
   506
\                    Notes A {|Agent B, Nonce PMS|} : set evs --> A=A' & B=B'";
paulson@3519
   507
by (parts_induct_tac 1);
paulson@3515
   508
by (asm_simp_tac (!simpset addsimps [all_conj_distrib]) 1);
paulson@3745
   509
(*ClientKeyExch: if PMS is fresh, then it can't appear in Notes A X.*)
paulson@3672
   510
by (expand_case_tac "PMS = ?y" 1 THEN
paulson@3683
   511
    blast_tac (!claset addSDs [Notes_Crypt_parts_spies] addSEs partsEs) 1);
paulson@3515
   512
val lemma = result();
paulson@3515
   513
paulson@3515
   514
goal thy 
paulson@3672
   515
 "!!evs. [| Notes A  {|Agent B,  Nonce PMS|} : set evs;  \
paulson@3672
   516
\           Notes A' {|Agent B', Nonce PMS|} : set evs;  \
paulson@3515
   517
\           evs : tls |]                               \
paulson@3515
   518
\        ==> A=A' & B=B'";
paulson@3515
   519
by (prove_unique_tac lemma 1);
paulson@3672
   520
qed "Notes_unique_PMS";
paulson@3515
   521
paulson@3515
   522
paulson@3474
   523
paulson@3745
   524
(*If A sends ClientKeyExch to an honest B, then the PMS will stay secret.*)
paulson@3677
   525
goal thy
paulson@3683
   526
 "!!evs. [| evs : tls;  A ~: bad;  B ~: bad |]           \
paulson@3677
   527
\        ==> Notes A {|Agent B, Nonce PMS|} : set evs  -->   \
paulson@3683
   528
\            Nonce PMS ~: analz (spies evs)";
paulson@3745
   529
by (analz_induct_tac 1);   (*11 seconds*)
paulson@3677
   530
(*ClientAccepts and ServerAccepts: because PMS ~: range PRF*)
paulson@3745
   531
by (REPEAT (fast_tac (!claset addss (!simpset)) 6));
paulson@3745
   532
(*ClientHello, ServerHello, ClientKeyExch, ServerResume: 
paulson@3687
   533
  mostly freshness reasoning*)
paulson@3677
   534
by (REPEAT (blast_tac (!claset addSEs partsEs
paulson@3683
   535
			       addDs  [Notes_Crypt_parts_spies,
paulson@3677
   536
				       impOfSubs analz_subset_parts,
paulson@3687
   537
				       Says_imp_spies RS analz.Inj]) 3));
paulson@3677
   538
(*SpyKeys*)
paulson@3677
   539
by (fast_tac (!claset addss (!simpset)) 2);
paulson@3677
   540
(*Fake*)
paulson@3677
   541
by (spy_analz_tac 1);
paulson@3677
   542
bind_thm ("Spy_not_see_PMS", result() RSN (2, rev_mp));
paulson@3677
   543
paulson@3677
   544
paulson@3745
   545
(*If A sends ClientKeyExch to an honest B, then the MASTER SECRET
paulson@3677
   546
  will stay secret.*)
paulson@3677
   547
goal thy
paulson@3683
   548
 "!!evs. [| evs : tls;  A ~: bad;  B ~: bad |]           \
paulson@3677
   549
\        ==> Notes A {|Agent B, Nonce PMS|} : set evs  -->   \
paulson@3683
   550
\            Nonce (PRF(PMS,NA,NB)) ~: analz (spies evs)";
paulson@3745
   551
by (analz_induct_tac 1);   (*13 seconds*)
paulson@3677
   552
(*ClientAccepts and ServerAccepts: because PMS was already visible*)
paulson@3677
   553
by (REPEAT (blast_tac (!claset addDs [Spy_not_see_PMS, 
paulson@3683
   554
				      Says_imp_spies RS analz.Inj,
paulson@3683
   555
				      Notes_imp_spies RS analz.Inj]) 6));
paulson@3677
   556
(*ClientHello*)
paulson@3677
   557
by (Blast_tac 3);
paulson@3677
   558
(*SpyKeys: by secrecy of the PMS, Spy cannot make the MS*)
paulson@3677
   559
by (blast_tac (!claset addSDs [Spy_not_see_PMS, 
paulson@3683
   560
			       Says_imp_spies RS analz.Inj]) 2);
paulson@3677
   561
(*Fake*)
paulson@3677
   562
by (spy_analz_tac 1);
paulson@3745
   563
(*ServerHello and ClientKeyExch: mostly freshness reasoning*)
paulson@3677
   564
by (REPEAT (blast_tac (!claset addSEs partsEs
paulson@3683
   565
			       addDs  [Notes_Crypt_parts_spies,
paulson@3677
   566
				       impOfSubs analz_subset_parts,
paulson@3683
   567
				       Says_imp_spies RS analz.Inj]) 1));
paulson@3677
   568
bind_thm ("Spy_not_see_MS", result() RSN (2, rev_mp));
paulson@3677
   569
paulson@3677
   570
paulson@3704
   571
(*** Weakening the Oops conditions for leakage of clientK ***)
paulson@3704
   572
paulson@3704
   573
(*If A created PMS then nobody other than the Spy would send a message
paulson@3704
   574
  using a clientK generated from that PMS.*)
paulson@3704
   575
goal thy
paulson@3704
   576
 "!!evs. [| evs : tls;  A' ~= Spy |]                \
paulson@3704
   577
\  ==> Notes A {|Agent B, Nonce PMS|} : set evs -->                  \
paulson@3704
   578
\      Says A' B' (Crypt (clientK(Na,Nb,PRF(PMS,NA,NB))) Y) : set evs -->  \
paulson@3704
   579
\      A = A'";
paulson@3745
   580
by (analz_induct_tac 1);	(*8 seconds*)
paulson@3711
   581
by (ALLGOALS Clarify_tac);
paulson@3704
   582
(*ClientFinished, ClientResume: by unicity of PMS*)
paulson@3704
   583
by (REPEAT 
paulson@3704
   584
    (blast_tac (!claset addSDs [Notes_master_imp_Notes_PMS]
paulson@3704
   585
     	 	        addIs  [Notes_unique_PMS RS conjunct1]) 2));
paulson@3745
   586
(*ClientKeyExch*)
paulson@3704
   587
by (blast_tac (!claset addSEs [PMS_Crypt_sessionK_not_spied RSN (2,rev_notE)]
paulson@3704
   588
	               addSDs [Says_imp_spies RS parts.Inj]) 1);
paulson@3704
   589
bind_thm ("Says_clientK_unique",
paulson@3704
   590
	  result() RSN(2,rev_mp) RSN(2,rev_mp));
paulson@3704
   591
paulson@3704
   592
paulson@3704
   593
(*If A created PMS and has not leaked her clientK to the Spy, 
paulson@3704
   594
  then nobody has.*)
paulson@3704
   595
goal thy
paulson@3704
   596
 "!!evs. evs : tls                         \
paulson@3704
   597
\  ==> Says A Spy (Key(clientK(Na,Nb,PRF(PMS,NA,NB)))) ~: set evs --> \
paulson@3704
   598
\      Notes A {|Agent B, Nonce PMS|} : set evs -->                   \
paulson@3704
   599
\      (ALL A. Says A Spy (Key(clientK(Na,Nb,PRF(PMS,NA,NB)))) ~: set evs) ";
paulson@3704
   600
by (etac tls.induct 1);
paulson@3704
   601
(*This roundabout proof sequence avoids looping in simplification*)
paulson@3704
   602
by (ALLGOALS Simp_tac);
paulson@3711
   603
by (ALLGOALS Clarify_tac);
paulson@3704
   604
by (Fake_parts_insert_tac 1);
paulson@3704
   605
by (ALLGOALS Asm_simp_tac);
paulson@3704
   606
(*Oops*)
paulson@3704
   607
by (blast_tac (!claset addIs [Says_clientK_unique]) 2);
paulson@3745
   608
(*ClientKeyExch*)
paulson@3704
   609
by (blast_tac (!claset addSEs ((PMS_sessionK_not_spied RSN (2,rev_notE)) ::
paulson@3704
   610
			       spies_partsEs)) 1);
paulson@3704
   611
qed_spec_mp "clientK_Oops_ALL";
paulson@3704
   612
paulson@3704
   613
paulson@3704
   614
paulson@3704
   615
(*** Weakening the Oops conditions for leakage of serverK ***)
paulson@3704
   616
paulson@3704
   617
(*If A created PMS for B, then nobody other than B or the Spy would
paulson@3704
   618
  send a message using a serverK generated from that PMS.*)
paulson@3704
   619
goal thy
paulson@3704
   620
 "!!evs. [| evs : tls;  A ~: bad;  B ~: bad;  B' ~= Spy |]                \
paulson@3704
   621
\  ==> Notes A {|Agent B, Nonce PMS|} : set evs -->                  \
paulson@3704
   622
\      Says B' A' (Crypt (serverK(Na,Nb,PRF(PMS,NA,NB))) Y) : set evs -->  \
paulson@3704
   623
\      B = B'";
paulson@3745
   624
by (analz_induct_tac 1);	(*9 seconds*)
paulson@3711
   625
by (ALLGOALS Clarify_tac);
paulson@3704
   626
(*ServerResume, ServerFinished: by unicity of PMS*)
paulson@3704
   627
by (REPEAT
paulson@3704
   628
    (blast_tac (!claset addSEs [MPair_parts]
paulson@3704
   629
		        addSDs [Notes_master_imp_Crypt_PMS, 
paulson@3704
   630
				Says_imp_spies RS parts.Inj]
paulson@3704
   631
                        addDs  [Spy_not_see_PMS, 
paulson@3704
   632
				Notes_Crypt_parts_spies,
paulson@3704
   633
				Crypt_unique_PMS]) 2));
paulson@3745
   634
(*ClientKeyExch*)
paulson@3704
   635
by (blast_tac (!claset addSEs [PMS_Crypt_sessionK_not_spied RSN (2,rev_notE)]
paulson@3704
   636
	               addSDs [Says_imp_spies RS parts.Inj]) 1);
paulson@3704
   637
bind_thm ("Says_serverK_unique",
paulson@3704
   638
	  result() RSN(2,rev_mp) RSN(2,rev_mp));
paulson@3704
   639
paulson@3704
   640
(*If A created PMS for B, and B has not leaked his serverK to the Spy, 
paulson@3704
   641
  then nobody has.*)
paulson@3704
   642
goal thy
paulson@3704
   643
 "!!evs. [| evs : tls;  A ~: bad;  B ~: bad |]                        \
paulson@3704
   644
\  ==> Says B Spy (Key(serverK(Na,Nb,PRF(PMS,NA,NB)))) ~: set evs --> \
paulson@3704
   645
\      Notes A {|Agent B, Nonce PMS|} : set evs -->                   \
paulson@3704
   646
\      (ALL A. Says A Spy (Key(serverK(Na,Nb,PRF(PMS,NA,NB)))) ~: set evs) ";
paulson@3704
   647
by (etac tls.induct 1);
paulson@3704
   648
(*This roundabout proof sequence avoids looping in simplification*)
paulson@3704
   649
by (ALLGOALS Simp_tac);
paulson@3711
   650
by (ALLGOALS Clarify_tac);
paulson@3704
   651
by (Fake_parts_insert_tac 1);
paulson@3704
   652
by (ALLGOALS Asm_simp_tac);
paulson@3704
   653
(*Oops*)
paulson@3704
   654
by (blast_tac (!claset addIs [Says_serverK_unique]) 2);
paulson@3745
   655
(*ClientKeyExch*)
paulson@3704
   656
by (blast_tac (!claset addSEs ((PMS_sessionK_not_spied RSN (2,rev_notE)) ::
paulson@3704
   657
			       spies_partsEs)) 1);
paulson@3704
   658
qed_spec_mp "serverK_Oops_ALL";
paulson@3704
   659
paulson@3704
   660
paulson@3704
   661
paulson@3685
   662
(*** Protocol goals: if A receives ServerFinished, then B is present 
paulson@3729
   663
     and has used the quoted values PA, PB, etc.  Note that it is up to A
paulson@3729
   664
     to compare PA with what she originally sent.
paulson@3474
   665
***)
paulson@3474
   666
paulson@3685
   667
(*The mention of her name (A) in X assures A that B knows who she is.*)
paulson@3515
   668
goal thy
paulson@3686
   669
 "!!evs. [| ALL A. Says A Spy (Key (serverK(Na,Nb,M))) ~: set evs; \
paulson@3686
   670
\           X = Crypt (serverK(Na,Nb,M))                  \
paulson@3758
   671
\                 (Hash{|Number SID, Nonce M,             \
paulson@3745
   672
\                        Nonce Na, Number PA, Agent A,    \
paulson@3745
   673
\                        Nonce Nb, Number PB, Agent B|}); \
paulson@3676
   674
\           M = PRF(PMS,NA,NB);                           \
paulson@3683
   675
\           evs : tls;  A ~: bad;  B ~: bad |]          \
paulson@3676
   676
\        ==> Notes A {|Agent B, Nonce PMS|} : set evs --> \
paulson@3683
   677
\        X : parts (spies evs) --> Says B A X : set evs";
paulson@3686
   678
by (etac rev_mp 1);
paulson@3480
   679
by (hyp_subst_tac 1);
paulson@3745
   680
by (analz_induct_tac 1);        (*22 seconds*)
paulson@3704
   681
by (ALLGOALS (asm_simp_tac (!simpset addsimps [all_conj_distrib])));
paulson@3711
   682
(*proves ServerResume*)
paulson@3711
   683
by (ALLGOALS Clarify_tac);
paulson@3745
   684
(*ClientKeyExch*)
paulson@3704
   685
by (fast_tac  (*blast_tac gives PROOF FAILED*)
paulson@3704
   686
    (!claset addSEs [PMS_Crypt_sessionK_not_spied RSN (2,rev_notE)]) 2);
paulson@3480
   687
(*Fake: the Spy doesn't have the critical session key!*)
paulson@3683
   688
by (subgoal_tac "Key (serverK(Na,Nb,PRF(PMS,NA,NB))) ~: analz(spies evsa)" 1);
paulson@3672
   689
by (asm_simp_tac (!simpset addsimps [Spy_not_see_MS, 
paulson@3480
   690
				     not_parts_not_analz]) 2);
paulson@3474
   691
by (Fake_parts_insert_tac 1);
paulson@3704
   692
val lemma = normalize_thm [RSspec, RSmp] (result());
paulson@3704
   693
paulson@3704
   694
(*Final version*)
paulson@3704
   695
goal thy
paulson@3704
   696
 "!!evs. [| X = Crypt (serverK(Na,Nb,M))                  \
paulson@3758
   697
\                 (Hash{|Number SID, Nonce M,             \
paulson@3745
   698
\                        Nonce Na, Number PA, Agent A,    \
paulson@3745
   699
\                        Nonce Nb, Number PB, Agent B|}); \
paulson@3704
   700
\           M = PRF(PMS,NA,NB);                           \
paulson@3704
   701
\           X : parts (spies evs);                        \
paulson@3704
   702
\           Notes A {|Agent B, Nonce PMS|} : set evs;     \
paulson@3704
   703
\           Says B Spy (Key (serverK(Na,Nb,M))) ~: set evs; \
paulson@3704
   704
\           evs : tls;  A ~: bad;  B ~: bad |]          \
paulson@3704
   705
\        ==> Says B A X : set evs";
paulson@3704
   706
by (blast_tac (!claset addIs [lemma]
paulson@3704
   707
                       addEs [serverK_Oops_ALL RSN(2, rev_notE)]) 1);
paulson@3474
   708
qed_spec_mp "TrustServerFinished";
paulson@3474
   709
paulson@3474
   710
paulson@3704
   711
paulson@3685
   712
(*This version refers not to ServerFinished but to any message from B.
paulson@3685
   713
  We don't assume B has received CertVerify, and an intruder could
paulson@3515
   714
  have changed A's identity in all other messages, so we can't be sure
paulson@3519
   715
  that B sends his message to A.  If CLIENT KEY EXCHANGE were augmented
paulson@3704
   716
  to bind A's identity with PMS, then we could replace A' by A below.*)
paulson@3515
   717
goal thy
paulson@3686
   718
 "!!evs. [| ALL A. Says A Spy (Key (serverK(Na,Nb,M))) ~: set evs; \
paulson@3686
   719
\           evs : tls;  A ~: bad;  B ~: bad;                 \
paulson@3672
   720
\           M = PRF(PMS,NA,NB) |]            \
paulson@3672
   721
\        ==> Notes A {|Agent B, Nonce PMS|} : set evs -->              \
paulson@3683
   722
\            Crypt (serverK(Na,Nb,M)) Y : parts (spies evs)  -->  \
paulson@3672
   723
\            (EX A'. Says B A' (Crypt (serverK(Na,Nb,M)) Y) : set evs)";
paulson@3686
   724
by (etac rev_mp 1);
paulson@3672
   725
by (hyp_subst_tac 1);
paulson@3686
   726
by (analz_induct_tac 1);	(*20 seconds*)
paulson@3704
   727
by (ALLGOALS (asm_simp_tac (!simpset addsimps [ex_disj_distrib])));
paulson@3711
   728
by (ALLGOALS Clarify_tac);
paulson@3704
   729
(*ServerResume, ServerFinished: by unicity of PMS*)
paulson@3704
   730
by (REPEAT
paulson@3704
   731
    (blast_tac (!claset addSEs [MPair_parts]
paulson@3704
   732
		        addSDs [Notes_master_imp_Crypt_PMS, 
paulson@3704
   733
				Says_imp_spies RS parts.Inj]
paulson@3704
   734
                        addDs  [Spy_not_see_PMS, 
paulson@3704
   735
				Notes_Crypt_parts_spies,
paulson@3704
   736
				Crypt_unique_PMS]) 3));
paulson@3745
   737
(*ClientKeyExch*)
paulson@3704
   738
by (blast_tac
paulson@3704
   739
    (!claset addSEs [PMS_Crypt_sessionK_not_spied RSN (2,rev_notE)]) 2);
paulson@3515
   740
(*Fake: the Spy doesn't have the critical session key!*)
paulson@3683
   741
by (subgoal_tac "Key (serverK(Na,Nb,PRF(PMS,NA,NB))) ~: analz(spies evsa)" 1);
paulson@3672
   742
by (asm_simp_tac (!simpset addsimps [Spy_not_see_MS, 
paulson@3515
   743
				     not_parts_not_analz]) 2);
paulson@3515
   744
by (Fake_parts_insert_tac 1);
paulson@3704
   745
val lemma = normalize_thm [RSspec, RSmp] (result());
paulson@3704
   746
paulson@3704
   747
(*Final version*)
paulson@3704
   748
goal thy
paulson@3704
   749
 "!!evs. [| M = PRF(PMS,NA,NB);                           \
paulson@3704
   750
\           Crypt (serverK(Na,Nb,M)) Y : parts (spies evs); \
paulson@3704
   751
\           Notes A {|Agent B, Nonce PMS|} : set evs;     \
paulson@3704
   752
\           Says B Spy (Key (serverK(Na,Nb,M))) ~: set evs; \
paulson@3704
   753
\           evs : tls;  A ~: bad;  B ~: bad |]          \
paulson@3704
   754
\        ==> EX A'. Says B A' (Crypt (serverK(Na,Nb,M)) Y) : set evs";
paulson@3704
   755
by (blast_tac (!claset addIs [lemma]
paulson@3704
   756
                       addEs [serverK_Oops_ALL RSN(2, rev_notE)]) 1);
paulson@3704
   757
paulson@3515
   758
qed_spec_mp "TrustServerMsg";
paulson@3515
   759
paulson@3515
   760
paulson@3704
   761
paulson@3515
   762
(*** Protocol goal: if B receives any message encrypted with clientK
paulson@3672
   763
     then A has sent it, ASSUMING that A chose PMS.  Authentication is
paulson@3515
   764
     assumed here; B cannot verify it.  But if the message is
paulson@3729
   765
     ClientFinished, then B can then check the quoted values PA, PB, etc.
paulson@3506
   766
***)
paulson@3704
   767
paulson@3515
   768
goal thy
paulson@3683
   769
 "!!evs. [| evs : tls;  A ~: bad;  B ~: bad |]                         \
paulson@3686
   770
\  ==> (ALL A. Says A Spy (Key(clientK(Na,Nb,PRF(PMS,NA,NB)))) ~: set evs) -->\
paulson@3686
   771
\      Notes A {|Agent B, Nonce PMS|} : set evs -->                  \
paulson@3683
   772
\      Crypt (clientK(Na,Nb,PRF(PMS,NA,NB))) Y : parts (spies evs) -->  \
paulson@3672
   773
\      Says A B (Crypt (clientK(Na,Nb,PRF(PMS,NA,NB))) Y) : set evs";
paulson@3745
   774
by (analz_induct_tac 1);	(*15 seconds*)
paulson@3711
   775
by (ALLGOALS Clarify_tac);
paulson@3704
   776
(*ClientFinished, ClientResume: by unicity of PMS*)
paulson@3704
   777
by (REPEAT (blast_tac (!claset delrules [conjI]
paulson@3704
   778
		               addSDs [Notes_master_imp_Notes_PMS]
paulson@3704
   779
	 	               addDs  [Notes_unique_PMS]) 3));
paulson@3745
   780
(*ClientKeyExch*)
paulson@3704
   781
by (fast_tac  (*blast_tac gives PROOF FAILED*)
paulson@3704
   782
    (!claset addSEs [PMS_Crypt_sessionK_not_spied RSN (2,rev_notE)]) 2);
paulson@3480
   783
(*Fake: the Spy doesn't have the critical session key!*)
paulson@3683
   784
by (subgoal_tac "Key (clientK(Na,Nb,PRF(PMS,NA,NB))) ~: analz(spies evsa)" 1);
paulson@3672
   785
by (asm_simp_tac (!simpset addsimps [Spy_not_see_MS, 
paulson@3480
   786
				     not_parts_not_analz]) 2);
paulson@3474
   787
by (Fake_parts_insert_tac 1);
paulson@3704
   788
val lemma = normalize_thm [RSspec, RSmp] (result());
paulson@3704
   789
paulson@3704
   790
(*Final version*)
paulson@3704
   791
goal thy
paulson@3704
   792
 "!!evs. [| Crypt (clientK(Na,Nb,PRF(PMS,NA,NB))) Y : parts (spies evs);  \
paulson@3704
   793
\           Notes A {|Agent B, Nonce PMS|} : set evs;        \
paulson@3704
   794
\           Says A Spy (Key(clientK(Na,Nb,PRF(PMS,NA,NB)))) ~: set evs;  \
paulson@3704
   795
\           evs : tls;  A ~: bad;  B ~: bad |]                         \
paulson@3704
   796
\  ==> Says A B (Crypt (clientK(Na,Nb,PRF(PMS,NA,NB))) Y) : set evs";
paulson@3704
   797
by (blast_tac (!claset addIs [lemma]
paulson@3704
   798
                       addEs [clientK_Oops_ALL RSN(2, rev_notE)]) 1);
paulson@3515
   799
qed_spec_mp "TrustClientMsg";
paulson@3506
   800
paulson@3506
   801
paulson@3685
   802
paulson@3685
   803
(*** Protocol goal: if B receives ClientFinished, and if B is able to
paulson@3685
   804
     check a CertVerify from A, then A has used the quoted
paulson@3729
   805
     values PA, PB, etc.  Even this one requires A to be uncompromised.
paulson@3506
   806
 ***)
paulson@3506
   807
goal thy
paulson@3704
   808
 "!!evs. [| Says A Spy (Key(clientK(Na,Nb,PRF(PMS,NA,NB)))) ~: set evs;\
paulson@3686
   809
\           Says A' B (Crypt (clientK(Na,Nb,PRF(PMS,NA,NB))) Y) : set evs; \
paulson@3745
   810
\           certificate A KA : parts (spies evs);       \
paulson@3745
   811
\           Says A'' B (Crypt (invKey KA) (Hash{|nb, Agent B, Nonce PMS|}))\
paulson@3515
   812
\             : set evs;                                                  \
paulson@3683
   813
\        evs : tls;  A ~: bad;  B ~: bad |]                             \
paulson@3672
   814
\     ==> Says A B (Crypt (clientK(Na,Nb,PRF(PMS,NA,NB))) Y) : set evs";
paulson@3515
   815
by (blast_tac (!claset addSIs [TrustClientMsg, UseCertVerify]
paulson@3683
   816
                       addDs  [Says_imp_spies RS parts.Inj]) 1);
paulson@3515
   817
qed "AuthClientFinished";
paulson@3687
   818
paulson@3687
   819
(*22/9/97: loads in 622s, which is 10 minutes 22 seconds*)
paulson@3711
   820
(*24/9/97: loads in 672s, which is 11 minutes 12 seconds [stronger theorems]*)
paulson@3745
   821
(*29/9/97: loads in 481s, after removing Certificate from ClientKeyExch*)
paulson@3758
   822
(*30/9/97: loads in 476s, after removing unused theorems*)