src/HOL/Auth/TLS.ML
author paulson
Mon Jul 07 10:49:14 1997 +0200 (1997-07-07)
changeset 3506 a36e0a49d2cd
parent 3500 0d8ad2f192d8
child 3515 d8a71f6eaf40
permissions -rw-r--r--
New proofs involving CERTIFICATE VERIFY
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@3474
     6
The public-key model has a weakness, especially concerning anonymous sessions.
paulson@3480
     7
The Spy's state is recorded as the trace of message.  But if he himself is the
paulson@3500
     8
Client and invents M, then he encrypts M with B's public key before sending
paulson@3500
     9
it.  This message gives no evidence that the spy knows M, and yet the spy
paulson@3500
    10
actually chose M!  So, in any property concerning the secrecy of some item,
paulson@3500
    11
one must establish that the spy didn't choose the item.  Guarantees normally
paulson@3500
    12
assume that the other party is uncompromised (otherwise, one can prove
paulson@3500
    13
little).
paulson@3480
    14
paulson@3480
    15
Protocol goals: 
paulson@3480
    16
* M, serverK(NA,NB,M) and clientK(NA,NB,M) will be known only to the two
paulson@3480
    17
     parties (though A is not necessarily authenticated).
paulson@3480
    18
paulson@3480
    19
* B upon receiving CERTIFICATE VERIFY knows that A is present (But this
paulson@3480
    20
    message is optional!)
paulson@3474
    21
paulson@3480
    22
* A upon receiving SERVER FINISHED knows that B is present
paulson@3480
    23
paulson@3480
    24
* Each party who has received a FINISHED message can trust that the other
paulson@3480
    25
  party agrees on all message components, including XA and XB (thus foiling
paulson@3480
    26
  rollback attacks).
paulson@3474
    27
*)
paulson@3474
    28
paulson@3474
    29
open TLS;
paulson@3474
    30
paulson@3474
    31
proof_timing:=true;
paulson@3474
    32
HOL_quantifiers := false;
paulson@3474
    33
paulson@3474
    34
AddIffs [Spy_in_lost, Server_not_lost];
paulson@3500
    35
Addsimps [certificate_def];
paulson@3474
    36
paulson@3480
    37
goal thy "!!A. A ~: lost ==> A ~= Spy";
paulson@3480
    38
by (Blast_tac 1);
paulson@3480
    39
qed "not_lost_not_eq_Spy";
paulson@3480
    40
Addsimps [not_lost_not_eq_Spy];
paulson@3480
    41
paulson@3474
    42
(*Injectiveness of key-generating functions*)
paulson@3474
    43
AddIffs [inj_clientK RS inj_eq, inj_serverK RS inj_eq];
paulson@3474
    44
paulson@3474
    45
(* invKey(clientK x) = clientK x  and similarly for serverK*)
paulson@3474
    46
Addsimps [isSym_clientK, rewrite_rule [isSymKey_def] isSym_clientK,
paulson@3474
    47
	  isSym_serverK, rewrite_rule [isSymKey_def] isSym_serverK];
paulson@3480
    48
paulson@3474
    49
paulson@3474
    50
(*Replacing the variable by a constant improves search speed by 50%!*)
paulson@3474
    51
val Says_imp_sees_Spy' = 
paulson@3474
    52
    read_instantiate_sg (sign_of thy) [("lost","lost")] Says_imp_sees_Spy;
paulson@3474
    53
paulson@3474
    54
paulson@3474
    55
(*** clientK and serverK make symmetric keys; no clashes with pubK or priK ***)
paulson@3474
    56
paulson@3474
    57
goal thy "pubK A ~= clientK arg";
paulson@3474
    58
br notI 1;
paulson@3474
    59
by (dres_inst_tac [("f","isSymKey")] arg_cong 1);
paulson@3474
    60
by (Full_simp_tac 1);
paulson@3474
    61
qed "pubK_neq_clientK";
paulson@3474
    62
paulson@3474
    63
goal thy "pubK A ~= serverK arg";
paulson@3474
    64
br notI 1;
paulson@3474
    65
by (dres_inst_tac [("f","isSymKey")] arg_cong 1);
paulson@3474
    66
by (Full_simp_tac 1);
paulson@3474
    67
qed "pubK_neq_serverK";
paulson@3474
    68
paulson@3474
    69
goal thy "priK A ~= clientK arg";
paulson@3474
    70
br notI 1;
paulson@3474
    71
by (dres_inst_tac [("f","isSymKey")] arg_cong 1);
paulson@3474
    72
