src/HOL/Auth/NS_Public.ML
author paulson
Tue, 23 Dec 1997 11:56:09 +0100
changeset 4476 fbdc87f8ac7e
parent 4470 af3239def3d4
child 4477 b3e5857d8d99
permissions -rw-r--r--
Tidied using rev_iffD1
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
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
Version incorporating Lowe's fix (inclusion of B's identify in round 2).
4470
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
     8
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
     9
This version is experimental.  It adds many more rules to the claset and even
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
    10
replaces Fake_parts_insert_tac by Blast_tac.
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    11
*)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    12
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    13
open NS_Public;
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    14
4449
wenzelm
parents: 4422
diff changeset
    15
set proof_timing;
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    16
HOL_quantifiers := false;
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    17
4470
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
    18
AddEs spies_partsEs;
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
    19
AddDs [impOfSubs analz_subset_parts];
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
    20
AddDs [impOfSubs Fake_parts_insert];
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
    21
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
    22
AddIffs [Spy_in_bad];
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    23
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    24
(*A "possibility property": there are traces that reach the end*)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    25
goal thy 
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    26
 "!!A B. A ~= B ==> EX NB. EX evs: ns_public.               \
3465
e85c24717cad set_of_list -> set
nipkow
parents: 3121
diff changeset
    27
\                     Says A B (Crypt (pubK B) (Nonce NB)) : set evs";
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    28
by (REPEAT (resolve_tac [exI,bexI] 1));
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    29
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
    30
by possibility_tac;
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    31
result();
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    32
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    33
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    34
(**** Inductive proofs about ns_public ****)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    35
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    36
(*Nobody sends themselves messages*)
3465
e85c24717cad set_of_list -> set
nipkow
parents: 3121
diff changeset
    37
goal thy "!!evs. evs : ns_public ==> ALL A X. Says A A X ~: set evs";
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    38
by (etac ns_public.induct 1);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    39
by (Auto_tac());
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    40
qed_spec_mp "not_Says_to_self";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    41
Addsimps [not_Says_to_self];
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    42
AddSEs   [not_Says_to_self RSN (2, rev_notE)];
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    43
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    44
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
    45
(*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
    46
   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
    47
   needless information about analz (insert X (spies evs))  *)
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
    48
fun parts_induct_tac i = 
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
    49
    etac ns_public.induct i
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
    50
    THEN 
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
    51
    REPEAT (FIRSTGOAL analz_mono_contra_tac)
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
    52
    THEN 
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
    53
    prove_simple_subgoals_tac i;
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
    54
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
    55
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
    56
(** Theorems of the form X ~: parts (spies evs) imply that NOBODY
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    57
    sends messages containing X! **)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    58
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
    59
(*Spy never sees another agent's private key! (unless it's bad at start)*)
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    60
goal thy 
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
    61
 "!!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: 3516
diff changeset
    62
by (parts_induct_tac 1);
4470
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
    63
by (Blast_tac 1);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    64
qed "Spy_see_priK";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    65
Addsimps [Spy_see_priK];
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    66
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    67
goal thy 
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
    68
 "!!A. evs: ns_public ==> (Key (priK A) : analz (spies evs)) = (A : bad)";
4422
21238c9d363e Simplified proofs using rewrites for f``A where f is injective
paulson
parents: 4197
diff changeset
    69
by (Auto_tac());
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    70
qed "Spy_analz_priK";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    71
Addsimps [Spy_analz_priK];
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    72
4470
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
    73
AddSDs [Spy_see_priK RSN (2, rev_iffD1), 
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
    74
	Spy_analz_priK RSN (2, rev_iffD1)];
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    75
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
    76
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
    77
(**** Authenticity properties obtained from NS2 ****)
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
    78
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
    79
(*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: 3516
diff changeset
    80
  is secret.  (Honest users generate fresh nonces.)*)
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
    81
goal thy 
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
    82
 "!!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
    83
\           Nonce NA ~: analz (spies evs);       \
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
    84
