src/HOL/Auth/NS_Public_Bad.ML
author wenzelm
Mon, 03 Nov 1997 12:24:13 +0100
changeset 4091 771b1f6422a8
parent 3919 c036caebfc75
child 4197 1547bc6daa5a
permissions -rw-r--r--
isatool fixclasimp;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
     1
(*  Title:      HOL/Auth/NS_Public_Bad
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
     2
    ID:         $Id$
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
     4
    Copyright   1996  University of Cambridge
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
     5
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
     6
Inductive relation "ns_public" for the Needham-Schroeder Public-Key protocol.
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
     7
Flawed version, vulnerable to Lowe's attack.
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
     8
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
     9
From page 260 of
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    10
  Burrows, Abadi and Needham.  A Logic of Authentication.
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    11
  Proc. Royal Soc. 426 (1989)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    12
*)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    13
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    14
open NS_Public_Bad;
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    15
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    16
proof_timing:=true;
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    17
HOL_quantifiers := false;
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    18
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
    19
AddIffs [Spy_in_bad];
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    20
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    21
(*A "possibility property": there are traces that reach the end*)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    22
goal thy 
2480
f9be937df511 Tidied up the unicity proofs
paulson
parents: 2451
diff changeset
    23
 "!!A B. A ~= B ==> EX NB. EX evs: ns_public.               \
3465
e85c24717cad set_of_list -> set
nipkow
parents: 3440
diff changeset
    24
\                     Says A B (Crypt (pubK B) (Nonce NB)) : set evs";
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    25
by (REPEAT (resolve_tac [exI,bexI] 1));
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    26
by (rtac (ns_public.Nil RS ns_public.NS1 RS ns_public.NS2 RS ns_public.NS3) 2);
2516
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2497
diff changeset
    27
by possibility_tac;
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    28
result();
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    29
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    30
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    31
(**** Inductive proofs about ns_public ****)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    32
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    33
(*Nobody sends themselves messages*)
3465
e85c24717cad set_of_list -> set
nipkow
parents: 3440
diff changeset
    34
goal thy "!!evs. evs : ns_public ==> ALL A X. Says A A X ~: set evs";
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    35
by (etac ns_public.induct 1);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    36
by (Auto_tac());
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    37
qed_spec_mp "not_Says_to_self";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    38
Addsimps [not_Says_to_self];
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    39
AddSEs   [not_Says_to_self RSN (2, rev_notE)];
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    40
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    41
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
    42
(*Induction for regularity theorems.  If induction formula has the form
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
    43
   X ~: analz (spies evs) --> ... then it shortens the proof by discarding
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
    44
   needless information about analz (insert X (spies evs))  *)
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
    45
fun parts_induct_tac i = 
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
    46
    etac ns_public.induct i
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
    47
    THEN 
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
    48
    REPEAT (FIRSTGOAL analz_mono_contra_tac)
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
    49
    THEN 
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
    50
    prove_simple_subgoals_tac i;
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
    51
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
    52
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
    53
(** Theorems of the form X ~: parts (spies evs) imply that NOBODY
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    54
    sends messages containing X! **)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    55
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
    56
(*Spy never sees another agent's private key! (unless it's bad at start)*)
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    57
goal thy 
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
    58
 "!!A. evs: ns_public ==> (Key (priK A) : parts (spies evs)) = (A : bad)";
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
    59
by (parts_induct_tac 1);
3121
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 2637
diff changeset
    60
by (Fake_parts_insert_tac 1);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    61
qed "Spy_see_priK";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    62
Addsimps [Spy_see_priK];
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    63
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    64
goal thy 
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
    65
 "!!A. evs: ns_public ==> (Key (priK A) : analz (spies evs)) = (A : bad)";
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
    66
by (auto_tac(claset() addDs [impOfSubs analz_subset_parts], simpset()));
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    67
qed "Spy_analz_priK";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    68
Addsimps [Spy_analz_priK];
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    69
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
    70