by (Full_simp_tac 1);
paulson@3474
    73
qed "priK_neq_clientK";
paulson@3474
    74
paulson@3474
    75
goal thy "priK A ~= serverK arg";
paulson@3474
    76
br notI 1;
paulson@3474
    77
by (dres_inst_tac [("f","isSymKey")] arg_cong 1);
paulson@3474
    78
by (Full_simp_tac 1);
paulson@3474
    79
qed "priK_neq_serverK";
paulson@3474
    80
paulson@3480
    81
(*clientK and serverK have disjoint ranges*)
paulson@3480
    82
goal thy "clientK arg ~= serverK arg'";
paulson@3480
    83
by (cut_facts_tac [rangeI RS impOfSubs clientK_range] 1);
paulson@3480
    84
by (Blast_tac 1);
paulson@3480
    85
qed "clientK_neq_serverK";
paulson@3480
    86
paulson@3474
    87
val ths = [pubK_neq_clientK, pubK_neq_serverK, 
paulson@3480
    88
	   priK_neq_clientK, priK_neq_serverK, clientK_neq_serverK];
paulson@3474
    89
AddIffs (ths @ (ths RL [not_sym]));
paulson@3474
    90
paulson@3474
    91
paulson@3474
    92
(**** Protocol Proofs ****)
paulson@3474
    93
paulson@3474
    94
(*A "possibility property": there are traces that reach the end.
paulson@3474
    95
  This protocol has three end points and six messages to consider.*)
paulson@3474
    96
paulson@3474
    97
(*Possibility property ending with ServerFinished.*)
paulson@3474
    98
goal thy 
paulson@3474
    99
 "!!A B. A ~= B ==> EX NA XA NB XB M. EX evs: tls.    \
paulson@3474
   100
\  Says B A (Crypt (serverK(NA,NB,M))                 \
paulson@3474
   101
\            (Hash{|Hash{|Nonce NA, Nonce NB, Nonce M|}, \
paulson@3474
   102
\                   Nonce NA, Agent XA, Agent A,      \
paulson@3474
   103
\                   Nonce NB, Agent XB,               \
paulson@3500
   104
\                   certificate B (pubK B)|})) \
paulson@3474
   105
\    : set evs";
paulson@3474
   106
by (REPEAT (resolve_tac [exI,bexI] 1));
paulson@3474
   107
by (rtac (tls.Nil RS tls.ClientHello RS tls.ServerHello RS tls.ClientCertKeyEx
paulson@3474
   108
	  RS tls.ServerFinished) 2);
paulson@3474
   109
by possibility_tac;
paulson@3474
   110
result();
paulson@3474
   111
paulson@3474
   112
(*And one for ClientFinished.  Either FINISHED message may come first.*)
paulson@3474
   113
goal thy 
paulson@3474
   114
 "!!A B. A ~= B ==> EX NA XA NB XB M. EX evs: tls.    \
paulson@3474
   115
\  Says A B (Crypt (clientK(NA,NB,M))                 \
paulson@3474
   116
\            (Hash{|Hash{|Nonce NA, Nonce NB, Nonce M|}, \
paulson@3474
   117
\                   Nonce NA, Agent XA,               \
paulson@3500
   118
\                   certificate A (pubK A),      \
paulson@3474
   119
\                   Nonce NB, Agent XB, Agent B|})) : set evs";
paulson@3474
   120
by (REPEAT (resolve_tac [exI,bexI] 1));
paulson@3474
   121
by (rtac (tls.Nil RS tls.ClientHello RS tls.ServerHello RS tls.ClientCertKeyEx
paulson@3474
   122
	  RS tls.ClientFinished) 2);
paulson@3474
   123
by possibility_tac;
paulson@3474
   124
result();
paulson@3474
   125
paulson@3474
   126
(*Another one, for CertVerify (which is optional)*)
paulson@3474
   127
goal thy 
paulson@3506
   128
 "!!A B. A ~= B ==> EX NB M. EX evs: tls.     \
paulson@3474
   129
\  Says A B (Crypt (priK A)                 \
paulson@3506
   130
\            (Hash{|Nonce NB, certificate B (pubK B), Nonce M|})) : set evs";
paulson@3474
   131
by (REPEAT (resolve_tac [exI,bexI] 1));
paulson@3506
   132
by (rtac (tls.Nil RS tls.ClientHello RS tls.ServerHello RS tls.ClientCertKeyEx
paulson@3506
   133
	  RS tls.CertVerify) 2);
paulson@3474
   134