\           evs : ns_public |]                      \
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
    85
\ ==> Crypt (pubK C) {|NA', Nonce NA, Agent D|} ~: parts (spies evs)";
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
    86
by (etac rev_mp 1);
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
    87
by (etac rev_mp 1);
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
    88
by (parts_induct_tac 1);
4470
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
    89
by (ALLGOALS Blast_tac);
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
    90
qed "no_nonce_NS1_NS2";
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
    91
4470
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
    92
(*Adding it to the claset slows down proofs...*)
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
    93
val nonce_NS1_NS2_E = no_nonce_NS1_NS2 RSN (2, rev_notE);
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
    94
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
    95
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
    96
(*Unicity for NS1: nonce NA identifies agents A and B*)
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
    97
goal thy 
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
    98
 "!!evs. [| Nonce NA ~: analz (spies evs);  evs : ns_public |]      \
3709
c13c2137e9ee Tidied proofs, using Clarify_tac
paulson
parents: 3683
diff changeset
    99
\ ==> EX A' B'. ALL A B.                                            \
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   100
\      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: 3516
diff changeset
   101
\      A=A' & B=B'";
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
   102
by (etac rev_mp 1);
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
   103
by (parts_induct_tac 1);
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
   104
by (ALLGOALS
4470
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
   105
    (asm_simp_tac (simpset() addsimps [all_conj_distrib,
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
   106
				       parts_insert_spies])));
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
   107
(*NS1*)
4470
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
   108
by (expand_case_tac "NA = ?y" 2 THEN Blast_tac 2);
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
   109
(*Fake*)
3709
c13c2137e9ee Tidied proofs, using Clarify_tac
paulson
parents: 3683
diff changeset
   110
by (Clarify_tac 1);
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
   111
by (ex_strip_tac 1);
4470
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
   112
by (Blast_tac 1);
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
   113
val lemma = result();
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
   114
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
   115
goal thy 
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   116
 "!!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
   117
\           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
\           Nonce NA ~: analz (spies evs);                            \
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   119
\           evs : ns_public |]                                        \
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
   120
\        ==> A=A' & B=B'";
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
   121
by (prove_unique_tac lemma 1);
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
   122
qed "unique_NA";
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
   123
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
   124
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
   125
(*Tactic for proving secrecy theorems*)
2418
6b6a92d05fb2 New tactics: prove_unique_tac and analz_induct_tac
paulson
parents: 2374
diff changeset
   126
fun analz_induct_tac i = 
3121
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 2637
diff changeset
   127
    etac ns_public.induct i   THEN
4470
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
   128
    ALLGOALS (asm_simp_tac (simpset() addsplits [expand_if]));
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   129
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   130
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   131
(*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
   132
goal thy 
3466
30791e5a69c4 Corrected indentations and margins after the renaming of "set_of_list"
paulson
parents: 3465
diff changeset
   133
 "!!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
   134
\           A ~: bad;  B ~: bad;  evs : ns_public |]                        \
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   135
\        ==>  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
   136
by (etac rev_mp 1);
2418
6b6a92d05fb2 New tactics: prove_unique_tac and analz_induct_tac
paulson
parents: 2374
diff changeset
   137
by (analz_induct_tac 1);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   138
(*NS3*)
4470
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
   139
by (blast_tac (claset() addEs [nonce_NS1_NS2_E]) 4);
2536
1e04eb7f7eb1 Tidied proofs by using "etac rev_mp" instead of applying rev_mp to result()
paulson
parents: 2516
diff changeset
   140
(*NS2*)
4470
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
   141
by (blast_tac (claset() addDs [unique_NA]) 3);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   142
(*NS1*)
4470
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
   143
by (Blast_tac 2);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   144
(*Fake*)
2497
47de509bdd55 New treatment of nonce creation
paulson
parents: 2480
diff changeset
   145
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
   146
qed "Spy_not_see_NA";
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   147
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   148
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   149
(*Authentication for A: if she receives message 2 and has used NA
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   150
  to start a run, then B has sent message 2.*)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   151