goal thy  "!!A. [| Key (priK A) : parts (spies evs);       \
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
    71
\                  evs : ns_public |] ==> A:bad";
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
    72
by (blast_tac (claset() addDs [Spy_see_priK]) 1);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    73
qed "Spy_see_priK_D";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    74
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    75
bind_thm ("Spy_analz_priK_D", analz_subset_parts RS subsetD RS Spy_see_priK_D);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    76
AddSDs [Spy_see_priK_D, Spy_analz_priK_D];
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    77
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    78
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
    79
(**** Authenticity properties obtained from NS2 ****)
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
    80
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
    81
(*It is impossible to re-use a nonce in both NS1 and NS2, provided the nonce
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
    82
  is secret.  (Honest users generate fresh nonces.)*)
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
    83
goal thy 
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
    84
 "!!evs. [| Crypt (pubK B) {|Nonce NA, Agent A|} : parts (spies evs); \
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
    85
\           Nonce NA ~: analz (spies evs);   evs : ns_public |]       \
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
    86
\ ==> Crypt (pubK C) {|NA', Nonce NA|} ~: parts (spies evs)";
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
    87
by (etac rev_mp 1);
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
    88
by (etac rev_mp 1);
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
    89
by (parts_induct_tac 1);
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
    90
(*NS3*)
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
    91
by (blast_tac (claset() addSEs partsEs) 3);
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
    92
(*NS2*)
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
    93
by (blast_tac (claset() addSEs partsEs) 2);
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
    94
by (Fake_parts_insert_tac 1);
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
    95
qed "no_nonce_NS1_NS2";
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
    96
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
    97
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
    98
(*Unicity for NS1: nonce NA identifies agents A and B*)
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
    99
goal thy 
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   100
 "!!evs. [| Nonce NA ~: analz (spies evs);  evs : ns_public |]      \
3709
c13c2137e9ee Tidied proofs, using Clarify_tac
paulson
parents: 3703
diff changeset
   101
\ ==> EX A' B'. ALL A B.                                            \
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   102
\      Crypt (pubK B) {|Nonce NA, Agent A|} : parts (spies evs) --> \
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
   103
\      A=A' & B=B'";
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
   104
by (etac rev_mp 1);
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
   105
by (parts_induct_tac 1);
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
   106
by (ALLGOALS
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
   107
    (asm_simp_tac (simpset() addsimps [all_conj_distrib, parts_insert_spies])));
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
   108
(*NS1*)
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
   109
by (expand_case_tac "NA = ?y" 2 THEN blast_tac (claset() addSEs partsEs) 2);
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
   110
(*Fake*)
3709
c13c2137e9ee Tidied proofs, using Clarify_tac
paulson
parents: 3703
diff changeset
   111
by (Clarify_tac 1);
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
   112
by (ex_strip_tac 1);
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
   113
by (Fake_parts_insert_tac 1);
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
   114
val lemma = result();
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
   115
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
   116
goal thy 
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   117
 "!!evs. [| Crypt(pubK B)  {|Nonce NA, Agent A|}  : parts(spies evs); \
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   118
\           Crypt(pubK B') {|Nonce NA, Agent A'|} : parts(spies evs); \
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   119
\           Nonce NA ~: analz (spies evs);                            \
3709
c13c2137e9ee Tidied proofs, using Clarify_tac
paulson
parents: 3703
diff changeset
   120
\           evs : ns_public |]                                        \
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
   121
\        ==> A=A' & B=B'";
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
   122
by (prove_unique_tac lemma 1);
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
   123
qed "unique_NA";
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
   124
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
   125
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
   126
(*Tactic for proving secrecy theorems*)
2418
6b6a92d05fb2 New tactics: prove_unique_tac and analz_induct_tac
paulson
parents: 2374
diff changeset
   127
fun analz_induct_tac i = 
3121
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 2637
diff changeset
   128
    etac ns_public.induct i   THEN
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
   129
    ALLGOALS (asm_simp_tac (simpset() addsplits [expand_if]));