by possibility_tac;
paulson@3474
   135
result();
paulson@3474
   136
paulson@3474
   137
paulson@3474
   138
(**** Inductive proofs about tls ****)
paulson@3474
   139
paulson@3474
   140
(*Nobody sends themselves messages*)
paulson@3474
   141
goal thy "!!evs. evs : tls ==> ALL A X. Says A A X ~: set evs";
paulson@3474
   142
by (etac tls.induct 1);
paulson@3474
   143
by (Auto_tac());
paulson@3474
   144
qed_spec_mp "not_Says_to_self";
paulson@3474
   145
Addsimps [not_Says_to_self];
paulson@3474
   146
AddSEs   [not_Says_to_self RSN (2, rev_notE)];
paulson@3474
   147
paulson@3474
   148
paulson@3474
   149
(** Theorems of the form X ~: parts (sees lost Spy evs) imply that NOBODY
paulson@3474
   150
    sends messages containing X! **)
paulson@3474
   151
paulson@3474
   152
(*Spy never sees another agent's private key! (unless it's lost at start)*)
paulson@3474
   153
goal thy 
paulson@3474
   154
 "!!evs. evs : tls \
paulson@3474
   155
\        ==> (Key (priK A) : parts (sees lost Spy evs)) = (A : lost)";
paulson@3474
   156
by (etac tls.induct 1);
paulson@3474
   157
by (prove_simple_subgoals_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@3474
   163
 "!!evs. evs : tls \
paulson@3474
   164
\        ==> (Key (priK A) : analz (sees lost Spy evs)) = (A : lost)";
paulson@3474
   165
by (auto_tac(!claset addDs [impOfSubs analz_subset_parts], !simpset));
paulson@3474
   166
qed "Spy_analz_priK";
paulson@3474
   167
Addsimps [Spy_analz_priK];
paulson@3474
   168
paulson@3474
   169
goal thy  "!!A. [| Key (priK A) : parts (sees lost Spy evs);       \
paulson@3474
   170
\                  evs : tls |] ==> A:lost";
paulson@3474
   171
by (blast_tac (!claset addDs [Spy_see_priK]) 1);
paulson@3474
   172
qed "Spy_see_priK_D";
paulson@3474
   173
paulson@3474
   174
bind_thm ("Spy_analz_priK_D", analz_subset_parts RS subsetD RS Spy_see_priK_D);
paulson@3474
   175
AddSDs [Spy_see_priK_D, Spy_analz_priK_D];
paulson@3474
   176
paulson@3474
   177
paulson@3474
   178
(*Every Nonce that's hashed is already in past traffic. *)
paulson@3474
   179
goal thy "!!evs. [| Hash {|Nonce N, X|} : parts (sees lost Spy evs);  \
paulson@3474
   180
\                   evs : tls |]  \
paulson@3474
   181
\                ==> Nonce N : parts (sees lost Spy evs)";
paulson@3474
   182
by (etac rev_mp 1);
paulson@3474
   183
by (etac tls.induct 1);
paulson@3474
   184
by (ALLGOALS (asm_simp_tac (!simpset addsimps [parts_insert_sees])));
paulson@3474
   185
by (step_tac (!claset addSDs [Says_imp_sees_Spy' RS parts.Inj]
paulson@3474
   186
		      addSEs partsEs) 1);
paulson@3474
   187
by (Fake_parts_insert_tac 1);
paulson@3474
   188
qed "Hash_imp_Nonce1";
paulson@3474
   189
paulson@3474
   190
(*Lemma needed to prove Hash_Hash_imp_Nonce*)
paulson@3474
   191
goal thy "!!evs. [| Hash{|Nonce NA, Nonce NB, Nonce M|}  \
paulson@3474
   192
\                       : parts (sees lost Spy evs);     \
paulson@3474
   193
\                   evs : tls |]  \
paulson@3474
   194
\                ==> Nonce M : parts (sees lost Spy evs)";
paulson@3474
   195
by (etac rev_mp 1);
paulson@3474
   196
by (etac tls.induct 1);
paulson@3474
   197
by (ALLGOALS (asm_simp_tac (!simpset addsimps [parts_insert_sees])));
paulson@3474
   198