goal thy 
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
   152
 "!!evs. [| Says A B (Crypt (pubK B) {|Nonce NA, Agent A|}) : set evs;  \
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
   153
\           Says B' A (Crypt(pubK A) {|Nonce NA, Nonce NB, Agent B|})   \
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
   154
\             : set evs;                                                \
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   155
\           A ~: bad;  B ~: bad;  evs : ns_public |]                  \
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
   156
\        ==> Says B A (Crypt(pubK A) {|Nonce NA, Nonce NB, Agent B|})   \
3465
e85c24717cad set_of_list -> set
nipkow
parents: 3121
diff changeset
   157
\              : set evs";
2536
1e04eb7f7eb1 Tidied proofs by using "etac rev_mp" instead of applying rev_mp to result()
paulson
parents: 2516
diff changeset
   158
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
   159
(*prepare induction over Crypt (pubK A) {|NA,NB,B|} : parts H*)
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   160
by (etac (Says_imp_spies RS parts.Inj RS rev_mp) 1);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   161
by (etac ns_public.induct 1);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   162
by (ALLGOALS Asm_simp_tac);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   163
(*NS1*)
4470
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
   164
by (Blast_tac 2);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   165
(*Fake*)
4422
21238c9d363e Simplified proofs using rewrites for f``A where f is injective
paulson
parents: 4197
diff changeset
   166
by (blast_tac (claset() addDs [Spy_not_see_NA]) 1);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   167
qed "A_trusts_NS2";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   168
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   169
(*If the encrypted message appears then it originated with Alice in NS1*)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   170
goal thy 
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   171
 "!!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
   172
\           Nonce NA ~: analz (spies evs);                 \
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   173
\           evs : ns_public |]                             \
3465
e85c24717cad set_of_list -> set
nipkow
parents: 3121
diff changeset
   174
\   ==> 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
   175
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
   176
by (etac rev_mp 1);
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
   177
by (parts_induct_tac 1);
4470
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
   178
by (Blast_tac 1);
2536
1e04eb7f7eb1 Tidied proofs by using "etac rev_mp" instead of applying rev_mp to result()
paulson
parents: 2516
diff changeset
   179
qed "B_trusts_NS1";
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   180
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   181
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   182
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   183
(**** Authenticity properties obtained from NS2 ****)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   184
2480
f9be937df511 Tidied up the unicity proofs
paulson
parents: 2451
diff changeset
   185