2418
6b6a92d05fb2 New tactics: prove_unique_tac and analz_induct_tac
paulson
parents: 2374
diff changeset
   130
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   131
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   132
(*Secrecy: Spy does not see the nonce sent in msg NS1 if A and B are secure*)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   133
goal thy 
3709
c13c2137e9ee Tidied proofs, using Clarify_tac
paulson
parents: 3703
diff changeset
   134
 "!!evs. [| Says A B (Crypt(pubK B) {|Nonce NA, Agent A|}) : set evs;   \
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   135
\           A ~: bad;  B ~: bad;  evs : ns_public |]                    \
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   136
\        ==>  Nonce NA ~: analz (spies evs)";
2536
1e04eb7f7eb1 Tidied proofs by using "etac rev_mp" instead of applying rev_mp to result()
paulson
parents: 2516
diff changeset
   137
by (etac rev_mp 1);
2418
6b6a92d05fb2 New tactics: prove_unique_tac and analz_induct_tac
paulson
parents: 2374
diff changeset
   138
by (analz_induct_tac 1);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   139
(*NS3*)
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
   140
by (blast_tac (claset() addDs  [Says_imp_spies RS parts.Inj]
3121
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 2637
diff changeset
   141
                       addEs  [no_nonce_NS1_NS2 RSN (2, rev_notE)]) 4);
2536
1e04eb7f7eb1 Tidied proofs by using "etac rev_mp" instead of applying rev_mp to result()
paulson
parents: 2516
diff changeset
   142
(*NS2*)
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
   143
by (blast_tac (claset() addSEs [MPair_parts]
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   144
		       addDs  [Says_imp_spies RS parts.Inj,
3121
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 2637
diff changeset
   145
			       parts.Body, unique_NA]) 3);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   146
(*NS1*)
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
   147
by (blast_tac (claset() addSEs spies_partsEs
3121
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 2637
diff changeset
   148
                       addIs  [impOfSubs analz_subset_parts]) 2);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   149
(*Fake*)
2497
47de509bdd55 New treatment of nonce creation
paulson
parents: 2480
diff changeset
   150
by (spy_analz_tac 1);
2536
1e04eb7f7eb1 Tidied proofs by using "etac rev_mp" instead of applying rev_mp to result()
paulson
parents: 2516
diff changeset
   151
qed "Spy_not_see_NA";
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   152
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   153
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   154
(*Authentication for A: if she receives message 2 and has used NA
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   155
  to start a run, then B has sent message 2.*)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   156
goal thy 
3466
30791e5a69c4 Corrected indentations and margins after the renaming of "set_of_list"
paulson
parents: 3465
diff changeset
   157
 "!!evs. [| Says A B (Crypt (pubK B) {|Nonce NA, Agent A|}) : set evs;  \
30791e5a69c4 Corrected indentations and margins after the renaming of "set_of_list"
paulson
parents: 3465
diff changeset
   158
\           Says B' A (Crypt(pubK A) {|Nonce NA, Nonce NB|}): set evs;  \
3709
c13c2137e9ee Tidied proofs, using Clarify_tac
paulson
parents: 3703
diff changeset
   159
\           A ~: bad;  B ~: bad;  evs : ns_public |]                    \
3465
e85c24717cad set_of_list -> set
nipkow
parents: 3440
diff changeset
   160
\        ==> Says B A (Crypt(pubK A) {|Nonce NA, Nonce NB|}): set evs";
2536
1e04eb7f7eb1 Tidied proofs by using "etac rev_mp" instead of applying rev_mp to result()
paulson
parents: 2516
diff changeset
   161
by (etac rev_mp 1);
1e04eb7f7eb1 Tidied proofs by using "etac rev_mp" instead of applying rev_mp to result()
paulson
parents: 2516
diff changeset
   162
