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