by (step_tac (!claset addSDs [Says_imp_sees_Spy' RS parts.Inj]
paulson@3474
   199
		      addSEs partsEs) 1);
paulson@3474
   200
by (Fake_parts_insert_tac 1);
paulson@3474
   201
qed "Hash_imp_Nonce2";
paulson@3474
   202
AddSDs [Hash_imp_Nonce2];
paulson@3474
   203
paulson@3474
   204
goal thy "!!evs. [| Hash {| Hash{|Nonce NA, Nonce NB, Nonce M|}, X |}  \
paulson@3474
   205
\                      : parts (sees lost Spy evs);      \
paulson@3474
   206
\                   evs : tls |]                         \
paulson@3474
   207
\                ==> Nonce M : parts (sees lost Spy evs)";
paulson@3474
   208
by (etac rev_mp 1);
paulson@3474
   209
by (etac tls.induct 1);
paulson@3474
   210
by (ALLGOALS (asm_simp_tac (!simpset addsimps [parts_insert_sees])));
paulson@3474
   211
by (step_tac (!claset addSDs [Says_imp_sees_Spy' RS parts.Inj]
paulson@3474
   212
		      addSEs partsEs) 1);
paulson@3474
   213
by (Fake_parts_insert_tac 1);
paulson@3474
   214
qed "Hash_Hash_imp_Nonce";
paulson@3474
   215
paulson@3474
   216
paulson@3474
   217
(*NEEDED??
paulson@3474
   218
  Every Nonce that's hashed is already in past traffic. 
paulson@3474
   219
  This general formulation is tricky to prove and hard to use, since the
paulson@3474
   220
  2nd premise is typically proved by simplification.*)
paulson@3474
   221
goal thy "!!evs. [| Hash X : parts (sees lost Spy evs);  \
paulson@3474
   222
\                   Nonce N : parts {X};  evs : tls |]  \
paulson@3474
   223
\                ==> Nonce N : parts (sees lost Spy evs)";
paulson@3474
   224
by (etac rev_mp 1);
paulson@3474
   225
by (etac tls.induct 1);
paulson@3474
   226
by (ALLGOALS Asm_simp_tac);
paulson@3474
   227