(*prepare induction over Crypt (pubK A) {|NA,NB|} : parts H*)
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   163
by (etac (Says_imp_spies RS parts.Inj RS rev_mp) 1);
2536
1e04eb7f7eb1 Tidied proofs by using "etac rev_mp" instead of applying rev_mp to result()
paulson
parents: 2516
diff changeset
   164
by (etac ns_public.induct 1);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   165
by (ALLGOALS Asm_simp_tac);
3709
c13c2137e9ee Tidied proofs, using Clarify_tac
paulson
parents: 3703
diff changeset
   166
by (ALLGOALS Clarify_tac);
c13c2137e9ee Tidied proofs, using Clarify_tac
paulson
parents: 3703
diff changeset
   167
(*NS2*)
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
   168
by (blast_tac (claset() addDs [Says_imp_spies RS parts.Inj,
3709
c13c2137e9ee Tidied proofs, using Clarify_tac
paulson
parents: 3703
diff changeset
   169
			      Spy_not_see_NA, unique_NA]) 3);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   170
(*NS1*)
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
   171
by (blast_tac (claset() addSEs spies_partsEs) 2);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   172
(*Fake*)
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
   173
by (blast_tac (claset() addSDs [impOfSubs Fake_parts_insert]
3121
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 2637
diff changeset
   174
                       addDs  [Spy_not_see_NA, 
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 2637
diff changeset
   175
			       impOfSubs analz_subset_parts]) 1);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   176
qed "A_trusts_NS2";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   177
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   178
(*If the encrypted message appears then it originated with Alice in NS1*)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   179
goal thy 
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   180
 "!!evs. [| Crypt (pubK B) {|Nonce NA, Agent A|} : parts (spies evs); \
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   181
\           Nonce NA ~: analz (spies evs);                            \
3709
c13c2137e9ee Tidied proofs, using Clarify_tac
paulson
parents: 3703
diff changeset
   182
\           evs : ns_public |]                                        \
3465
e85c24717cad set_of_list -> set
nipkow
parents: 3440
diff changeset
   183
\   ==> Says A B (Crypt (pubK B) {|Nonce NA, Agent A|}) : set evs";
2536
1e04eb7f7eb1 Tidied proofs by using "etac rev_mp" instead of applying rev_mp to result()
paulson
parents: 2516
diff changeset
   184
by (etac rev_mp 1);
1e04eb7f7eb1 Tidied proofs by using "etac rev_mp" instead of applying rev_mp to result()
paulson
parents: 2516
diff changeset
   185
by (etac rev_mp 1);
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
   186
by (parts_induct_tac 1);
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
   187
by (Fake_parts_insert_tac 1);
3121
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 2637
diff changeset
   188
qed "B_trusts_NS1";
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   189
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   190
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   191
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   192
(**** Authenticity properties obtained from NS2 ****)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   193
2480
f9be937df511 Tidied up the unicity proofs
paulson
parents: 2451
diff changeset
   194
(*Unicity for NS2: nonce NB identifies agent A and nonce NA
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   195
  [proof closely follows that for unique_NA] *)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   196
goal thy 
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   197
 "!!evs. [| Nonce NB ~: analz (spies evs);  evs : ns_public |]  \
3709
c13c2137e9ee Tidied proofs, using Clarify_tac
paulson
parents: 3703
diff changeset
   198
\ ==> EX A' NA'. ALL A NA.                                      \
c13c2137e9ee Tidied proofs, using Clarify_tac
paulson
parents: 3703
diff changeset
   199
\      Crypt (pubK A) {|Nonce NA, Nonce NB|}                    \
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   200
\        : parts (spies evs)  -->  A=A' & NA=NA'";
2536
1e04eb7f7eb1 Tidied proofs by using "etac rev_mp" instead of applying rev_mp to result()
paulson
parents: 2516
diff changeset
   201
by (etac rev_mp 1);
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
   202
by (parts_induct_tac 1);
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
   203
by (ALLGOALS
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
   204
    (asm_simp_tac (simpset() addsimps [all_conj_distrib, parts_insert_spies])));
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   205
(*NS2*)
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
   206
