src/HOL/Auth/NS_Shared.ML
author paulson
Mon, 23 Sep 1996 17:41:57 +0200
changeset 2002 ed423882c6a9
parent 1999 b5efc4108d04
child 2015 d4a8fd8a8065
permissions -rw-r--r--
Bad version of Otway-Rees and the new attack on it
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
     1
(*  Title:      HOL/Auth/NS_Shared
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
     2
    ID:         $Id$
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
     4
    Copyright   1996  University of Cambridge
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
     5
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
     6
Inductive relation "ns_shared" for Needham-Schroeder Shared-Key protocol.
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
     7
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
     8
From page 247 of
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
     9
  Burrows, Abadi and Needham.  A Logic of Authentication.
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    10
  Proc. Royal Soc. 426 (1989)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    11
*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    12
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    13
open NS_Shared;
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    14
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
    15
proof_timing:=true;
1997
6efba890341e No longer assumes Alice is not the Enemy in NS3.
paulson
parents: 1967
diff changeset
    16
HOL_quantifiers := false;
6efba890341e No longer assumes Alice is not the Enemy in NS3.
paulson
parents: 1967
diff changeset
    17
6efba890341e No longer assumes Alice is not the Enemy in NS3.
paulson
parents: 1967
diff changeset
    18
(** Weak liveness: there are traces that reach the end **)
6efba890341e No longer assumes Alice is not the Enemy in NS3.
paulson
parents: 1967
diff changeset
    19
6efba890341e No longer assumes Alice is not the Enemy in NS3.
paulson
parents: 1967
diff changeset
    20
goal thy 
6efba890341e No longer assumes Alice is not the Enemy in NS3.
paulson
parents: 1967
diff changeset
    21
 "!!A B. [| A ~= B; A ~= Server; B ~= Server |]   \
6efba890341e No longer assumes Alice is not the Enemy in NS3.
paulson
parents: 1967
diff changeset
    22
\        ==> EX N K. EX evs: ns_shared.          \
6efba890341e No longer assumes Alice is not the Enemy in NS3.
paulson
parents: 1967
diff changeset
    23
\               Says A B (Crypt {|Nonce N, Nonce N|} K) : set_of_list evs";
6efba890341e No longer assumes Alice is not the Enemy in NS3.
paulson
parents: 1967
diff changeset
    24
by (REPEAT (resolve_tac [exI,bexI] 1));
6efba890341e No longer assumes Alice is not the Enemy in NS3.
paulson
parents: 1967
diff changeset
    25
br (ns_shared.Nil RS ns_shared.NS1 RS ns_shared.NS2 RS ns_shared.NS3 RS ns_shared.NS4 RS ns_shared.NS5) 2;
6efba890341e No longer assumes Alice is not the Enemy in NS3.
paulson
parents: 1967
diff changeset
    26
by (ALLGOALS (simp_tac (!simpset setsolver safe_solver)));
6efba890341e No longer assumes Alice is not the Enemy in NS3.
paulson
parents: 1967
diff changeset
    27
by (REPEAT_FIRST (resolve_tac [refl, conjI]));
6efba890341e No longer assumes Alice is not the Enemy in NS3.
paulson
parents: 1967
diff changeset
    28
by (ALLGOALS (fast_tac (!claset addss (!simpset setsolver safe_solver))));
6efba890341e No longer assumes Alice is not the Enemy in NS3.
paulson
parents: 1967
diff changeset
    29
qed "weak_liveness";
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
    30
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    31
(**** Inductive proofs about ns_shared ****)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    32
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    33
(*The Enemy can see more than anybody else, except for their initial state*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    34
goal thy 
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    35
 "!!evs. evs : ns_shared ==> \
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    36
\     sees A evs <= initState A Un sees Enemy evs";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    37
be ns_shared.induct 1;
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    38
by (ALLGOALS (fast_tac (!claset addDs [sees_Says_subset_insert RS subsetD] 
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    39
			        addss (!simpset))));
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    40
qed "sees_agent_subset_sees_Enemy";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    41
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    42
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    43
(*Nobody sends themselves messages*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    44
goal thy "!!evs. evs : ns_shared ==> ALL A X. Says A A X ~: set_of_list evs";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    45
be ns_shared.induct 1;
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    46
by (Auto_tac());
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    47
qed_spec_mp "not_Says_to_self";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    48
Addsimps [not_Says_to_self];
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    49
AddSEs   [not_Says_to_self RSN (2, rev_notE)];
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    50
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    51
goal thy "!!evs. evs : ns_shared ==> Notes A X ~: set_of_list evs";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    52
be ns_shared.induct 1;
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    53
by (Auto_tac());
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    54
qed "not_Notes";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    55
Addsimps [not_Notes];
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    56
AddSEs   [not_Notes RSN (2, rev_notE)];
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    57
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    58
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
    59
(*For reasoning about the encrypted portion of message NS3*)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    60
goal thy "!!evs. (Says S A (Crypt {|N, B, K, X|} KA)) : set_of_list evs ==> \
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    61
\                X : parts (sees Enemy evs)";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    62
by (fast_tac (!claset addSEs partsEs
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    63
	              addSDs [Says_imp_sees_Enemy RS parts.Inj]) 1);
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    64
qed "NS3_msg_in_parts_sees_Enemy";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    65
			      
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    66
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
    67
(*** Shared keys are not betrayed ***)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    68
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
    69
(*Enemy never sees another agent's shared key!*)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    70
goal thy 
1999
b5efc4108d04 Reformatting
paulson
parents: 1997
diff changeset
    71
 "!!evs. [| evs : ns_shared; A ~: bad |]    \
b5efc4108d04 Reformatting
paulson
parents: 1997
diff changeset
    72
\        ==> Key (shrK A) ~: parts (sees Enemy evs)";
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    73
be ns_shared.induct 1;
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    74
bd NS3_msg_in_parts_sees_Enemy 5;
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    75
by (Auto_tac());
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    76
(*Deals with Fake message*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    77
by (best_tac (!claset addDs [impOfSubs analz_subset_parts,
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
    78
			     impOfSubs Fake_parts_insert]) 1);
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
    79
qed "Enemy_not_see_shrK";
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    80
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
    81
bind_thm ("Enemy_not_analz_shrK",
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
    82
	  [analz_subset_parts, Enemy_not_see_shrK] MRS contra_subsetD);
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    83
1967
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
    84
Addsimps [Enemy_not_see_shrK, Enemy_not_analz_shrK];
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    85
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
    86
(*We go to some trouble to preserve R in the 3rd and 4th subgoals
1967
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
    87
  As usual fast_tac cannot be used because it uses the equalities too soon*)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    88
val major::prems = 
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
    89
goal thy  "[| Key (shrK A) : parts (sees Enemy evs);       \
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
    90
\             evs : ns_shared;                             \
1967
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
    91
\             A:bad ==> R                                  \
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    92
\           |] ==> R";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    93
br ccontr 1;
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
    94
br ([major, Enemy_not_see_shrK] MRS rev_notE) 1;
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    95
by (swap_res_tac prems 2);
1967
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
    96
by (ALLGOALS (fast_tac (!claset addIs prems)));
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
    97
qed "Enemy_see_shrK_E";
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
    98
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
    99
bind_thm ("Enemy_analz_shrK_E", 
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   100
	  analz_subset_parts RS subsetD RS Enemy_see_shrK_E);
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   101
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   102
AddSEs [Enemy_see_shrK_E, Enemy_analz_shrK_E];
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   103
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   104
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   105
goal thy  
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   106
 "!!evs. evs : ns_shared ==>                              \
1967
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   107
\        (Key (shrK A) : analz (sees Enemy evs)) = (A : bad)";
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   108
by (best_tac (!claset addDs [impOfSubs analz_subset_parts]
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   109
		      addIs [impOfSubs (subset_insertI RS analz_mono)]
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   110
	              addss (!simpset)) 1);
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   111
qed "shrK_mem_analz";
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   112
1967
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   113
Addsimps [shrK_mem_analz];
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   114
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   115
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   116
(*** Future keys can't be seen or used! ***)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   117
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   118
(*Nobody can have SEEN keys that will be generated in the future.
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   119
  This has to be proved anew for each protocol description,
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   120
  but should go by similar reasoning every time.  Hardest case is the
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   121
  standard Fake rule.  
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   122
      The length comparison, and Union over C, are essential for the 
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   123
  induction! *)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   124
goal thy "!!evs. evs : ns_shared ==> \
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   125
\                length evs <= length evs' --> \
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   126
\                          Key (newK evs') ~: (UN C. parts (sees C evs))";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   127
be ns_shared.induct 1;
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   128
bd NS3_msg_in_parts_sees_Enemy 5;
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   129
(*auto_tac does not work here, as it performs safe_tac first*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   130
by (ALLGOALS Asm_simp_tac);
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   131
by (ALLGOALS (best_tac (!claset addDs [impOfSubs analz_subset_parts,
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   132
				       impOfSubs parts_insert_subset_Un,
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   133
				       Suc_leD]
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   134
			        addss (!simpset))));
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   135
val lemma = result();
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   136
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   137
(*Variant needed for the main theorem below*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   138
goal thy 
1999
b5efc4108d04 Reformatting
paulson
parents: 1997
diff changeset
   139
 "!!evs. [| evs : ns_shared;  length evs <= length evs' |]    \
b5efc4108d04 Reformatting
paulson
parents: 1997
diff changeset
   140
\        ==> Key (newK evs') ~: parts (sees C evs)";
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   141
by (fast_tac (!claset addDs [lemma]) 1);
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   142
qed "new_keys_not_seen";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   143
Addsimps [new_keys_not_seen];
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   144
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   145
(*Another variant: old messages must contain old keys!*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   146
goal thy 
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   147
 "!!evs. [| Says A B X : set_of_list evs;  \
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   148
\           Key (newK evt) : parts {X};    \
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   149
\           evs : ns_shared                 \
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   150
\        |] ==> length evt < length evs";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   151
br ccontr 1;
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   152
by (fast_tac (!claset addSDs [new_keys_not_seen, Says_imp_sees_Enemy]
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   153
	              addIs [impOfSubs parts_mono, leI]) 1);
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   154
qed "Says_imp_old_keys";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   155
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   156
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   157
(*Nobody can have USED keys that will be generated in the future.
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   158
  ...very like new_keys_not_seen*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   159
goal thy "!!evs. evs : ns_shared ==> \
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   160
\                length evs <= length evs' --> \
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   161
\                newK evs' ~: keysFor (UN C. parts (sees C evs))";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   162
be ns_shared.induct 1;
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   163
bd NS3_msg_in_parts_sees_Enemy 5;
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   164
by (ALLGOALS Asm_simp_tac);
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   165
(*NS1 and NS2*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   166
map (by o fast_tac (!claset addDs [Suc_leD] addss (!simpset))) [3,2];
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   167
(*Fake and NS3*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   168
map (by o best_tac
1997
6efba890341e No longer assumes Alice is not the Enemy in NS3.
paulson
parents: 1967
diff changeset
   169
     (!claset addDs [impOfSubs (analz_subset_parts RS keysFor_mono),
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   170
		     impOfSubs (parts_insert_subset_Un RS keysFor_mono),
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   171
		     Suc_leD]
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   172
	      addEs [new_keys_not_seen RS not_parts_not_analz RSN (2,rev_notE)]
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   173
	      addss (!simpset)))
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   174
    [2,1];
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   175
(*NS4 and NS5: nonce exchange*)
1997
6efba890341e No longer assumes Alice is not the Enemy in NS3.
paulson
parents: 1967
diff changeset
   176
by (ALLGOALS (deepen_tac (!claset addSDs [Says_imp_old_keys]
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   177
	                          addIs  [less_SucI, impOfSubs keysFor_mono]
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   178
		                  addss (!simpset addsimps [le_def])) 0));
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   179
val lemma = result();
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   180
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   181
goal thy 
1999
b5efc4108d04 Reformatting
paulson
parents: 1997
diff changeset
   182
 "!!evs. [| evs : ns_shared;  length evs <= length evs' |]    \
b5efc4108d04 Reformatting
paulson
parents: 1997
diff changeset
   183
\        ==> newK evs' ~: keysFor (parts (sees C evs))";
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   184
by (fast_tac (!claset addSDs [lemma] addss (!simpset)) 1);
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   185
qed "new_keys_not_used";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   186
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   187
bind_thm ("new_keys_not_analzd",
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   188
	  [analz_subset_parts RS keysFor_mono,
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   189
	   new_keys_not_used] MRS contra_subsetD);
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   190
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   191
Addsimps [new_keys_not_used, new_keys_not_analzd];
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   192
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   193
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   194
(** Lemmas concerning the form of items passed in messages **)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   195
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   196
(*Describes the form *and age* of K, and the form of X,
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   197
  when the following message is sent*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   198
goal thy 
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   199
 "!!evs. [| Says Server A (Crypt {|N, Agent B, K, X|} K') : set_of_list evs; \
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   200
\           evs : ns_shared    \
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   201
\        |] ==> (EX evt:ns_shared. \
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   202
\                         K = Key(newK evt) & \
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   203
\                         X = (Crypt {|K, Agent A|} (shrK B)) & \
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   204
\                         K' = shrK A & \
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   205
\                         length evt < length evs)";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   206
be rev_mp 1;
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   207
be ns_shared.induct 1;
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   208
by (ALLGOALS (fast_tac (!claset addIs [less_SucI] addss (!simpset))));
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   209
qed "Says_Server_message_form";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   210
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   211
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   212
(*Describes the form of X when the following message is sent.  The use of
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   213
  "parts" strengthens the induction hyp for proving the Fake case.  The
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   214
  assumptions on A are needed to prevent its being a Faked message.*)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   215
goal thy
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   216
 "!!evs. evs : ns_shared ==>                                              \
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   217
\        ALL A NA B K X.                                                  \
1967
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   218
\            Crypt {|Nonce NA, Agent B, Key K, X|} (shrK A)               \
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   219
\               : parts (sees Enemy evs) &                                \
1967
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   220
\            A ~: bad --> \
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   221
\          (EX evt:ns_shared. K = newK evt & \
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   222
\                             X = (Crypt {|Key K, Agent A|} (shrK B)))";
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   223
be ns_shared.induct 1;
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   224
bd NS3_msg_in_parts_sees_Enemy 5;
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   225
by (Step_tac 1);
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   226
by (ALLGOALS Asm_full_simp_tac);
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   227
by (fast_tac (!claset addss (!simpset)) 1);
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   228
(*Remaining cases are Fake and NS2*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   229
by (fast_tac (!claset addSDs [spec]) 2);
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   230
(*Now for the Fake case*)
1967
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   231
by (best_tac (!claset addSDs [impOfSubs Fake_parts_insert]
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   232
	              addDs  [impOfSubs analz_subset_parts]
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   233
	              addss  (!simpset)) 1);
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   234
qed_spec_mp "encrypted_form";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   235
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   236
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   237
(*If such a message is sent with a bad key then the Enemy sees it (even if
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   238
  he didn't send it in the first place).*)
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   239
goal thy
1967
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   240
 "!!evs. [| Says S A (Crypt {|N, B, K, X|} (shrK A)) : set_of_list evs;   \
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   241
\           A : bad |]                                                    \
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   242
\        ==> X : analz (sees Enemy evs)";
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   243
by (fast_tac (!claset addSDs [Says_imp_sees_Enemy RS analz.Inj]
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   244
	              addss (!simpset)) 1);
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   245
qed_spec_mp "bad_encrypted_form";
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   246
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   247
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   248
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   249
(*EITHER describes the form of X when the following message is sent, 
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   250
  OR     reduces it to the Fake case.
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   251
  Use Says_Server_message_form if applicable.*)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   252
goal thy 
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   253
 "!!evs. [| Says S A (Crypt {|Nonce NA, Agent B, Key K, X|} (shrK A))    \
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   254
\            : set_of_list evs;  evs : ns_shared |]                      \
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   255
\        ==> (EX evt:ns_shared. K = newK evt & length evt < length evs & \
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   256
\                               X = (Crypt {|Key K, Agent A|} (shrK B))) | \
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   257
\            X : analz (sees Enemy evs)";
1967
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   258
by (excluded_middle_tac "A : bad" 1);
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   259
by (fast_tac (!claset addIs [bad_encrypted_form]) 2);
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   260
by (forward_tac [encrypted_form] 1);
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   261
br (parts.Inj RS conjI) 1;
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   262
by (auto_tac (!claset addIs [Says_imp_old_keys], !simpset));
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   263
qed "Says_S_message_form";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   264
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   265
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   266
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   267
(****
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   268
 The following is to prove theorems of the form
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   269
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   270
          Key K : analz (insert (Key (newK evt)) (sees Enemy evs)) ==>
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   271
          Key K : analz (sees Enemy evs)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   272
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   273
 A more general formula must be proved inductively.
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   274
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   275
****)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   276
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   277
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   278
(*NOT useful in this form, but it says that session keys are not used
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   279
  to encrypt messages containing other keys, in the actual protocol.
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   280
  We require that agents should behave like this subsequently also.*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   281
goal thy 
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   282
 "!!evs. evs : ns_shared ==> \
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   283
\        (Crypt X (newK evt)) : parts (sees Enemy evs) & \
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   284
\        Key K : parts {X} --> Key K : parts (sees Enemy evs)";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   285
be ns_shared.induct 1;
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   286
bd NS3_msg_in_parts_sees_Enemy 5;
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   287
by (ALLGOALS (asm_simp_tac (!simpset addsimps pushes)));
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   288
(*Deals with Faked messages*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   289
by (best_tac (!claset addSEs partsEs
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   290
		      addDs [impOfSubs analz_subset_parts,
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   291
                             impOfSubs parts_insert_subset_Un]
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   292
                      addss (!simpset)) 2);
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   293
(*Base, NS4 and NS5*)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   294
by (ALLGOALS (fast_tac (!claset addss (!simpset))));
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   295
result();
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   296
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   297
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   298
(** Specialized rewriting for this proof **)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   299
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   300
Delsimps [image_insert];
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   301
Addsimps [image_insert RS sym];
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   302
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   303
Delsimps [image_Un];
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   304
Addsimps [image_Un RS sym];
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   305
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   306
goal thy "insert (Key (newK x)) (sees A evs) = \
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   307
\         Key `` (newK``{x}) Un (sees A evs)";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   308
by (Fast_tac 1);
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   309
val insert_Key_singleton = result();
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   310
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   311
goal thy "insert (Key (f x)) (Key``(f``E) Un C) = \
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   312
\         Key `` (f `` (insert x E)) Un C";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   313
by (Fast_tac 1);
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   314
val insert_Key_image = result();
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   315
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   316
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   317
(** Session keys are not used to encrypt other session keys **)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   318
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   319
(*Lemma for the trivial direction of the if-and-only-if*)
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   320
goal thy  
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   321
 "!!evs. (Key K : analz (Key``nE Un sEe)) --> \
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   322
\         (K : nE | Key K : analz sEe)  ==>     \
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   323
\        (Key K : analz (Key``nE Un sEe)) = (K : nE | Key K : analz sEe)";
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   324
by (fast_tac (!claset addSEs [impOfSubs analz_mono]) 1);
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   325
val lemma = result();
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   326
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   327
goal thy  
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   328
 "!!evs. evs : ns_shared ==> \
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   329
\  ALL K E. (Key K : analz (Key``(newK``E) Un (sees Enemy evs))) = \
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   330
\           (K : newK``E | Key K : analz (sees Enemy evs))";
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   331
be ns_shared.induct 1;
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   332
by (forward_tac [Says_S_message_form] 5 THEN assume_tac 5);	
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   333
by (REPEAT ((eresolve_tac [bexE, conjE, disjE] ORELSE' hyp_subst_tac) 5));
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   334
by (REPEAT_FIRST (resolve_tac [allI, lemma]));
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   335
by (ALLGOALS 
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   336
    (asm_simp_tac 
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   337
     (!simpset addsimps ([insert_Key_singleton, insert_Key_image, pushKey_newK]
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   338
			 @ pushes)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   339
               setloop split_tac [expand_if])));
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   340
(** LEVEL 5 **)
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   341
(*NS3, Fake subcase*)
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   342
by (enemy_analz_tac 5);
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   343
(*Cases NS2 and NS3!!  Simple, thanks to auto case splits*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   344
by (REPEAT (Fast_tac 3));
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   345
(*Fake case*) (** LEVEL 7 **)
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   346
by (enemy_analz_tac 2);
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   347
(*Base case*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   348
by (fast_tac (!claset addIs [image_eqI] addss (!simpset)) 1);
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   349
qed_spec_mp "analz_image_newK";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   350
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   351
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   352
goal thy
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   353
 "!!evs. evs : ns_shared ==>                               \
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   354
\        Key K : analz (insert (Key (newK evt)) (sees Enemy evs)) = \
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   355
\        (K = newK evt | Key K : analz (sees Enemy evs))";
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   356
by (asm_simp_tac (HOL_ss addsimps [pushKey_newK, analz_image_newK, 
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   357
				   insert_Key_singleton]) 1);
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   358
by (Fast_tac 1);
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   359
qed "analz_insert_Key_newK";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   360
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   361
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   362
(** First, two lemmas for the Fake and NS3 cases **)
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   363
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   364
goal thy 
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   365
 "!!evs. [| X : synth (analz (sees Enemy evs));                \
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   366
\           Crypt X' (shrK C) : parts{X};                      \
1967
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   367
\           C ~: bad;  evs : ns_shared |]  \
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   368
\        ==> Crypt X' (shrK C) : parts (sees Enemy evs)";
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   369
by (best_tac (!claset addSEs [impOfSubs analz_subset_parts]
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   370
	              addDs [impOfSubs parts_insert_subset_Un]
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   371
                      addss (!simpset)) 1);
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   372
qed "Crypt_Fake_parts";
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   373
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   374
goal thy 
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   375
 "!!evs. [| Crypt X' K : parts (sees A evs);  evs : ns_shared |]  \
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   376
\        ==> EX S S' Y. Says S S' Y : set_of_list evs &       \
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   377
\            Crypt X' K : parts {Y}";
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   378
bd parts_singleton 1;
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   379
by (fast_tac (!claset addSDs [seesD] addss (!simpset)) 1);
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   380
qed "Crypt_parts_singleton";
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   381
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   382
fun ex_strip_tac i = REPEAT (ares_tac [exI, conjI] i) THEN assume_tac (i+1);
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   383
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   384
(*This says that the Key, K, uniquely identifies the message.
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   385
    But if Enemy knows C's key then he could send all sorts of nonsense.*)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   386
goal thy 
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   387
 "!!evs. evs : ns_shared ==>                      \
1967
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   388
\      EX X'. ALL C.                              \
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   389
\       C ~: bad -->                              \
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   390
\        (ALL S A Y. Says S A Y : set_of_list evs -->     \
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   391
\         (ALL N B X. Crypt {|N, Agent B, Key K, X|} (shrK C) : parts{Y} --> \
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   392
\          X=X'))";
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   393
be ns_shared.induct 1;
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   394
by (forward_tac [Says_S_message_form] 5 THEN assume_tac 5);	
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   395
by (ALLGOALS 
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   396
    (asm_simp_tac (!simpset addsimps [all_conj_distrib, imp_conj_distrib])));
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   397
by (REPEAT_FIRST (eresolve_tac [exE,disjE]));
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   398
(*NS3: Fake (compromised) case*)
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   399
by (ex_strip_tac 4);
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   400
by (fast_tac (!claset addSDs [synth.Inj RS Crypt_Fake_parts, 
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   401
			      Crypt_parts_singleton]) 4);
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   402
(*NS3: Good case, no relevant messages*)
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   403
by (fast_tac (!claset addSEs [exI] addss (!simpset)) 3);
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   404
(*NS2: Case split propagates some context to other subgoal...*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   405
by (excluded_middle_tac "K = newK evsa" 2);
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   406
by (Asm_simp_tac 2);
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   407
be exI 2;
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   408
(*...we assume X is a very new message, and handle this case by contradiction*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   409
by (fast_tac (!claset addIs [impOfSubs (subset_insertI RS parts_mono)]
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   410
		      addSEs partsEs
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   411
		      addEs [Says_imp_old_keys RS less_irrefl]
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   412
	              addss (!simpset)) 2);
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   413
(*Fake*) (** LEVEL 11 **)
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   414
by (ex_strip_tac 1);
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   415
by (fast_tac (!claset addSDs [Crypt_Fake_parts, Crypt_parts_singleton]) 1);
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   416
val lemma = result();
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   417
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   418
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   419
(*In messages of this form, the session key uniquely identifies the rest*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   420
goal thy 
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   421
 "!!evs. [| Says S A          \
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   422
\             (Crypt {|N, Agent B, Key K, X|} (shrK C))     \
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   423
\                  : set_of_list evs; \ 
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   424
\           Says S' A'                                         \
1943
20574dca5a3e Renaming and simplification
paulson
parents: 1934
diff changeset
   425
\             (Crypt {|N', Agent B', Key K, X'|} (shrK C')) \
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   426
\                  : set_of_list evs;                         \
1967
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   427
\           evs : ns_shared;  C ~= Enemy;  C ~: bad;  C' ~: bad |] ==> X = X'";
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   428
bd lemma 1;
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   429
be exE 1;
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   430
(*Duplicate the assumption*)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   431
by (forw_inst_tac [("psi", "ALL C.?P(C)")] asm_rl 1);
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   432
(*Are these instantiations essential?*)
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   433
by (dres_inst_tac [("x","C")] spec 1);
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   434
by (dres_inst_tac [("x","C'")] spec 1);
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   435
by (fast_tac (!claset addSDs [spec]) 1);
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   436
qed "unique_session_keys";
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   437
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   438
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   439
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   440
(*Crucial secrecy property: Enemy does not see the keys sent in msg NS2*)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   441
goal thy 
1967
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   442
 "!!evs. [| Says Server A                                       \
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   443
\            (Crypt {|N, Agent B, K, X|} K') : set_of_list evs;  \
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   444
\           A ~: bad;  B ~: bad;  evs : ns_shared                  \
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   445
\        |] ==>                                                          \
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   446
\     K ~: analz (sees Enemy evs)";
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   447
be rev_mp 1;
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   448
be ns_shared.induct 1;
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   449
by (ALLGOALS Asm_simp_tac);
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   450
(*Next 3 steps infer that K has the form "Key (newK evs'" ... *)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   451
by (REPEAT_FIRST (resolve_tac [conjI, impI]));
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   452
by (TRYALL (forward_tac [Says_Server_message_form] THEN' assume_tac));
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   453
by (REPEAT_FIRST (eresolve_tac [bexE, conjE] ORELSE' hyp_subst_tac));
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   454
by (ALLGOALS 
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   455
    (asm_full_simp_tac 
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   456
     (!simpset addsimps ([analz_subset_parts RS contra_subsetD,
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   457
			  analz_insert_Key_newK] @ pushes)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   458
               setloop split_tac [expand_if])));
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   459
(*NS2*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   460
by (fast_tac (!claset addSEs [less_irrefl]) 2);
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   461
(*Fake case*) (** LEVEL 8 **)
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   462
by (enemy_analz_tac 1);
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   463
(*NS3: that message from the Server was sent earlier*)
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   464
by (mp_tac 1);
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   465
by (forward_tac [Says_S_message_form] 1 THEN assume_tac 1);
1967
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   466
by (Step_tac 1);
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   467
by (enemy_analz_tac 2);		(*Prove the Fake subcase*)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   468
by (asm_full_simp_tac
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   469
    (!simpset addsimps (mem_if::analz_insert_Key_newK::pushes)) 1);
1967
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   470
by (Step_tac 1);
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   471
(**LEVEL 15 **)
1997
6efba890341e No longer assumes Alice is not the Enemy in NS3.
paulson
parents: 1967
diff changeset
   472
by (excluded_middle_tac "Aa : bad" 1);
1967
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   473
(*But this contradicts Key (newK evta) ~: analz (sees Enemy evsa) *)
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   474
bd (Says_imp_sees_Enemy RS analz.Inj) 2;
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   475
bd analz.Decrypt 2;
1967
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   476
by (Asm_full_simp_tac 2);
1965
789c12ea0b30 Stronger proofs; work for Otway-Rees
paulson
parents: 1943
diff changeset
   477
by (Fast_tac 2);
1967
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   478
(*So now we know that (Friend i) is a good agent*)
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   479
bd unique_session_keys 1;
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   480
by (REPEAT_FIRST assume_tac);
1967
0ff58b41c037 "bad" set simplifies statements of many theorems
paulson
parents: 1965
diff changeset
   481
by (Auto_tac ());
1934
58573e7041b4 Separation of theory Event into two parts:
paulson
parents:
diff changeset
   482
qed "Enemy_not_see_encrypted_key";