src/HOL/UNITY/NSP_Bad.ML
author paulson
Mon, 07 Sep 1998 10:43:31 +0200
changeset 5430 4a179dba527a
child 5460 0c4e3d024ec9
permissions -rw-r--r--
New UNITY theory, the N-S protocol
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5430
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
     1
(*  Title:      HOL/Auth/NSP_Bad
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
     2
    ID:         $Id$
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
     4
    Copyright   1996  University of Cambridge
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
     5
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
     6
Inductive relation "ns_public" for the Needham-Schroeder Public-Key protocol.
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
     7
Flawed version, vulnerable to Lowe's attack.
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
     8
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
     9
From page 260 of
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    10
  Burrows, Abadi and Needham.  A Logic of Authentication.
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    11
  Proc. Royal Soc. 426 (1989)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    12
*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    13
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    14
AddEs spies_partsEs;
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    15
AddDs [impOfSubs analz_subset_parts];
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    16
AddDs [impOfSubs Fake_parts_insert];
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    17
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    18
AddIffs [Spy_in_bad];
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    19
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    20
(*For other theories, e.g. Mutex and Lift, using AddIffs slows proofs down.
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    21
  Here, it facilitates re-use of the Auth proofs.*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    22
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    23
AddIffs (map simp_of_act [Fake_def, NS1_def, NS2_def, NS3_def]);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    24
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    25
Addsimps [Nprg_def RS def_prg_simps];
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    26
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    27
(*A "possibility property": there are traces that reach the end*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    28
Goal "A ~= B ==> EX NB. EX s: reachable Nprg.                \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    29
\                  Says A B (Crypt (pubK B) (Nonce NB)) : set s";
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    30
by (REPEAT (resolve_tac [exI,bexI] 1));
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    31
by (res_inst_tac [("act", "NS3")] reachable.Acts 2);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    32
by (res_inst_tac [("act", "NS2")] reachable.Acts 3);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    33
by (res_inst_tac [("act", "NS1")] reachable.Acts 4);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    34
br reachable.Init 5;
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    35
by (ALLGOALS Asm_simp_tac);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    36
by (REPEAT_FIRST (resolve_tac [exI]));
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    37
by possibility_tac;
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    38
result();
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    39
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    40
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    41
(**** Inductive proofs about ns_public ****)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    42
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    43
(*Nobody sends themselves messages*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    44
Goal "Invariant Nprg {s. ALL X. Says A A X ~: set s}";
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    45
by (rtac InvariantI 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    46
by (Force_tac 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    47
by (constrains_tac 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    48
by Auto_tac;
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    49
qed "not_Says_to_self";
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    50
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    51
(** HOW TO USE??  They don't seem to be needed!
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    52
Addsimps [not_Says_to_self];
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    53
AddSEs   [not_Says_to_self RSN (2, rev_notE)];
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    54
**)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    55
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    56
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    57
(*can be used to simulate analz_mono_contra_tac
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    58
val analz_impI = read_instantiate_sg (sign_of thy)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    59
                [("P", "?Y ~: analz (spies ?evs)")] impI;
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    60
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    61
val spies_Says_analz_contraD = 
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    62
    spies_subset_spies_Says RS analz_mono RS contra_subsetD;
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    63
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    64
by (rtac analz_impI 2);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    65
by (auto_tac (claset() addSDs [spies_Says_analz_contraD], simpset()));
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    66
*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    67
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    68
val parts_induct_tac = 
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    69
  (SELECT_GOAL o EVERY)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    70
     [etac reachable.induct 1,
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    71
      Force_tac 1,
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    72
      Full_simp_tac 1,
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    73
      safe_tac (claset() delrules [impI,impCE]),
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    74
      REPEAT (FIRSTGOAL analz_mono_contra_tac),
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    75
      ALLGOALS Asm_simp_tac];
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    76
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    77
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    78
(** Theorems of the form X ~: parts (spies evs) imply that NOBODY
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    79
    sends messages containing X! **)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    80
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    81
(*Spy never sees another agent's private key! (unless it's bad at start)*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    82
Goal "Invariant Nprg {s. (Key (priK A) : parts (spies s)) = (A : bad)}";
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    83
by (rtac InvariantI 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    84
by (Force_tac 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    85
by (constrains_tac 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    86
by Auto_tac;
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    87
qed "Spy_see_priK";
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    88
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    89
(** HOW TO USE??
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    90
Addsimps [Spy_see_priK];
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    91
*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    92
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    93
Goal "s : reachable Nprg ==> (Key (priK A) : parts (spies s)) = (A : bad)";
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    94
be reachable.induct 1;
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    95
by Auto_tac;
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    96
qed "Spy_see_priK";
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    97
Addsimps [Spy_see_priK];
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    98
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
    99
Goal "s : reachable Nprg ==> (Key (priK A) : analz (spies s)) = (A : bad)";
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   100
by Auto_tac;
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   101
qed "Spy_analz_priK";
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   102
Addsimps [Spy_analz_priK];
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   103
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   104
AddSDs [Spy_see_priK RSN (2, rev_iffD1), 
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   105
	Spy_analz_priK RSN (2, rev_iffD1)];
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   106
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   107
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   108
(**** Authenticity properties obtained from NS2 ****)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   109
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   110
(*It is impossible to re-use a nonce in both NS1 and NS2, provided the nonce
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   111
  is secret.  (Honest users generate fresh nonces.)*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   112
Goal "[| Crypt (pubK B) {|Nonce NA, Agent A|} : parts (spies s); \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   113
\        Nonce NA ~: analz (spies s);   s : reachable Nprg |]       \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   114
\     ==> Crypt (pubK C) {|NA', Nonce NA|} ~: parts (spies s)";
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   115
by (etac rev_mp 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   116
by (etac rev_mp 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   117
by (parts_induct_tac 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   118
by (ALLGOALS Blast_tac);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   119
qed "no_nonce_NS1_NS2";
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   120
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   121
(*Adding it to the claset slows down proofs...*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   122
val nonce_NS1_NS2_E = no_nonce_NS1_NS2 RSN (2, rev_notE);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   123
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   124
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   125
(*Unicity for NS1: nonce NA identifies agents A and B*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   126
Goal "[| Nonce NA ~: analz (spies s);  s : reachable Nprg |]      \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   127
\     ==> EX A' B'. ALL A B.                                            \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   128
\            Crypt (pubK B) {|Nonce NA, Agent A|} : parts (spies s) --> \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   129
\               A=A' & B=B'";
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   130
by (etac rev_mp 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   131
by (parts_induct_tac 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   132
by (ALLGOALS (simp_tac (simpset() addsimps [all_conj_distrib])));
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   133
(*NS1*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   134
by (expand_case_tac "NA = ?y" 2 THEN Blast_tac 2);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   135
(*Fake*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   136
by (Blast_tac 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   137
val lemma = result();
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   138
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   139
Goal "[| Crypt(pubK B)  {|Nonce NA, Agent A|}  : parts(spies s); \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   140
\        Crypt(pubK B') {|Nonce NA, Agent A'|} : parts(spies s); \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   141
\        Nonce NA ~: analz (spies s);                            \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   142
\        s : reachable Nprg |]                                   \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   143
\     ==> A=A' & B=B'";
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   144
by (prove_unique_tac lemma 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   145
qed "unique_NA";
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   146
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   147
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   148
(*Tactic for proving secrecy theorems*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   149
val analz_induct_tac = 
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   150
  (SELECT_GOAL o EVERY)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   151
     [etac reachable.induct 1,
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   152
      Force_tac 1,
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   153
      Full_simp_tac 1,
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   154
      safe_tac (claset() delrules [impI,impCE]),
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   155
      ALLGOALS Asm_simp_tac];
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   156
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   157
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   158
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   159
(*Secrecy: Spy does not see the nonce sent in msg NS1 if A and B are secure*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   160
Goal "[| Says A B (Crypt(pubK B) {|Nonce NA, Agent A|}) : set s;   \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   161
\        A ~: bad;  B ~: bad;  s : reachable Nprg |]                    \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   162
\     ==>  Nonce NA ~: analz (spies s)";
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   163
by (etac rev_mp 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   164
by (analz_induct_tac 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   165
(*NS3*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   166
by (blast_tac (claset() addEs [nonce_NS1_NS2_E]) 4);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   167
(*NS2*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   168
by (blast_tac (claset() addDs [unique_NA]) 3);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   169
(*NS1*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   170
by (Blast_tac 2);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   171
(*Fake*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   172
by (spy_analz_tac 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   173
qed "Spy_not_see_NA";
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   174
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   175
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   176
(*Authentication for A: if she receives message 2 and has used NA
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   177
  to start a run, then B has sent message 2.*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   178
Goal "[| Says A  B (Crypt(pubK B) {|Nonce NA, Agent A|}) : set s;  \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   179
\        Says B' A (Crypt(pubK A) {|Nonce NA, Nonce NB|}): set s;  \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   180
\        A ~: bad;  B ~: bad;  s : reachable Nprg |]                    \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   181
\     ==> Says B A (Crypt(pubK A) {|Nonce NA, Nonce NB|}): set s";
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   182
by (etac rev_mp 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   183
(*prepare induction over Crypt (pubK A) {|NA,NB|} : parts H*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   184
by (etac (Says_imp_spies RS parts.Inj RS rev_mp) 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   185
by (parts_induct_tac 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   186
by (ALLGOALS Clarify_tac);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   187
(*NS2*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   188
by (blast_tac (claset() addDs [Spy_not_see_NA, unique_NA]) 3);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   189
(*NS1*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   190
by (Blast_tac 2);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   191
(*Fake*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   192
by (blast_tac (claset() addDs [Spy_not_see_NA]) 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   193
qed "A_trusts_NS2";
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   194
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   195
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   196
(*If the encrypted message appears then it originated with Alice in NS1*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   197
Goal "[| Crypt (pubK B) {|Nonce NA, Agent A|} : parts (spies s); \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   198
\        Nonce NA ~: analz (spies s);                            \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   199
\        s : reachable Nprg |]                                        \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   200
\     ==> Says A B (Crypt (pubK B) {|Nonce NA, Agent A|}) : set s";
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   201
by (etac rev_mp 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   202
by (etac rev_mp 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   203
by (parts_induct_tac 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   204
by (Blast_tac 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   205
qed "B_trusts_NS1";
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   206
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   207
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   208
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   209
(**** Authenticity properties obtained from NS2 ****)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   210
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   211
(*Unicity for NS2: nonce NB identifies nonce NA and agent A
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   212
  [proof closely follows that for unique_NA] *)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   213
Goal "[| Nonce NB ~: analz (spies s);  s : reachable Nprg |]         \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   214
\     ==> EX A' NA'. ALL A NA.                                       \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   215
\           Crypt (pubK A) {|Nonce NA, Nonce NB|} : parts (spies s)  \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   216
\                -->  A=A' & NA=NA'";
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   217
by (etac rev_mp 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   218
by (parts_induct_tac 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   219
by (ALLGOALS (asm_simp_tac (simpset() addsimps [all_conj_distrib])));
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   220
(*NS2*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   221
by (expand_case_tac "NB = ?y" 2 THEN Blast_tac 2);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   222
(*Fake*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   223
by (Blast_tac 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   224
val lemma = result();
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   225
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   226
Goal "[| Crypt(pubK A) {|Nonce NA, Nonce NB|}  : parts(spies s); \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   227
\        Crypt(pubK A'){|Nonce NA', Nonce NB|} : parts(spies s); \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   228
\        Nonce NB ~: analz (spies s);                            \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   229
\        s : reachable Nprg |]                                        \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   230
\     ==> A=A' & NA=NA'";
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   231
by (prove_unique_tac lemma 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   232
qed "unique_NB";
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   233
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   234
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   235
(*NB remains secret PROVIDED Alice never responds with round 3*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   236
Goal "[| Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set s;  \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   237
\       ALL C. Says A C (Crypt (pubK C) (Nonce NB)) ~: set s;      \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   238
\       A ~: bad;  B ~: bad;  s : reachable Nprg |]                     \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   239
\    ==> Nonce NB ~: analz (spies s)";
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   240
by (etac rev_mp 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   241
by (etac rev_mp 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   242
by (analz_induct_tac 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   243
by (ALLGOALS (asm_simp_tac (simpset() addsimps [all_conj_distrib])));
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   244
by (ALLGOALS Clarify_tac);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   245
(*NS3: because NB determines A*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   246
by (blast_tac (claset() addDs [unique_NB]) 4);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   247
(*NS2: by freshness and unicity of NB*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   248
by (blast_tac (claset() addEs [nonce_NS1_NS2_E]) 3);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   249
(*NS1: by freshness*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   250
by (Blast_tac 2);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   251
(*Fake*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   252
by (spy_analz_tac 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   253
qed "Spy_not_see_NB";
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   254
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   255
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   256
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   257
(*Authentication for B: if he receives message 3 and has used NB
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   258
  in message 2, then A has sent message 3--to somebody....*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   259
Goal "[| Says B A  (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set s; \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   260
\        Says A' B (Crypt (pubK B) (Nonce NB)): set s;              \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   261
\        A ~: bad;  B ~: bad;  s : reachable Nprg |]                \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   262
\     ==> EX C. Says A C (Crypt (pubK C) (Nonce NB)) : set s";
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   263
by (etac rev_mp 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   264
(*prepare induction over Crypt (pubK B) NB : parts H*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   265
by (etac (Says_imp_spies RS parts.Inj RS rev_mp) 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   266
by (parts_induct_tac 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   267
by (ALLGOALS (asm_simp_tac (simpset() addsimps [ex_disj_distrib])));
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   268
by (ALLGOALS Clarify_tac);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   269
(*NS3: because NB determines A (this use of unique_NB is more robust) *)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   270
by (blast_tac (claset() addDs [Spy_not_see_NB]
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   271
			addIs [unique_NB RS conjunct1]) 3);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   272
(*NS1: by freshness*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   273
by (Blast_tac 2);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   274
(*Fake*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   275
by (blast_tac (claset() addDs [Spy_not_see_NB]) 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   276
qed "B_trusts_NS3";
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   277
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   278
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   279
(*Can we strengthen the secrecy theorem?  NO*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   280
Goal "[| A ~: bad;  B ~: bad;  s : reachable Nprg |]           \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   281
\     ==> Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set s \
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   282
\           --> Nonce NB ~: analz (spies s)";
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   283
by (analz_induct_tac 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   284
by (ALLGOALS Clarify_tac);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   285
(*NS2: by freshness and unicity of NB*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   286
by (blast_tac (claset() addEs [nonce_NS1_NS2_E]) 3);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   287
(*NS1: by freshness*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   288
by (Blast_tac 2);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   289
(*Fake*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   290
by (spy_analz_tac 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   291
(*NS3: unicity of NB identifies A and NA, but not B*)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   292
by (forw_inst_tac [("A'","A")] (Says_imp_spies RS parts.Inj RS unique_NB) 1
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   293
    THEN REPEAT (eresolve_tac [asm_rl, Says_imp_spies RS parts.Inj] 1));
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   294
by Auto_tac;
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   295
by (rename_tac "s B' C" 1);
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   296
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   297
(*
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   298
THIS IS THE ATTACK!
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   299
Level 8
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   300
!!s. [| A ~: bad; B ~: bad; s : reachable Nprg |]
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   301
       ==> Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set s -->
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   302
           Nonce NB ~: analz (spies s)
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   303
 1. !!s B' C.
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   304
       [| A ~: bad; B ~: bad; s : reachable Nprg;
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   305
          Says A C (Crypt (pubK C) {|Nonce NA, Agent A|}) : set s;
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   306
          Says B' A (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set s; C : bad;
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   307
          Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set s;
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   308
          Nonce NB ~: analz (spies s) |]
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   309
       ==> False
4a179dba527a New UNITY theory, the N-S protocol
paulson
parents:
diff changeset
   310
*)