by (expand_case_tac "NB = ?y" 2 THEN blast_tac (claset() addSEs partsEs) 2);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   207
(*Fake*)
3709
c13c2137e9ee Tidied proofs, using Clarify_tac
paulson
parents: 3703
diff changeset
   208
by (Clarify_tac 1);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   209
by (ex_strip_tac 1);
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
   210
by (Fake_parts_insert_tac 1);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   211
val lemma = result();
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   212
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   213
goal thy 
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   214
 "!!evs. [| Crypt(pubK A) {|Nonce NA, Nonce NB|}  : parts(spies evs); \
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   215
\           Crypt(pubK A'){|Nonce NA', Nonce NB|} : parts(spies evs); \
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   216
\           Nonce NB ~: analz (spies evs);                            \
3709
c13c2137e9ee Tidied proofs, using Clarify_tac
paulson
parents: 3703
diff changeset
   217
\           evs : ns_public |]                                        \
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   218
\        ==> A=A' & NA=NA'";
2418
6b6a92d05fb2 New tactics: prove_unique_tac and analz_induct_tac
paulson
parents: 2374
diff changeset
   219
by (prove_unique_tac lemma 1);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   220
qed "unique_NB";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   221
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   222
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   223
(*NB remains secret PROVIDED Alice never responds with round 3*)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   224
goal thy 
3466
30791e5a69c4 Corrected indentations and margins after the renaming of "set_of_list"
paulson
parents: 3465
diff changeset
   225
 "!!evs.[| Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set evs;  \
3703
c5ae2d63dbaa Tidied some proofs using clarify_tac
paulson
parents: 3683
diff changeset
   226
\          ALL C. Says A C (Crypt (pubK C) (Nonce NB)) ~: set evs;      \
c5ae2d63dbaa Tidied some proofs using clarify_tac
paulson
parents: 3683
diff changeset
   227
\          A ~: bad;  B ~: bad;  evs : ns_public |]                     \
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   228
\       ==> Nonce NB ~: analz (spies evs)";
2536
1e04eb7f7eb1 Tidied proofs by using "etac rev_mp" instead of applying rev_mp to result()
paulson
parents: 2516
diff changeset
   229
by (etac rev_mp 1);
1e04eb7f7eb1 Tidied proofs by using "etac rev_mp" instead of applying rev_mp to result()
paulson
parents: 2516
diff changeset
   230
by (etac rev_mp 1);
2418
6b6a92d05fb2 New tactics: prove_unique_tac and analz_induct_tac
paulson
parents: 2374
diff changeset
   231
