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