by (step_tac (!claset addSDs [Says_imp_sees_Spy' RS parts.Inj]
paulson@3474
   228
		      addSEs partsEs) 1);
paulson@3474
   229
by (ALLGOALS (asm_full_simp_tac (!simpset addsimps [parts_insert_sees])));
paulson@3474
   230
by (Fake_parts_insert_tac 1);
paulson@3506
   231
(*CertVerify, ClientFinished, ServerFinished (?)*)
paulson@3506
   232
by (REPEAT (Blast_tac 1));
paulson@3474
   233
qed "Hash_imp_Nonce_seen";
paulson@3474
   234
paulson@3474
   235
paulson@3474
   236
(*** Protocol goal: if B receives CERTIFICATE VERIFY, then A sent it ***)
paulson@3474
   237
paulson@3506
   238
(*B can check A's signature if he has received A's certificate.
paulson@3506
   239
  Perhaps B~=Spy is unnecessary, but there's no obvious proof if the first
paulson@3480
   240
  message is Fake.  We don't need guarantees for the Spy anyway.  We must
paulson@3480
   241
  assume A~:lost; otherwise, the Spy can forge A's signature.*)
paulson@3500
   242
goalw thy [certificate_def]
paulson@3506
   243
 "!!evs. [| X = Crypt (priK A)                                        \
paulson@3506
   244
\                 (Hash{|Nonce NB, certificate B KB, Nonce M|});      \
paulson@3506
   245
\           evs : tls;  A ~: lost;  B ~= Spy |]                       \
paulson@3506
   246
\    ==> Says B A {|Nonce NA, Nonce NB, Agent XB, certificate B KB|}  \
paulson@3506
   247
\          : set evs --> \
paulson@3474
   248
\        X : parts (sees lost Spy evs) --> Says A B X : set evs";
paulson@3480
   249
by (hyp_subst_tac 1);
paulson@3474
   250
by (etac tls.induct 1);
paulson@3474
   251
by (ALLGOALS Asm_simp_tac);
paulson@3474
   252
by (Fake_parts_insert_tac 1);
paulson@3480
   253
(*ServerHello: nonce NB cannot be in X because it's fresh!*)
paulson@3474
   254
by (blast_tac (!claset addSDs [Hash_imp_Nonce1]
paulson@3474
   255
	               addSEs sees_Spy_partsEs) 1);
paulson@3474
   256
qed_spec_mp "TrustCertVerify";
paulson@3474
   257
paulson@3474
   258
paulson@3506
   259
goal thy
paulson@3506
   260
 "!!evs. [| evs : tls;  A ~= Spy |]                                      \
paulson@3506
   261
\ ==> Says A B (Crypt (priK A)                                           \
paulson@3506
   262
\               (Hash{|Nonce NB, certificate B KB, Nonce M|})) : set evs \
paulson@3506
   263
\     --> Says A B {|certificate A (pubK A), Crypt KB (Nonce M)|} : set evs";
paulson@3506
   264
by (etac tls.induct 1);
paulson@3506
   265
by (ALLGOALS Asm_full_simp_tac);
paulson@3506
   266
bind_thm ("UseCertVerify", result() RSN (2, rev_mp));
paulson@3506
   267
paulson@3506
   268
paulson@3474
   269
(*This lemma says that no false certificates exist.  One might extend the
paulson@3474
   270
  model to include bogus certificates for the lost agents, but there seems
paulson@3474
   271
  little point in doing so: the loss of their private keys is a worse
paulson@3474
   272
  breach of security.*)
paulson@3500
   273
goalw thy [certificate_def]
paulson@3474
   274
 "!!evs. evs : tls     \
paulson@3506
   275
\        ==> certificate B KB : parts (sees lost Spy evs) --> KB = pubK B";
paulson@3474
   276
by (etac tls.induct 1);
paulson@3474
   277
by (ALLGOALS Asm_simp_tac);
paulson@3474
   278
by (Fake_parts_insert_tac 2);
paulson@3474
   279
by (Blast_tac 1);
paulson@3474
   280
bind_thm ("Server_cert_pubB", result() RSN (2, rev_mp));
paulson@3474
   281
paulson@3474
   282
paulson@3474
   283
(*Replace key KB in ClientCertKeyEx by (pubK B) *)
paulson@3474
   284
val ClientCertKeyEx_tac = 
paulson@3474
   285
    forward_tac [Says_imp_sees_Spy' RS parts.Inj RS 
paulson@3474
   286
		 parts.Snd RS parts.Snd RS parts.Snd RS Server_cert_pubB]
paulson@3474
   287
    THEN' assume_tac
paulson@3474
   288
    THEN' hyp_subst_tac;
paulson@3474
   289
paulson@3474
   290
fun analz_induct_tac i = 
paulson@3474
   291
    etac tls.induct i   THEN
paulson@3480
   292
    ClientCertKeyEx_tac  (i+5)  THEN
paulson@3474
   293
    ALLGOALS (asm_simp_tac 
paulson@3474
   294
              (!simpset addsimps [not_parts_not_analz]
paulson@3474
   295
                        setloop split_tac [expand_if]))  THEN
paulson@3474
   296
    (*Remove instances of pubK B:  the Spy already knows all public keys.
paulson@3474
   297
      Combining the two simplifier calls makes them run extremely slowly.*)
paulson@3474
   298
    ALLGOALS (asm_simp_tac 
paulson@3474
   299
              (!simpset addsimps [insert_absorb]
paulson@3474
   300
                        setloop split_tac [expand_if]));
paulson@3474
   301
paulson@3480
   302
(*** Specialized rewriting for the analz_image_... theorems ***)
paulson@3480
   303
paulson@3480
   304
goal thy "insert (Key K) H = Key `` {K} Un H";
paulson@3480
   305
by (Blast_tac 1);
paulson@3480
   306
qed "insert_Key_singleton";
paulson@3480
   307
paulson@3480
   308
goal thy "insert (Key K) (Key``KK Un C) = Key `` (insert K KK) Un C";
paulson@3480
   309
by (Blast_tac 1);
paulson@3480
   310
qed "insert_Key_image";
paulson@3480
   311
paulson@3480
   312
(*Reverse the normal simplification of "image" to build up (not break down)
paulson@3480
   313
  the set of keys.  Based on analz_image_freshK_ss, but simpler.*)
paulson@3480
   314
val analz_image_keys_ss = 
paulson@3480
   315
     !simpset delsimps [image_insert, image_Un]
paulson@3480
   316
              addsimps [image_insert RS sym, image_Un RS sym,
paulson@3480
   317
			rangeI, 
paulson@3480
   318
			insert_Key_singleton, 
paulson@3480
   319
			insert_Key_image, Un_assoc RS sym]
paulson@3480
   320
              setloop split_tac [expand_if];
paulson@3480
   321
paulson@3480
   322
(*No collection of keys can help the spy get new private keys*)
paulson@3480
   323
goal thy  
paulson@3480
   324
 "!!evs. evs : tls ==>                                    \
paulson@3480
   325
\  ALL KK. (Key(priK B) : analz (Key``KK Un (sees lost Spy evs))) =  \
paulson@3480
   326
\            (priK B : KK | B : lost)";
paulson@3480
   327
by (etac tls.induct 1);
paulson@3480
   328
by (ALLGOALS (asm_simp_tac analz_image_keys_ss));
paulson@3480
   329
(*Fake*) 
paulson@3480
   330
by (spy_analz_tac 2);
paulson@3480
   331
(*Base*)
paulson@3480
   332
by (Blast_tac 1);
paulson@3480
   333
qed_spec_mp "analz_image_priK";
paulson@3480
   334
paulson@3480
   335
paulson@3480
   336
(*Lemma for the trivial direction of the if-and-only-if*)
paulson@3480
   337
goal thy  
paulson@3480
   338
 "!!evs. (X : analz (G Un H)) --> (X : analz H)  ==> \
paulson@3480
   339
\        (X : analz (G Un H))  =  (X : analz H)";
paulson@3480
   340
by (blast_tac (!claset addIs [impOfSubs analz_mono]) 1);
paulson@3480
   341
val lemma = result();
paulson@3480
   342
paulson@3480
   343
(*Knowing some clientKs and serverKs is no help in getting new nonces*)
paulson@3480
   344
goal thy  
paulson@3480
   345
 "!!evs. evs : tls ==>                                 \
paulson@3480
   346
\    ALL KK. KK <= (range clientK Un range serverK) -->           \
paulson@3480
   347
\            (Nonce N : analz (Key``KK Un (sees lost Spy evs))) = \
paulson@3480
   348
\            (Nonce N : analz (sees lost Spy evs))";
paulson@3480
   349
by (etac tls.induct 1);
paulson@3480
   350
by (ClientCertKeyEx_tac 6);
paulson@3480
   351
by (REPEAT_FIRST (resolve_tac [allI, impI]));
paulson@3480
   352
by (REPEAT_FIRST (rtac lemma ));
paulson@3480
   353
	(*SLOW: 30s!*)
paulson@3480
   354
by (ALLGOALS (asm_simp_tac analz_image_keys_ss));
paulson@3480
   355
by (ALLGOALS (asm_simp_tac
paulson@3480
   356
	      (!simpset addsimps [analz_image_priK, insert_absorb])));
paulson@3480
   357
(*ClientCertKeyEx: a nonce is sent, but one needs a priK to read it.*)
paulson@3480
   358
by (Blast_tac 3);
paulson@3480
   359
(*Fake*) 
paulson@3480
   360
by (spy_analz_tac 2);
paulson@3480
   361
(*Base*)
paulson@3480
   362
by (Blast_tac 1);
paulson@3480
   363
qed_spec_mp "analz_image_keys";
paulson@3480
   364
paulson@3480
   365
paulson@3480
   366
(*If A sends ClientCertKeyEx to an uncompromised B, then M will stay secret.
paulson@3480
   367
  The assumption is A~=Spy, not A~:lost, since A doesn't use her private key
paulson@3480
   368
  here.*)
paulson@3500
   369
goalw thy [certificate_def]
paulson@3506
   370
 "!!evs. [| evs : tls;  A~=Spy;  B ~: lost |]                        \
paulson@3506
   371
\        ==> Says A B {|certificate A (pubK A), Crypt KB (Nonce M)|} \
paulson@3506
   372
\              : set evs  -->  Nonce M ~: analz (sees lost Spy evs)";
paulson@3474
   373
by (analz_induct_tac 1);
paulson@3474
   374
(*ClientHello*)
paulson@3480
   375
by (blast_tac (!claset addSEs sees_Spy_partsEs) 3);
paulson@3480
   376
(*SpyKeys*)
paulson@3480
   377
by (asm_simp_tac (analz_image_keys_ss addsimps [analz_image_keys]) 2);
paulson@3474
   378
(*Fake*)
paulson@3474
   379
by (spy_analz_tac 1);
paulson@3474
   380
(*ServerHello and ClientCertKeyEx: mostly freshness reasoning*)
paulson@3474
   381
by (REPEAT (blast_tac (!claset addSEs partsEs
paulson@3474
   382
			       addDs  [impOfSubs analz_subset_parts,
paulson@3474
   383
				       Says_imp_sees_Spy' RS analz.Inj]) 1));
paulson@3474
   384
bind_thm ("Spy_not_see_premaster_secret", result() RSN (2, rev_mp));
paulson@3474
   385
paulson@3474
   386
paulson@3474
   387
(*** Protocol goal: serverK(NA,NB,M) and clientK(NA,NB,M) remain secure ***)
paulson@3474
   388
paulson@3480
   389
(*The two proofs are identical*)
paulson@3474
   390
goal thy 
paulson@3480
   391
 "!!evs. [| Nonce M ~: analz (sees lost Spy evs);  \
paulson@3480
   392
\           evs : tls |]                           \
paulson@3480
   393
\        ==> Key (clientK(NA,NB,M)) ~: parts (sees lost Spy evs)";
paulson@3480
   394
by (etac rev_mp 1);
paulson@3480
   395
by (analz_induct_tac 1);
paulson@3480
   396
(*SpyKeys*)
paulson@3480
   397
by (asm_simp_tac (analz_image_keys_ss addsimps [analz_image_keys]) 3);
paulson@3480
   398
by (blast_tac (!claset addDs [Says_imp_sees_Spy' RS analz.Inj]) 3);
paulson@3480
   399
(*Fake*) 
paulson@3480
   400
by (spy_analz_tac 2);
paulson@3480
   401
(*Base*)
paulson@3480
   402
by (Blast_tac 1);
paulson@3474
   403
qed "clientK_notin_parts";
paulson@3474
   404
paulson@3474
   405
goal thy 
paulson@3480
   406
 "!!evs. [| Nonce M ~: analz (sees lost Spy evs);  \
paulson@3480
   407
\           evs : tls |]                           \
paulson@3480
   408
\        ==> Key (serverK(NA,NB,M)) ~: parts (sees lost Spy evs)";
paulson@3480
   409
by (etac rev_mp 1);
paulson@3480
   410
by (analz_induct_tac 1);
paulson@3480
   411
(*SpyKeys*)
paulson@3480
   412
by (asm_simp_tac (analz_image_keys_ss addsimps [analz_image_keys]) 3);
paulson@3480
   413
by (blast_tac (!claset addDs [Says_imp_sees_Spy' RS analz.Inj]) 3);
paulson@3480
   414
(*Fake*) 
paulson@3480
   415
by (spy_analz_tac 2);
paulson@3480
   416
(*Base*)
paulson@3480
   417
by (Blast_tac 1);
paulson@3474
   418
qed "serverK_notin_parts";
paulson@3474
   419
paulson@3474
   420
paulson@3474
   421
(*** Protocol goals: if A receives SERVER FINISHED, then B is present 
paulson@3474
   422
     and has used the quoted values XA, XB, etc.  Note that it is up to A
paulson@3474
   423
     to compare XA with what she originally sent.
paulson@3474
   424
***)
paulson@3474
   425
paulson@3500
   426
goalw thy [certificate_def]
paulson@3480
   427
 "!!evs. [| X = Crypt (serverK(NA,NB,M))                            \
paulson@3480
   428
\                 (Hash{|Hash{|Nonce NA, Nonce NB, Nonce M|},       \
paulson@3480
   429
\                        Nonce NA, Agent XA, Agent A,               \
paulson@3506
   430
\                        Nonce NB, Agent XB, certificate B (pubK B)|}); \
paulson@3480
   431
\           evs : tls;  A~=Spy;  B ~: lost |]                       \
paulson@3506
   432
\    ==> Says A B {|certificate A (pubK A), Crypt KB (Nonce M)|} \
paulson@3506
   433
\          : set evs -->              \
paulson@3480
   434
\        X : parts (sees lost Spy evs) --> Says B A X : set evs";
paulson@3480
   435
by (hyp_subst_tac 1);
paulson@3474
   436
by (etac tls.induct 1);
paulson@3474
   437
by (ALLGOALS Asm_simp_tac);
paulson@3480
   438
(*ClientCertKeyEx: M isn't in the Hash because it's fresh!*)
paulson@3480
   439
by (blast_tac (!claset addSDs [Hash_Hash_imp_Nonce]
paulson@3480
   440
                       addSEs sees_Spy_partsEs) 2);
paulson@3480
   441
(*Fake: the Spy doesn't have the critical session key!*)
paulson@3480
   442
by (REPEAT (rtac impI 1));
paulson@3480
   443
by (subgoal_tac "Key (serverK(NA,NB,M)) ~: analz (sees lost Spy evsa)" 1);
paulson@3480
   444
by (asm_simp_tac (!simpset addsimps [Spy_not_see_premaster_secret, 
paulson@3480
   445
				     serverK_notin_parts, 
paulson@3480
   446
				     not_parts_not_analz]) 2);
paulson@3474
   447
by (Fake_parts_insert_tac 1);
paulson@3474
   448
qed_spec_mp "TrustServerFinished";
paulson@3474
   449
paulson@3474
   450
paulson@3500
   451
(*** Protocol goal: if B receives CLIENT FINISHED, then A has used the
paulson@3500
   452
     quoted values XA, XB, etc., which B can then check.  BUT NOTE:
paulson@3506
   453
     B has no way of knowing that A is the sender of CLIENT CERTIFICATE!
paulson@3506
   454
***)
paulson@3500
   455
goalw thy [certificate_def]
paulson@3474
   456
 "!!evs. [| X = Crypt (clientK(NA,NB,M))                        \
paulson@3474
   457
\                 (Hash{|Hash{|Nonce NA, Nonce NB, Nonce M|},   \
paulson@3474
   458
\                        Nonce NA, Agent XA,                    \
paulson@3500
   459
\                        certificate A (pubK A),                \
paulson@3474
   460
\                        Nonce NB, Agent XB, Agent B|});        \
paulson@3480
   461
\           evs : tls;  A~=Spy;  B ~: lost |]                   \
paulson@3500
   462
\     ==> Says A B {|certificate A (pubK A),                    \
paulson@3506
   463
\                    Crypt KB (Nonce M)|} : set evs -->         \
paulson@3480
   464
\         X : parts (sees lost Spy evs) --> Says A B X : set evs";
paulson@3480
   465
by (hyp_subst_tac 1);
paulson@3474
   466
by (etac tls.induct 1);
paulson@3474
   467
by (ALLGOALS Asm_simp_tac);
paulson@3480
   468
(*ClientCertKeyEx: M isn't in the Hash because it's fresh!*)
paulson@3480
   469
by (blast_tac (!claset addSDs [Hash_Hash_imp_Nonce]
paulson@3480
   470
                       addSEs sees_Spy_partsEs) 2);
paulson@3480
   471
(*Fake: the Spy doesn't have the critical session key!*)
paulson@3480
   472
by (REPEAT (rtac impI 1));
paulson@3480
   473
by (subgoal_tac "Key (clientK(NA,NB,M)) ~: analz (sees lost Spy evsa)" 1);
paulson@3480
   474
by (asm_simp_tac (!simpset addsimps [Spy_not_see_premaster_secret, 
paulson@3480
   475
				     clientK_notin_parts, 
paulson@3480
   476
				     not_parts_not_analz]) 2);
paulson@3474
   477
by (Fake_parts_insert_tac 1);
paulson@3474
   478
qed_spec_mp "TrustClientFinished";
paulson@3506
   479
paulson@3506
   480
paulson@3506
   481
(*** Protocol goal: if B receives CLIENT FINISHED, and if B is able to
paulson@3506
   482
     check a CERTIFICATE VERIFY from A, then A has used the quoted
paulson@3506
   483
     values XA, XB, etc.  Even this one requires A to be uncompromised.
paulson@3506
   484
 ***)
paulson@3506
   485
goal thy
paulson@3506
   486
 "!!evs. [| X = Crypt (clientK(NA,NB,M))                        \
paulson@3506
   487
\                 (Hash{|Hash{|Nonce NA, Nonce NB, Nonce M|},   \
paulson@3506
   488
\                        Nonce NA, Agent XA,                    \
paulson@3506
   489
\                        certificate A (pubK A),                \
paulson@3506
   490
\                        Nonce NB, Agent XB, Agent B|});        \
paulson@3506
   491
\           Says A' B X : set evs;                              \
paulson@3506
   492
\           Says B A {|Nonce NA, Nonce NB, Agent XB, certificate B KB|}  \
paulson@3506
   493
\             : set evs;                                        \
paulson@3506
   494
\           Says A'' B (Crypt (priK A)                                   \
paulson@3506
   495
\                       (Hash{|Nonce NB, certificate B KB, Nonce M|}))   \
paulson@3506
   496
\             : set evs;                                        \
paulson@3506
   497
\        evs : tls;  A ~: lost;  B ~: lost |]                   \
paulson@3506
   498
\     ==> Says A B X : set evs";
paulson@3506
   499
br TrustClientFinished 1;
paulson@3506
   500
br (TrustCertVerify RS UseCertVerify) 5;
paulson@3506
   501
by (REPEAT_FIRST (ares_tac [refl]));
paulson@3506
   502
by (ALLGOALS 
paulson@3506
   503
    (asm_full_simp_tac (!simpset addsimps [Says_imp_sees_Spy RS parts.Inj])));
paulson@3506
   504
qed_spec_mp "AuthClientFinished";