by (analz_induct_tac 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
   232
by (ALLGOALS (asm_simp_tac (simpset() addsimps [all_conj_distrib])));
3709
c13c2137e9ee Tidied proofs, using Clarify_tac
paulson
parents: 3703
diff changeset
   233
by (ALLGOALS Clarify_tac);
3703
c5ae2d63dbaa Tidied some proofs using clarify_tac
paulson
parents: 3683
diff changeset
   234
(*NS3: because NB determines A*)
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
   235
by (blast_tac (claset() addDs [Says_imp_spies RS parts.Inj, unique_NB]) 4);
3703
c5ae2d63dbaa Tidied some proofs using clarify_tac
paulson
parents: 3683
diff changeset
   236
(*NS2: by freshness and unicity of NB*)
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
   237
by (blast_tac (claset() addDs [Says_imp_spies RS parts.Inj]
3703
c5ae2d63dbaa Tidied some proofs using clarify_tac
paulson
parents: 3683
diff changeset
   238
                       addEs [no_nonce_NS1_NS2 RSN (2, rev_notE)]
c5ae2d63dbaa Tidied some proofs using clarify_tac
paulson
parents: 3683
diff changeset
   239
                       addEs partsEs
c5ae2d63dbaa Tidied some proofs using clarify_tac
paulson
parents: 3683
diff changeset
   240
		       addIs [impOfSubs analz_subset_parts]) 3);
c5ae2d63dbaa Tidied some proofs using clarify_tac
paulson
parents: 3683
diff changeset
   241
(*NS1: by freshness*)
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
   242
by (blast_tac (claset() addSEs spies_partsEs) 2);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   243
(*Fake*)
2497
47de509bdd55 New treatment of nonce creation
paulson
parents: 2480
diff changeset
   244
by (spy_analz_tac 1);
2536
1e04eb7f7eb1 Tidied proofs by using "etac rev_mp" instead of applying rev_mp to result()
paulson
parents: 2516
diff changeset
   245
qed "Spy_not_see_NB";
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   246
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   247
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   248
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   249
(*Authentication for B: if he receives message 3 and has used NB
2536
1e04eb7f7eb1 Tidied proofs by using "etac rev_mp" instead of applying rev_mp to result()
paulson
parents: 2516
diff changeset
   250
  in message 2, then A has sent message 3--to somebody....*)
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   251
goal thy 
3545
4336eb0486bc Cosmetic changes: margins, indentation, ...
paulson
parents: 3519
diff changeset
   252
 "!!evs. [| Says B A  (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set evs; \
4336eb0486bc Cosmetic changes: margins, indentation, ...
paulson
parents: 3519
diff changeset
   253
\           Says A' B (Crypt (pubK B) (Nonce NB)): set evs;              \
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   254
\           A ~: bad;  B ~: bad;  evs : ns_public |]                   \
3465
e85c24717cad set_of_list -> set
nipkow
parents: 3440
diff changeset
   255
\        ==> EX C. Says A C (Crypt (pubK C) (Nonce NB)) : set evs";
2536
1e04eb7f7eb1 Tidied proofs by using "etac rev_mp" instead of applying rev_mp to result()
paulson
parents: 2516
diff changeset
   256
by (etac rev_mp 1);
1e04eb7f7eb1 Tidied proofs by using "etac rev_mp" instead of applying rev_mp to result()
paulson
parents: 2516
diff changeset
   257
(*prepare induction over Crypt (pubK B) NB : parts H*)
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   258
by (etac (Says_imp_spies RS parts.Inj RS rev_mp) 1);
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3466
diff changeset
   259
by (parts_induct_tac 1);
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
   260
by (ALLGOALS (asm_simp_tac (simpset() addsimps [ex_disj_distrib])));
3709
c13c2137e9ee Tidied proofs, using Clarify_tac
paulson
parents: 3703
diff changeset
   261
by (ALLGOALS Clarify_tac);
3703
c5ae2d63dbaa Tidied some proofs using clarify_tac
paulson
parents: 3683
diff changeset
   262
(*NS3: because NB determines A*)
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
   263
by (blast_tac (claset() addDs [Says_imp_spies RS parts.Inj, 
3703
c5ae2d63dbaa Tidied some proofs using clarify_tac
paulson
parents: 3683
diff changeset
   264
			      Spy_not_see_NB, unique_NB]) 3);
c5ae2d63dbaa Tidied some proofs using clarify_tac
paulson
parents: 3683
diff changeset
   265
(*NS1: by freshness*)
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
   266
by (blast_tac (claset() addSEs spies_partsEs) 2);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   267
(*Fake*)
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
   268
by (blast_tac (claset() addSDs [impOfSubs Fake_parts_insert]
3121
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 2637
diff changeset
   269
                       addDs  [Spy_not_see_NB, 
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 2637
diff changeset
   270
			       impOfSubs analz_subset_parts]) 1);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   271
qed "B_trusts_NS3";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   272
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   273
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   274
(*Can we strengthen the secrecy theorem?  NO*)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   275
goal thy 
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   276
 "!!evs. [| A ~: bad;  B ~: bad;  evs : ns_public |]           \
3465
e85c24717cad set_of_list -> set
nipkow
parents: 3440
diff changeset
   277
\ ==> Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set evs \
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   278
\     --> Nonce NB ~: analz (spies evs)";
2418
6b6a92d05fb2 New tactics: prove_unique_tac and analz_induct_tac
paulson
parents: 2374
diff changeset
   279
