src/HOL/Auth/Public.ML
author paulson
Fri Sep 19 18:27:31 1997 +0200 (1997-09-19)
changeset 3686 4b484805b4c4
parent 3683 aafe719dff14
child 3730 6933d20f335f
permissions -rw-r--r--
First working version with Oops event for session keys
paulson@2318
     1
(*  Title:      HOL/Auth/Public
paulson@2318
     2
    ID:         $Id$
paulson@2318
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
paulson@2318
     4
    Copyright   1996  University of Cambridge
paulson@2318
     5
paulson@2318
     6
Theory of Public Keys (common to all symmetric-key protocols)
paulson@2318
     7
paulson@2318
     8
Server keys; initial states of agents; new nonces and keys; function "sees" 
paulson@2318
     9
*)
paulson@2318
    10
paulson@2318
    11
paulson@2318
    12
open Public;
paulson@2318
    13
paulson@2497
    14
(*** Basic properties of pubK & priK ***)
paulson@2497
    15
paulson@2497
    16
AddIffs [inj_pubK RS inj_eq];
paulson@3477
    17
paulson@3477
    18
goal thy "!!A B. (priK A = priK B) = (A=B)";
paulson@3477
    19
by (Step_tac 1);
paulson@3477
    20
by (dres_inst_tac [("f","invKey")] arg_cong 1);
paulson@3477
    21
by (Full_simp_tac 1);
paulson@3477
    22
qed "priK_inj_eq";
paulson@3477
    23
paulson@3477
    24
AddIffs [priK_inj_eq];
paulson@3473
    25
AddIffs [priK_neq_pubK, priK_neq_pubK RS not_sym];
paulson@3473
    26
paulson@3473
    27
goalw thy [isSymKey_def] "~ isSymKey (pubK A)";
paulson@3473
    28
by (Simp_tac 1);
paulson@3473
    29
qed "not_isSymKey_pubK";
paulson@3473
    30
paulson@3473
    31
goalw thy [isSymKey_def] "~ isSymKey (priK A)";
paulson@3473
    32
by (Simp_tac 1);
paulson@3473
    33
qed "not_isSymKey_priK";
paulson@3473
    34
paulson@3473
    35
AddIffs [not_isSymKey_pubK, not_isSymKey_priK];
paulson@3473
    36
paulson@3512
    37
(** Rewrites should not refer to  initState(Friend i) 
paulson@3512
    38
    -- not in normal form! **)
paulson@3512
    39
paulson@3519
    40
goalw thy [keysFor_def] "keysFor (parts (initState C)) = {}";
paulson@3667
    41
by (induct_tac "C" 1);
paulson@3512
    42
by (auto_tac (!claset addIs [range_eqI], !simpset));
paulson@3512
    43
qed "keysFor_parts_initState";
paulson@3512
    44
Addsimps [keysFor_parts_initState];
paulson@3512
    45
paulson@3512
    46
paulson@3683
    47
(*** Function "spies" ***)
paulson@2497
    48
paulson@2318
    49
(*Agents see their own private keys!*)
paulson@3683
    50
goal thy "Key (priK A) : initState A";
paulson@3667
    51
by (induct_tac "A" 1);
paulson@3683
    52
by (Auto_tac());
paulson@3683
    53
qed "priK_in_initState";
paulson@3683
    54
AddIffs [priK_in_initState];
paulson@2318
    55
paulson@3683
    56
(*All public keys are visible*)
paulson@3683
    57
goal thy "Key (pubK A) : spies evs";
paulson@3667
    58
by (induct_tac "evs" 1);
paulson@3683
    59
by (ALLGOALS (asm_simp_tac
paulson@3683
    60
	      (!simpset addsimps [imageI, spies_Cons]
paulson@3683
    61
	                setloop split_tac [expand_event_case, expand_if])));
paulson@3683
    62
qed_spec_mp "spies_pubK";
paulson@2318
    63
paulson@3683
    64
(*Spy sees private keys of bad agents!*)
paulson@3683
    65
goal thy "!!A. A: bad ==> Key (priK A) : spies evs";
paulson@3667
    66
by (induct_tac "evs" 1);
paulson@3683
    67
by (ALLGOALS (asm_simp_tac
paulson@3683
    68
	      (!simpset addsimps [imageI, spies_Cons]
paulson@3683
    69
	                setloop split_tac [expand_event_case, expand_if])));
paulson@3683
    70
qed "Spy_spies_bad";
paulson@2318
    71
paulson@3683
    72
AddIffs [spies_pubK, spies_pubK RS analz.Inj];
paulson@3683
    73
AddSIs  [Spy_spies_bad];
paulson@2318
    74
paulson@2318
    75
paulson@3683
    76
(*For not_bad_tac*)
paulson@3683
    77
goal thy "!!A. [| Crypt (pubK A) X : analz (spies evs);  A: bad |] \
paulson@3683
    78
\              ==> X : analz (spies evs)";
paulson@3442
    79
by (blast_tac (!claset addSDs [analz.Decrypt]) 1);
paulson@3683
    80
qed "Crypt_Spy_analz_bad";
paulson@2318
    81
paulson@3442
    82