(*Unicity for NS2: nonce NB identifies nonce NA and agents A, B 
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   186
  [unicity of B makes Lowe's fix work]
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   187
  [proof closely follows that for unique_NA] *)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   188
goal thy 
3709
c13c2137e9ee Tidied proofs, using Clarify_tac
paulson
parents: 3683
diff changeset
   189
 "!!evs. [| Nonce NB ~: analz (spies evs);  evs : ns_public |]            \
c13c2137e9ee Tidied proofs, using Clarify_tac
paulson
parents: 3683
diff changeset
   190
\ ==> EX A' NA' B'. ALL A NA B.                                           \
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   191
\      Crypt (pubK A) {|Nonce NA, Nonce NB, Agent B|} : parts (spies evs) \
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   192
\         -->  A=A' & NA=NA' & B=B'";
2536
1e04eb7f7eb1 Tidied proofs by using "etac rev_mp" instead of applying rev_mp to result()
paulson
parents: 2516
diff changeset
   193
by (etac rev_mp 1);
3519
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
   194
by (parts_induct_tac 1);
ab0a9fbed4c0 Changing "lost" from a parameter of protocol definitions to a constant.
paulson
parents: 3516
diff changeset
   195
by (ALLGOALS
4422
21238c9d363e Simplified proofs using rewrites for f``A where f is injective
paulson
parents: 4197
diff changeset
   196
    (asm_simp_tac (simpset() addsimps [all_conj_distrib, 
21238c9d363e Simplified proofs using rewrites for f``A where f is injective
paulson
parents: 4197
diff changeset
   197
				       parts_insert_spies])));
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   198
(*NS2*)
4470
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
   199
by (expand_case_tac "NB = ?y" 2 THEN Blast_tac 2);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   200
(*Fake*)
3709
c13c2137e9ee Tidied proofs, using Clarify_tac
paulson
parents: 3683
diff changeset
   201
by (Clarify_tac 1);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   202
by (ex_strip_tac 1);
4470
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
   203
by (Blast_tac 1);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   204
val lemma = result();
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   205
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   206
goal thy 
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   207
 "!!evs. [| Crypt(pubK A)  {|Nonce NA, Nonce NB, Agent B|}   \
3709
c13c2137e9ee Tidied proofs, using Clarify_tac
paulson
parents: 3683
diff changeset
   208
\             : parts(spies evs);                            \
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   209
\           Crypt(pubK A') {|Nonce NA', Nonce NB, Agent B'|} \
3709
c13c2137e9ee Tidied proofs, using Clarify_tac
paulson
parents: 3683
diff changeset
   210
\             : parts(spies evs);                            \
c13c2137e9ee Tidied proofs, using Clarify_tac
paulson
parents: 3683
diff changeset
   211
\           Nonce NB ~: analz (spies evs);                   \
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   212
\           evs : ns_public |]                               \
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   213
\        ==> A=A' & NA=NA' & B=B'";
2418
6b6a92d05fb2 New tactics: prove_unique_tac and analz_induct_tac
paulson
parents: 2374
diff changeset
   214
by (prove_unique_tac lemma 1);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   215
qed "unique_NB";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   216
4470
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
   217
AddDs [unique_NB];
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
   218
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   219
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   220
(*Secrecy: Spy does not see the nonce sent in msg NS2 if A and B are secure*)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   221
goal thy 
2536
1e04eb7f7eb1 Tidied proofs by using "etac rev_mp" instead of applying rev_mp to result()
paulson
parents: 2516
diff changeset
   222
 "!!evs. [| Says B A (Crypt (pubK A) {|Nonce NA, Nonce NB, Agent B|}) \
3466
30791e5a69c4 Corrected indentations and margins after the renaming of "set_of_list"
paulson
parents: 3465
diff changeset
   223
\             : set evs;                                              \
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   224
\           A ~: bad;  B ~: bad;  evs : ns_public |]                \
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   225
\ ==> 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
   226
by (etac rev_mp 1);
2418
6b6a92d05fb2 New tactics: prove_unique_tac and analz_induct_tac
paulson
parents: 2374
diff changeset
   227
by (analz_induct_tac 1);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   228
(*NS3*)
4470
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
   229
by (Blast_tac 4);
3709
c13c2137e9ee Tidied proofs, using Clarify_tac
paulson
parents: 3683
diff changeset
   230
(*NS2: by freshness and unicity of NB*)
4470
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
   231
by (blast_tac (claset() addEs [nonce_NS1_NS2_E]) 3);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   232
(*NS1*)
4470
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
   233
by (Blast_tac 2);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   234
(*Fake*)
2497
47de509bdd55 New treatment of nonce creation
paulson
parents: 2480
diff changeset
   235
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
   236
qed "Spy_not_see_NB";
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   237
4422
21238c9d363e Simplified proofs using rewrites for f``A where f is injective
paulson
parents: 4197
diff changeset
   238
AddDs [Spy_not_see_NB];
21238c9d363e Simplified proofs using rewrites for f``A where f is injective
paulson
parents: 4197
diff changeset
   239
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   240
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   241
(*Authentication for B: if he receives message 3 and has used NB
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   242
  in message 2, then A has sent message 3.*)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   243
goal thy 
2536
1e04eb7f7eb1 Tidied proofs by using "etac rev_mp" instead of applying rev_mp to result()
paulson
parents: 2516
diff changeset
   244
 "!!evs. [| Says B A  (Crypt (pubK A) {|Nonce NA, Nonce NB, Agent B|}) \
3466
30791e5a69c4 Corrected indentations and margins after the renaming of "set_of_list"
paulson
parents: 3465
diff changeset
   245
