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