by (analz_induct_tac 1);
3709
c13c2137e9ee Tidied proofs, using Clarify_tac
paulson
parents: 3703
diff changeset
   280
by (ALLGOALS Clarify_tac);
3703
c5ae2d63dbaa Tidied some proofs using clarify_tac
paulson
parents: 3683
diff changeset
   281
(*NS2: by freshness and unicity of NB*)
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
   282
by (blast_tac (claset() addDs [Says_imp_spies RS parts.Inj]
3703
c5ae2d63dbaa Tidied some proofs using clarify_tac
paulson
parents: 3683
diff changeset
   283
                       addEs [no_nonce_NS1_NS2 RSN (2, rev_notE)]
c5ae2d63dbaa Tidied some proofs using clarify_tac
paulson
parents: 3683
diff changeset
   284
                       addEs partsEs
c5ae2d63dbaa Tidied some proofs using clarify_tac
paulson
parents: 3683
diff changeset
   285
		       addIs [impOfSubs analz_subset_parts]) 3);
c5ae2d63dbaa Tidied some proofs using clarify_tac
paulson
parents: 3683
diff changeset
   286
(*NS1: by freshness*)
4091
771b1f6422a8 isatool fixclasimp;
wenzelm
parents: 3919
diff changeset
   287
by (blast_tac (claset() addSEs spies_partsEs) 2);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   288
(*Fake*)
2497
47de509bdd55 New treatment of nonce creation
paulson
parents: 2480
diff changeset
   289
by (spy_analz_tac 1);
3703
c5ae2d63dbaa Tidied some proofs using clarify_tac
paulson
parents: 3683
diff changeset
   290
(*NS3: unicity of NB identifies A and NA, but not B*)
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   291
by (forw_inst_tac [("A'","A")] (Says_imp_spies RS parts.Inj RS unique_NB) 1
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   292
    THEN REPEAT (eresolve_tac [asm_rl, Says_imp_spies RS parts.Inj] 1));
3703
c5ae2d63dbaa Tidied some proofs using clarify_tac
paulson
parents: 3683
diff changeset
   293
by (Auto_tac());
c5ae2d63dbaa Tidied some proofs using clarify_tac
paulson
parents: 3683
diff changeset
   294
by (rename_tac "C B' evs3" 1);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   295
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   296
(*
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   297
THIS IS THE ATTACK!
3703
c5ae2d63dbaa Tidied some proofs using clarify_tac
paulson
parents: 3683
diff changeset
   298
Level 8
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   299
!!evs. [| A ~: bad; B ~: bad; evs : ns_public |]
3703
c5ae2d63dbaa Tidied some proofs using clarify_tac
paulson
parents: 3683
diff changeset
   300
       ==> Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set evs -->
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   301
           Nonce NB ~: analz (spies evs)
3703
c5ae2d63dbaa Tidied some proofs using clarify_tac
paulson
parents: 3683
diff changeset
   302
 1. !!C B' evs3.
c5ae2d63dbaa Tidied some proofs using clarify_tac
paulson
parents: 3683
diff changeset
   303
       [| A ~: bad; B ~: bad; evs3 : ns_public;
c5ae2d63dbaa Tidied some proofs using clarify_tac
paulson
parents: 3683
diff changeset
   304
          Says A C (Crypt (pubK C) {|Nonce NA, Agent A|}) : set evs3;
c5ae2d63dbaa Tidied some proofs using clarify_tac
paulson
parents: 3683
diff changeset
   305
          Says B' A (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set evs3; C : bad;
c5ae2d63dbaa Tidied some proofs using clarify_tac
paulson
parents: 3683
diff changeset
   306
          Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB|}) : set evs3;
c5ae2d63dbaa Tidied some proofs using clarify_tac
paulson
parents: 3683
diff changeset
   307
          Nonce NB ~: analz (spies evs3) |]
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   308
       ==> False
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   309
*)