\             : set evs;                                               \
30791e5a69c4 Corrected indentations and margins after the renaming of "set_of_list"
paulson
parents: 3465
diff changeset
   246
\           Says A' B (Crypt (pubK B) (Nonce NB)): set evs;            \
4197
1547bc6daa5a Made some proofs more robust
paulson
parents: 4091
diff changeset
   247
\           A ~: bad;  B ~: bad;  evs : ns_public |]                   \
3465
e85c24717cad set_of_list -> set
nipkow
parents: 3121
diff changeset
   248
\        ==> Says A B (Crypt (pubK B) (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
   249
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
   250
(*prepare induction over Crypt (pubK B) NB : parts H*)
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   251
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: 3516
diff changeset
   252
by (parts_induct_tac 1);
3709
c13c2137e9ee Tidied proofs, using Clarify_tac
paulson
parents: 3683
diff changeset
   253
by (ALLGOALS Clarify_tac);
4470
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
   254
by (ALLGOALS Blast_tac);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   255
qed "B_trusts_NS3";
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   256
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   257
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   258
(**** Overall guarantee for B*)
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   259
3121
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 2637
diff changeset
   260
(*Matches only NS2, not NS1 (or NS3)*)
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   261
val Says_imp_spies' = 
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   262
    read_instantiate [("X","Crypt ?K {|?XX,?YY,?ZZ|}")] Says_imp_spies;
3121
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 2637
diff changeset
   263
cbb6c0c1c58a Conversion to use blast_tac (with other improvements)
paulson
parents: 2637
diff changeset
   264
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   265
(*If B receives NS3 and the nonce NB agrees with the nonce he joined with
2536
1e04eb7f7eb1 Tidied proofs by using "etac rev_mp" instead of applying rev_mp to result()
paulson
parents: 2516
diff changeset
   266
  NA, then A initiated the run using NA.  SAME proof as B_trusts_NS3!*)
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   267
goal thy 
2536
1e04eb7f7eb1 Tidied proofs by using "etac rev_mp" instead of applying rev_mp to result()
paulson
parents: 2516
diff changeset
   268
 "!!evs. [| Says B A  (Crypt (pubK A) {|Nonce NA, Nonce NB, Agent B|}) \
3466
30791e5a69c4 Corrected indentations and margins after the renaming of "set_of_list"
paulson
parents: 3465
diff changeset
   269
\             : set evs;                                               \
30791e5a69c4 Corrected indentations and margins after the renaming of "set_of_list"
paulson
parents: 3465
diff changeset
   270
\           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
   271
\           A ~: bad;  B ~: bad;  evs : ns_public |]                 \
3465
e85c24717cad set_of_list -> set
nipkow
parents: 3121
diff changeset
   272
\    ==> 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
   273
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
   274
(*prepare induction over Crypt (pubK B) {|NB|} : parts H*)
3683
aafe719dff14 Global change: lost->bad and sees Spy->spies
paulson
parents: 3675
diff changeset
   275
by (etac (Says_imp_spies RS parts.Inj RS rev_mp) 1);
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   276
by (etac ns_public.induct 1);
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   277
by (ALLGOALS Asm_simp_tac);
3709
c13c2137e9ee Tidied proofs, using Clarify_tac
paulson
parents: 3683
diff changeset
   278
by (ALLGOALS Clarify_tac);
4470
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
   279
(*NS3 holds because NB determines A and NA*)
af3239def3d4 Tidied using more default rules
paulson
parents: 4449
diff changeset
   280
by (ALLGOALS Blast_tac);
2536
1e04eb7f7eb1 Tidied proofs by using "etac rev_mp" instead of applying rev_mp to result()
paulson
parents: 2516
diff changeset
   281
qed "B_trusts_protocol";
2318
6d3f7c7f70b0 Public-key examples
paulson
parents:
diff changeset
   282