(*Prove that the agent is uncompromised by the confidentiality of 
paulson@3442
    83
  a component of a message she's said.*)
paulson@3683
    84
fun not_bad_tac s =
paulson@3683
    85
    case_tac ("(" ^ s ^ ") : bad") THEN'
paulson@3442
    86
    SELECT_GOAL 
paulson@3683
    87
      (REPEAT_DETERM (dtac (Says_imp_spies RS analz.Inj) 1) THEN
paulson@3442
    88
       REPEAT_DETERM (etac MPair_analz 1) THEN
paulson@3442
    89
       THEN_BEST_FIRST 
paulson@3683
    90
         (dres_inst_tac [("A", s)] Crypt_Spy_analz_bad 1 THEN assume_tac 1)
paulson@3442
    91
         (has_fewer_prems 1, size_of_thm)
paulson@3442
    92
         (Step_tac 1));
paulson@2318
    93
paulson@2318
    94
paulson@2497
    95
(*** Fresh nonces ***)
paulson@2497
    96
paulson@3519
    97
goal thy "Nonce N ~: parts (initState B)";
paulson@3667
    98
by (induct_tac "B" 1);
paulson@2497
    99
by (Auto_tac ());
paulson@2497
   100
qed "Nonce_notin_initState";
paulson@2497
   101
AddIffs [Nonce_notin_initState];
paulson@2497
   102
paulson@3512
   103
goal thy "Nonce N ~: used []";
paulson@3683
   104
by (simp_tac (!simpset addsimps [used_Nil]) 1);
paulson@3512
   105
qed "Nonce_notin_used_empty";
paulson@3512
   106
Addsimps [Nonce_notin_used_empty];
paulson@2497
   107
paulson@2497
   108
paulson@3512
   109
(*** Supply fresh nonces for possibility theorems. ***)
paulson@2516
   110
paulson@3683
   111
(*In any trace, there is an upper bound N on the greatest nonce in use.*)
paulson@3683
   112
goal thy "EX N. ALL n. N<=n --> Nonce n ~: used evs";
paulson@3667
   113
by (induct_tac "evs" 1);
paulson@2497
   114
by (res_inst_tac [("x","0")] exI 1);
paulson@3683
   115
by (ALLGOALS (asm_simp_tac
paulson@3683
   116
	      (!simpset addsimps [used_Cons]
paulson@3683
   117
			setloop split_tac [expand_event_case, expand_if])));
paulson@2497
   118
by (Step_tac 1);
paulson@3512
   119
by (ALLGOALS (rtac (msg_Nonce_supply RS exE)));
paulson@3512
   120
by (ALLGOALS (blast_tac (!claset addSEs [add_leE])));
paulson@2497
   121
val lemma = result();
paulson@2497
   122
paulson@3683
   123
goal thy "EX N. Nonce N ~: used evs";
paulson@3683
   124
by (rtac (lemma RS exE) 1);
paulson@3683
   125
by (Blast_tac 1);
paulson@3683
   126
qed "Nonce_supply1";
paulson@3683
   127
paulson@2497
   128
goal thy "Nonce (@ N. Nonce N ~: used evs) ~: used evs";
paulson@2516
   129
by (rtac (lemma RS exE) 1);
paulson@2516
   130
by (rtac selectI 1);
paulson@2497
   131
by (Fast_tac 1);
paulson@2497
   132
qed "Nonce_supply";
paulson@2497
   133
paulson@2516
   134
(*Tactic for possibility theorems*)
paulson@3544
   135
fun possibility_tac st = st |>
paulson@3673
   136
    REPEAT (*omit used_Says so that Nonces start from different traces!*)
paulson@3512
   137
    (ALLGOALS (simp_tac (!simpset delsimps [used_Says] setSolver safe_solver))
paulson@2516
   138
     THEN
paulson@2516
   139
     REPEAT_FIRST (eq_assume_tac ORELSE' 
paulson@2516
   140
                   resolve_tac [refl, conjI, Nonce_supply]));
paulson@2497
   141
paulson@3512
   142
paulson@3512
   143
(*** Specialized rewriting for the analz_image_... theorems ***)
paulson@2318
   144
paulson@3512
   145
goal thy "insert (Key K) H = Key `` {K} Un H";
paulson@3512
   146
by (Blast_tac 1);
paulson@3512
   147
qed "insert_Key_singleton";
paulson@3512
   148
paulson@3512
   149
goal thy "insert (Key K) (Key``KK Un C) = Key `` (insert K KK) Un C";
paulson@3512
   150
by (Blast_tac 1);
paulson@3512
   151
qed "insert_Key_image";
paulson@2318
   152
paulson@3512
   153
(*Reverse the normal simplification of "image" to build up (not break down)
paulson@3512
   154
  the set of keys.  Based on analz_image_freshK_ss, but simpler.*)
paulson@3512
   155
val analz_image_keys_ss = 
paulson@3673
   156
     !simpset addcongs [if_weak_cong]
paulson@3673
   157
	      delsimps [image_insert, image_Un]
paulson@3680
   158
              delsimps [imp_disjL]    (*reduces blow-up*)
paulson@3512
   159
              addsimps [image_insert RS sym, image_Un RS sym,
paulson@3512
   160
			rangeI, 
paulson@3512
   161
			insert_Key_singleton, 
paulson@3512
   162
			insert_Key_image, Un_assoc RS sym]
paulson@3512
   163
              setloop split_tac [expand_if];
paulson@2318
   164