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