author | paulson |
Tue, 23 Sep 2003 15:41:33 +0200 | |
changeset 14200 | d8598e24f8fa |
parent 13956 | 8fe7e12290e1 |
child 14207 | f20fbb141673 |
permissions | -rw-r--r-- |
2318 | 1 |
(* Title: HOL/Auth/NS_Public |
2 |
ID: $Id$ |
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
|
4 |
Copyright 1996 University of Cambridge |
|
5 |
||
6 |
Inductive relation "ns_public" for the Needham-Schroeder Public-Key protocol. |
|
2538 | 7 |
Version incorporating Lowe's fix (inclusion of B's identity in round 2). |
2318 | 8 |
*) |
9 |
||
13956 | 10 |
header{*Verifying the Needham-Schroeder-Lowe Public-Key Protocol*} |
11 |
||
11104 | 12 |
theory NS_Public = Public: |
2318 | 13 |
|
11104 | 14 |
consts ns_public :: "event list set" |
2549 | 15 |
|
2318 | 16 |
inductive ns_public |
11104 | 17 |
intros |
2318 | 18 |
(*Initial trace is empty*) |
11104 | 19 |
Nil: "[] \<in> ns_public" |
2318 | 20 |
|
21 |
(*The spy MAY say anything he CAN say. We do not expect him to |
|
22 |
invent new nonces here, but he can also use NS1. Common to |
|
23 |
all similar protocols.*) |
|
11366 | 24 |
Fake: "\<lbrakk>evsf \<in> ns_public; X \<in> synth (analz (spies evsf))\<rbrakk> |
25 |
\<Longrightarrow> Says Spy B X # evsf \<in> ns_public" |
|
2318 | 26 |
|
27 |
(*Alice initiates a protocol run, sending a nonce to Bob*) |
|
11104 | 28 |
NS1: "\<lbrakk>evs1 \<in> ns_public; Nonce NA \<notin> used evs1\<rbrakk> |
13922 | 29 |
\<Longrightarrow> Says A B (Crypt (pubEK B) \<lbrace>Nonce NA, Agent A\<rbrace>) |
11104 | 30 |
# evs1 \<in> ns_public" |
2318 | 31 |
|
32 |
(*Bob responds to Alice's message with a further nonce*) |
|
11104 | 33 |
NS2: "\<lbrakk>evs2 \<in> ns_public; Nonce NB \<notin> used evs2; |
13922 | 34 |
Says A' B (Crypt (pubEK B) \<lbrace>Nonce NA, Agent A\<rbrace>) \<in> set evs2\<rbrakk> |
35 |
\<Longrightarrow> Says B A (Crypt (pubEK A) \<lbrace>Nonce NA, Nonce NB, Agent B\<rbrace>) |
|
11104 | 36 |
# evs2 \<in> ns_public" |
2318 | 37 |
|
38 |
(*Alice proves her existence by sending NB back to Bob.*) |
|
11104 | 39 |
NS3: "\<lbrakk>evs3 \<in> ns_public; |
13922 | 40 |
Says A B (Crypt (pubEK B) \<lbrace>Nonce NA, Agent A\<rbrace>) \<in> set evs3; |
41 |
Says B' A (Crypt (pubEK A) \<lbrace>Nonce NA, Nonce NB, Agent B\<rbrace>) |
|
11104 | 42 |
\<in> set evs3\<rbrakk> |
13922 | 43 |
\<Longrightarrow> Says A B (Crypt (pubEK B) (Nonce NB)) # evs3 \<in> ns_public" |
11104 | 44 |
|
45 |
declare knows_Spy_partsEs [elim] |
|
14200
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents:
13956
diff
changeset
|
46 |
declare knows_Spy_partsEs [elim] |
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents:
13956
diff
changeset
|
47 |
declare analz_into_parts [dest] |
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents:
13956
diff
changeset
|
48 |
declare Fake_parts_insert_in_Un [dest] |
11104 | 49 |
declare image_eq_UN [simp] (*accelerates proofs involving nested images*) |
50 |
||
51 |
(*A "possibility property": there are traces that reach the end*) |
|
13922 | 52 |
lemma "\<exists>NB. \<exists>evs \<in> ns_public. Says A B (Crypt (pubEK B) (Nonce NB)) \<in> set evs" |
11104 | 53 |
apply (intro exI bexI) |
54 |
apply (rule_tac [2] ns_public.Nil [THEN ns_public.NS1, THEN ns_public.NS2, |
|
55 |
THEN ns_public.NS3]) |
|
13926 | 56 |
apply possibility |
57 |
done |
|
11104 | 58 |
|
59 |
(** Theorems of the form X \<notin> parts (spies evs) imply that NOBODY |
|
60 |
sends messages containing X! **) |
|
61 |
||
62 |
(*Spy never sees another agent's private key! (unless it's bad at start)*) |
|
13922 | 63 |
lemma Spy_see_priEK [simp]: |
64 |
"evs \<in> ns_public \<Longrightarrow> (Key (priEK A) \<in> parts (spies evs)) = (A \<in> bad)" |
|
11104 | 65 |
by (erule ns_public.induct, auto) |
66 |
||
13922 | 67 |
lemma Spy_analz_priEK [simp]: |
68 |
"evs \<in> ns_public \<Longrightarrow> (Key (priEK A) \<in> analz (spies evs)) = (A \<in> bad)" |
|
11104 | 69 |
by auto |
70 |
||
14200
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents:
13956
diff
changeset
|
71 |
subsection{*Authenticity properties obtained from NS2*} |
11104 | 72 |
|
73 |
||
74 |
(*It is impossible to re-use a nonce in both NS1 and NS2, provided the nonce |
|
75 |
is secret. (Honest users generate fresh nonces.)*) |
|
76 |
lemma no_nonce_NS1_NS2 [rule_format]: |
|
77 |
"evs \<in> ns_public |
|
13922 | 78 |
\<Longrightarrow> Crypt (pubEK C) \<lbrace>NA', Nonce NA, Agent D\<rbrace> \<in> parts (spies evs) \<longrightarrow> |
79 |
Crypt (pubEK B) \<lbrace>Nonce NA, Agent A\<rbrace> \<in> parts (spies evs) \<longrightarrow> |
|
11104 | 80 |
Nonce NA \<in> analz (spies evs)" |
81 |
apply (erule ns_public.induct, simp_all) |
|
82 |
apply (blast intro: analz_insertI)+ |
|
83 |
done |
|
84 |
||
85 |
(*Unicity for NS1: nonce NA identifies agents A and B*) |
|
86 |
lemma unique_NA: |
|
13922 | 87 |
"\<lbrakk>Crypt(pubEK B) \<lbrace>Nonce NA, Agent A \<rbrace> \<in> parts(spies evs); |
88 |
Crypt(pubEK B') \<lbrace>Nonce NA, Agent A'\<rbrace> \<in> parts(spies evs); |
|
11104 | 89 |
Nonce NA \<notin> analz (spies evs); evs \<in> ns_public\<rbrakk> |
90 |
\<Longrightarrow> A=A' \<and> B=B'" |
|
91 |
apply (erule rev_mp, erule rev_mp, erule rev_mp) |
|
92 |
apply (erule ns_public.induct, simp_all) |
|
93 |
(*Fake, NS1*) |
|
94 |
apply (blast intro: analz_insertI)+ |
|
95 |
done |
|
96 |
||
97 |
||
98 |
(*Secrecy: Spy does not see the nonce sent in msg NS1 if A and B are secure |
|
99 |
The major premise "Says A B ..." makes it a dest-rule, so we use |
|
100 |
(erule rev_mp) rather than rule_format. *) |
|
101 |
theorem Spy_not_see_NA: |
|
13922 | 102 |
"\<lbrakk>Says A B (Crypt(pubEK B) \<lbrace>Nonce NA, Agent A\<rbrace>) \<in> set evs; |
11104 | 103 |
A \<notin> bad; B \<notin> bad; evs \<in> ns_public\<rbrakk> |
104 |
\<Longrightarrow> Nonce NA \<notin> analz (spies evs)" |
|
105 |
apply (erule rev_mp) |
|
13507 | 106 |
apply (erule ns_public.induct, simp_all, spy_analz) |
11104 | 107 |
apply (blast dest: unique_NA intro: no_nonce_NS1_NS2)+ |
108 |
done |
|
109 |
||
2318 | 110 |
|
11104 | 111 |
(*Authentication for A: if she receives message 2 and has used NA |
112 |
to start a run, then B has sent message 2.*) |
|
113 |
lemma A_trusts_NS2_lemma [rule_format]: |
|
114 |
"\<lbrakk>A \<notin> bad; B \<notin> bad; evs \<in> ns_public\<rbrakk> |
|
13922 | 115 |
\<Longrightarrow> Crypt (pubEK A) \<lbrace>Nonce NA, Nonce NB, Agent B\<rbrace> \<in> parts (spies evs) \<longrightarrow> |
116 |
Says A B (Crypt(pubEK B) \<lbrace>Nonce NA, Agent A\<rbrace>) \<in> set evs \<longrightarrow> |
|
117 |
Says B A (Crypt(pubEK A) \<lbrace>Nonce NA, Nonce NB, Agent B\<rbrace>) \<in> set evs" |
|
11104 | 118 |
apply (erule ns_public.induct, simp_all) |
119 |
(*Fake, NS1*) |
|
120 |
apply (blast dest: Spy_not_see_NA)+ |
|
121 |
done |
|
122 |
||
123 |
theorem A_trusts_NS2: |
|
13922 | 124 |
"\<lbrakk>Says A B (Crypt(pubEK B) \<lbrace>Nonce NA, Agent A\<rbrace>) \<in> set evs; |
125 |
Says B' A (Crypt(pubEK A) \<lbrace>Nonce NA, Nonce NB, Agent B\<rbrace>) \<in> set evs; |
|
11104 | 126 |
A \<notin> bad; B \<notin> bad; evs \<in> ns_public\<rbrakk> |
13922 | 127 |
\<Longrightarrow> Says B A (Crypt(pubEK A) \<lbrace>Nonce NA, Nonce NB, Agent B\<rbrace>) \<in> set evs" |
11104 | 128 |
by (blast intro: A_trusts_NS2_lemma) |
129 |
||
130 |
||
131 |
(*If the encrypted message appears then it originated with Alice in NS1*) |
|
132 |
lemma B_trusts_NS1 [rule_format]: |
|
133 |
"evs \<in> ns_public |
|
13922 | 134 |
\<Longrightarrow> Crypt (pubEK B) \<lbrace>Nonce NA, Agent A\<rbrace> \<in> parts (spies evs) \<longrightarrow> |
11104 | 135 |
Nonce NA \<notin> analz (spies evs) \<longrightarrow> |
13922 | 136 |
Says A B (Crypt (pubEK B) \<lbrace>Nonce NA, Agent A\<rbrace>) \<in> set evs" |
11104 | 137 |
apply (erule ns_public.induct, simp_all) |
138 |
(*Fake*) |
|
139 |
apply (blast intro!: analz_insertI) |
|
140 |
done |
|
141 |
||
142 |
||
14200
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents:
13956
diff
changeset
|
143 |
subsection{*Authenticity properties obtained from NS2*} |
11104 | 144 |
|
145 |
(*Unicity for NS2: nonce NB identifies nonce NA and agents A, B |
|
146 |
[unicity of B makes Lowe's fix work] |
|
147 |
[proof closely follows that for unique_NA] *) |
|
148 |
||
149 |
lemma unique_NB [dest]: |
|
13922 | 150 |
"\<lbrakk>Crypt(pubEK A) \<lbrace>Nonce NA, Nonce NB, Agent B\<rbrace> \<in> parts(spies evs); |
151 |
Crypt(pubEK A') \<lbrace>Nonce NA', Nonce NB, Agent B'\<rbrace> \<in> parts(spies evs); |
|
11104 | 152 |
Nonce NB \<notin> analz (spies evs); evs \<in> ns_public\<rbrakk> |
153 |
\<Longrightarrow> A=A' \<and> NA=NA' \<and> B=B'" |
|
154 |
apply (erule rev_mp, erule rev_mp, erule rev_mp) |
|
155 |
apply (erule ns_public.induct, simp_all) |
|
156 |
(*Fake, NS2*) |
|
157 |
apply (blast intro: analz_insertI)+ |
|
158 |
done |
|
159 |
||
160 |
||
161 |
(*Secrecy: Spy does not see the nonce sent in msg NS2 if A and B are secure*) |
|
162 |
theorem Spy_not_see_NB [dest]: |
|
13922 | 163 |
"\<lbrakk>Says B A (Crypt (pubEK A) \<lbrace>Nonce NA, Nonce NB, Agent B\<rbrace>) \<in> set evs; |
11104 | 164 |
A \<notin> bad; B \<notin> bad; evs \<in> ns_public\<rbrakk> |
165 |
\<Longrightarrow> Nonce NB \<notin> analz (spies evs)" |
|
166 |
apply (erule rev_mp) |
|
13507 | 167 |
apply (erule ns_public.induct, simp_all, spy_analz) |
11104 | 168 |
apply (blast intro: no_nonce_NS1_NS2)+ |
169 |
done |
|
170 |
||
171 |
||
172 |
(*Authentication for B: if he receives message 3 and has used NB |
|
173 |
in message 2, then A has sent message 3.*) |
|
174 |
lemma B_trusts_NS3_lemma [rule_format]: |
|
175 |
"\<lbrakk>A \<notin> bad; B \<notin> bad; evs \<in> ns_public\<rbrakk> \<Longrightarrow> |
|
13922 | 176 |
Crypt (pubEK B) (Nonce NB) \<in> parts (spies evs) \<longrightarrow> |
177 |
Says B A (Crypt (pubEK A) \<lbrace>Nonce NA, Nonce NB, Agent B\<rbrace>) \<in> set evs \<longrightarrow> |
|
178 |
Says A B (Crypt (pubEK B) (Nonce NB)) \<in> set evs" |
|
11104 | 179 |
by (erule ns_public.induct, auto) |
180 |
||
181 |
theorem B_trusts_NS3: |
|
13922 | 182 |
"\<lbrakk>Says B A (Crypt (pubEK A) \<lbrace>Nonce NA, Nonce NB, Agent B\<rbrace>) \<in> set evs; |
183 |
Says A' B (Crypt (pubEK B) (Nonce NB)) \<in> set evs; |
|
11104 | 184 |
A \<notin> bad; B \<notin> bad; evs \<in> ns_public\<rbrakk> |
13922 | 185 |
\<Longrightarrow> Says A B (Crypt (pubEK B) (Nonce NB)) \<in> set evs" |
11104 | 186 |
by (blast intro: B_trusts_NS3_lemma) |
187 |
||
14200
d8598e24f8fa
Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents:
13956
diff
changeset
|
188 |
subsection{*Overall guarantee for B*} |
11104 | 189 |
|
190 |
(*If NS3 has been sent and the nonce NB agrees with the nonce B joined with |
|
191 |
NA, then A initiated the run using NA.*) |
|
192 |
theorem B_trusts_protocol: |
|
193 |
"\<lbrakk>A \<notin> bad; B \<notin> bad; evs \<in> ns_public\<rbrakk> \<Longrightarrow> |
|
13922 | 194 |
Crypt (pubEK B) (Nonce NB) \<in> parts (spies evs) \<longrightarrow> |
195 |
Says B A (Crypt (pubEK A) \<lbrace>Nonce NA, Nonce NB, Agent B\<rbrace>) \<in> set evs \<longrightarrow> |
|
196 |
Says A B (Crypt (pubEK B) \<lbrace>Nonce NA, Agent A\<rbrace>) \<in> set evs" |
|
11104 | 197 |
by (erule ns_public.induct, auto) |
2318 | 198 |
|
199 |
end |