--- a/src/HOL/Auth/Yahalom.thy Sun Oct 23 16:44:17 2016 +0200
+++ b/src/HOL/Auth/Yahalom.thy Mon Oct 24 14:31:05 2016 +0100
@@ -22,32 +22,32 @@
(*The spy MAY say anything he CAN say. We do not expect him to
invent new nonces here, but he can also use NS1. Common to
all similar protocols.*)
- | Fake: "[| evsf \<in> yahalom; X \<in> synth (analz (knows Spy evsf)) |]
- ==> Says Spy B X # evsf \<in> yahalom"
+ | Fake: "\<lbrakk>evsf \<in> yahalom; X \<in> synth (analz (knows Spy evsf))\<rbrakk>
+ \<Longrightarrow> Says Spy B X # evsf \<in> yahalom"
(*A message that has been sent can be received by the
intended recipient.*)
- | Reception: "[| evsr \<in> yahalom; Says A B X \<in> set evsr |]
- ==> Gets B X # evsr \<in> yahalom"
+ | Reception: "\<lbrakk>evsr \<in> yahalom; Says A B X \<in> set evsr\<rbrakk>
+ \<Longrightarrow> Gets B X # evsr \<in> yahalom"
(*Alice initiates a protocol run*)
- | YM1: "[| evs1 \<in> yahalom; Nonce NA \<notin> used evs1 |]
- ==> Says A B \<lbrace>Agent A, Nonce NA\<rbrace> # evs1 \<in> yahalom"
+ | YM1: "\<lbrakk>evs1 \<in> yahalom; Nonce NA \<notin> used evs1\<rbrakk>
+ \<Longrightarrow> Says A B \<lbrace>Agent A, Nonce NA\<rbrace> # evs1 \<in> yahalom"
(*Bob's response to Alice's message.*)
- | YM2: "[| evs2 \<in> yahalom; Nonce NB \<notin> used evs2;
- Gets B \<lbrace>Agent A, Nonce NA\<rbrace> \<in> set evs2 |]
- ==> Says B Server
+ | YM2: "\<lbrakk>evs2 \<in> yahalom; Nonce NB \<notin> used evs2;
+ Gets B \<lbrace>Agent A, Nonce NA\<rbrace> \<in> set evs2\<rbrakk>
+ \<Longrightarrow> Says B Server
\<lbrace>Agent B, Crypt (shrK B) \<lbrace>Agent A, Nonce NA, Nonce NB\<rbrace>\<rbrace>
# evs2 \<in> yahalom"
(*The Server receives Bob's message. He responds by sending a
new session key to Alice, with a packet for forwarding to Bob.*)
- | YM3: "[| evs3 \<in> yahalom; Key KAB \<notin> used evs3; KAB \<in> symKeys;
+ | YM3: "\<lbrakk>evs3 \<in> yahalom; Key KAB \<notin> used evs3; KAB \<in> symKeys;
Gets Server
\<lbrace>Agent B, Crypt (shrK B) \<lbrace>Agent A, Nonce NA, Nonce NB\<rbrace>\<rbrace>
- \<in> set evs3 |]
- ==> Says Server A
+ \<in> set evs3\<rbrakk>
+ \<Longrightarrow> Says Server A
\<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key KAB, Nonce NA, Nonce NB\<rbrace>,
Crypt (shrK B) \<lbrace>Agent A, Key KAB\<rbrace>\<rbrace>
# evs3 \<in> yahalom"
@@ -57,20 +57,20 @@
uses the new session key to send Bob his Nonce. The premise
@{term "A \<noteq> Server"} is needed for \<open>Says_Server_not_range\<close>.
Alice can check that K is symmetric by its length.\<close>
- "[| evs4 \<in> yahalom; A \<noteq> Server; K \<in> symKeys;
+ "\<lbrakk>evs4 \<in> yahalom; A \<noteq> Server; K \<in> symKeys;
Gets A \<lbrace>Crypt(shrK A) \<lbrace>Agent B, Key K, Nonce NA, Nonce NB\<rbrace>, X\<rbrace>
\<in> set evs4;
- Says A B \<lbrace>Agent A, Nonce NA\<rbrace> \<in> set evs4 |]
- ==> Says A B \<lbrace>X, Crypt K (Nonce NB)\<rbrace> # evs4 \<in> yahalom"
+ Says A B \<lbrace>Agent A, Nonce NA\<rbrace> \<in> set evs4\<rbrakk>
+ \<Longrightarrow> Says A B \<lbrace>X, Crypt K (Nonce NB)\<rbrace> # evs4 \<in> yahalom"
(*This message models possible leaks of session keys. The Nonces
identify the protocol run. Quoting Server here ensures they are
correct.*)
- | Oops: "[| evso \<in> yahalom;
+ | Oops: "\<lbrakk>evso \<in> yahalom;
Says Server A \<lbrace>Crypt (shrK A)
\<lbrace>Agent B, Key K, Nonce NA, Nonce NB\<rbrace>,
- X\<rbrace> \<in> set evso |]
- ==> Notes Spy \<lbrace>Nonce NA, Nonce NB, Key K\<rbrace> # evso \<in> yahalom"
+ X\<rbrace> \<in> set evso\<rbrakk>
+ \<Longrightarrow> Notes Spy \<lbrace>Nonce NA, Nonce NB, Key K\<rbrace> # evso \<in> yahalom"
definition KeyWithNonce :: "[key, nat, event list] => bool" where
@@ -86,8 +86,8 @@
declare analz_into_parts [dest]
text\<open>A "possibility property": there are traces that reach the end\<close>
-lemma "[| A \<noteq> Server; K \<in> symKeys; Key K \<notin> used [] |]
- ==> \<exists>X NB. \<exists>evs \<in> yahalom.
+lemma "\<lbrakk>A \<noteq> Server; K \<in> symKeys; Key K \<notin> used []\<rbrakk>
+ \<Longrightarrow> \<exists>X NB. \<exists>evs \<in> yahalom.
Says A B \<lbrace>X, Crypt K (Nonce NB)\<rbrace> \<in> set evs"
apply (intro exI bexI)
apply (rule_tac [2] yahalom.Nil
@@ -102,12 +102,12 @@
subsection\<open>Regularity Lemmas for Yahalom\<close>
lemma Gets_imp_Says:
- "[| Gets B X \<in> set evs; evs \<in> yahalom |] ==> \<exists>A. Says A B X \<in> set evs"
+ "\<lbrakk>Gets B X \<in> set evs; evs \<in> yahalom\<rbrakk> \<Longrightarrow> \<exists>A. Says A B X \<in> set evs"
by (erule rev_mp, erule yahalom.induct, auto)
text\<open>Must be proved separately for each protocol\<close>
lemma Gets_imp_knows_Spy:
- "[| Gets B X \<in> set evs; evs \<in> yahalom |] ==> X \<in> knows Spy evs"
+ "\<lbrakk>Gets B X \<in> set evs; evs \<in> yahalom\<rbrakk> \<Longrightarrow> X \<in> knows Spy evs"
by (blast dest!: Gets_imp_Says Says_imp_knows_Spy)
lemmas Gets_imp_analz_Spy = Gets_imp_knows_Spy [THEN analz.Inj]
@@ -116,8 +116,8 @@
text\<open>Lets us treat YM4 using a similar argument as for the Fake case.\<close>
lemma YM4_analz_knows_Spy:
- "[| Gets A \<lbrace>Crypt (shrK A) Y, X\<rbrace> \<in> set evs; evs \<in> yahalom |]
- ==> X \<in> analz (knows Spy evs)"
+ "\<lbrakk>Gets A \<lbrace>Crypt (shrK A) Y, X\<rbrace> \<in> set evs; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> X \<in> analz (knows Spy evs)"
by blast
lemmas YM4_parts_knows_Spy =
@@ -126,7 +126,7 @@
text\<open>For Oops\<close>
lemma YM4_Key_parts_knows_Spy:
"Says Server A \<lbrace>Crypt (shrK A) \<lbrace>B,K,NA,NB\<rbrace>, X\<rbrace> \<in> set evs
- ==> K \<in> parts (knows Spy evs)"
+ \<Longrightarrow> K \<in> parts (knows Spy evs)"
by (metis parts.Body parts.Fst parts.Snd Says_imp_knows_Spy parts.Inj)
text\<open>Theorems of the form @{term "X \<notin> parts (knows Spy evs)"} imply
@@ -134,23 +134,23 @@
text\<open>Spy never sees a good agent's shared key!\<close>
lemma Spy_see_shrK [simp]:
- "evs \<in> yahalom ==> (Key (shrK A) \<in> parts (knows Spy evs)) = (A \<in> bad)"
+ "evs \<in> yahalom \<Longrightarrow> (Key (shrK A) \<in> parts (knows Spy evs)) = (A \<in> bad)"
by (erule yahalom.induct, force,
drule_tac [6] YM4_parts_knows_Spy, simp_all, blast+)
lemma Spy_analz_shrK [simp]:
- "evs \<in> yahalom ==> (Key (shrK A) \<in> analz (knows Spy evs)) = (A \<in> bad)"
+ "evs \<in> yahalom \<Longrightarrow> (Key (shrK A) \<in> analz (knows Spy evs)) = (A \<in> bad)"
by auto
lemma Spy_see_shrK_D [dest!]:
- "[|Key (shrK A) \<in> parts (knows Spy evs); evs \<in> yahalom|] ==> A \<in> bad"
+ "\<lbrakk>Key (shrK A) \<in> parts (knows Spy evs); evs \<in> yahalom\<rbrakk> \<Longrightarrow> A \<in> bad"
by (blast dest: Spy_see_shrK)
text\<open>Nobody can have used non-existent keys!
Needed to apply \<open>analz_insert_Key\<close>\<close>
lemma new_keys_not_used [simp]:
- "[|Key K \<notin> used evs; K \<in> symKeys; evs \<in> yahalom|]
- ==> K \<notin> keysFor (parts (spies evs))"
+ "\<lbrakk>Key K \<notin> used evs; K \<in> symKeys; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> K \<notin> keysFor (parts (spies evs))"
apply (erule rev_mp)
apply (erule yahalom.induct, force,
frule_tac [6] YM4_parts_knows_Spy, simp_all)
@@ -162,17 +162,17 @@
text\<open>Earlier, all protocol proofs declared this theorem.
But only a few proofs need it, e.g. Yahalom and Kerberos IV.\<close>
lemma new_keys_not_analzd:
- "[|K \<in> symKeys; evs \<in> yahalom; Key K \<notin> used evs|]
- ==> K \<notin> keysFor (analz (knows Spy evs))"
+ "\<lbrakk>K \<in> symKeys; evs \<in> yahalom; Key K \<notin> used evs\<rbrakk>
+ \<Longrightarrow> K \<notin> keysFor (analz (knows Spy evs))"
by (blast dest: new_keys_not_used intro: keysFor_mono [THEN subsetD])
text\<open>Describes the form of K when the Server sends this message. Useful for
Oops as well as main secrecy property.\<close>
lemma Says_Server_not_range [simp]:
- "[| Says Server A \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, na, nb\<rbrace>, X\<rbrace>
- \<in> set evs; evs \<in> yahalom |]
- ==> K \<notin> range shrK"
+ "\<lbrakk>Says Server A \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, na, nb\<rbrace>, X\<rbrace>
+ \<in> set evs; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> K \<notin> range shrK"
by (erule rev_mp, erule yahalom.induct, simp_all)
@@ -181,7 +181,7 @@
(****
The following is to prove theorems of the form
- Key K \<in> analz (insert (Key KAB) (knows Spy evs)) ==>
+ Key K \<in> analz (insert (Key KAB) (knows Spy evs)) \<Longrightarrow>
Key K \<in> analz (knows Spy evs)
A more general formula must be proved inductively.
@@ -190,7 +190,7 @@
text\<open>Session keys are not used to encrypt other session keys\<close>
lemma analz_image_freshK [rule_format]:
- "evs \<in> yahalom ==>
+ "evs \<in> yahalom \<Longrightarrow>
\<forall>K KK. KK <= - (range shrK) -->
(Key K \<in> analz (Key`KK Un (knows Spy evs))) =
(K \<in> KK | Key K \<in> analz (knows Spy evs))"
@@ -201,7 +201,7 @@
done
lemma analz_insert_freshK:
- "[| evs \<in> yahalom; KAB \<notin> range shrK |] ==>
+ "\<lbrakk>evs \<in> yahalom; KAB \<notin> range shrK\<rbrakk> \<Longrightarrow>
(Key K \<in> analz (insert (Key KAB) (knows Spy evs))) =
(K = KAB | Key K \<in> analz (knows Spy evs))"
by (simp only: analz_image_freshK analz_image_freshK_simps)
@@ -209,12 +209,12 @@
text\<open>The Key K uniquely identifies the Server's message.\<close>
lemma unique_session_keys:
- "[| Says Server A
+ "\<lbrakk>Says Server A
\<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, na, nb\<rbrace>, X\<rbrace> \<in> set evs;
Says Server A'
\<lbrace>Crypt (shrK A') \<lbrace>Agent B', Key K, na', nb'\<rbrace>, X'\<rbrace> \<in> set evs;
- evs \<in> yahalom |]
- ==> A=A' & B=B' & na=na' & nb=nb'"
+ evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> A=A' & B=B' & na=na' & nb=nb'"
apply (erule rev_mp, erule rev_mp)
apply (erule yahalom.induct, simp_all)
txt\<open>YM3, by freshness, and YM4\<close>
@@ -224,8 +224,8 @@
text\<open>Crucial secrecy property: Spy does not see the keys sent in msg YM3\<close>
lemma secrecy_lemma:
- "[| A \<notin> bad; B \<notin> bad; evs \<in> yahalom |]
- ==> Says Server A
+ "\<lbrakk>A \<notin> bad; B \<notin> bad; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> Says Server A
\<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, na, nb\<rbrace>,
Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>\<rbrace>
\<in> set evs -->
@@ -233,19 +233,21 @@
Key K \<notin> analz (knows Spy evs)"
apply (erule yahalom.induct, force,
drule_tac [6] YM4_analz_knows_Spy)
-apply (simp_all add: pushes analz_insert_eq analz_insert_freshK, spy_analz) \<comment>\<open>Fake\<close>
-apply (blast dest: unique_session_keys)+ \<comment>\<open>YM3, Oops\<close>
+apply (simp_all add: pushes analz_insert_eq analz_insert_freshK)
+ subgoal --\<open>Fake\<close> by spy_analz
+ subgoal --\<open>YM3\<close> by blast
+ subgoal --\<open>Oops\<close> by (blast dest: unique_session_keys)
done
text\<open>Final version\<close>
lemma Spy_not_see_encrypted_key:
- "[| Says Server A
+ "\<lbrakk>Says Server A
\<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, na, nb\<rbrace>,
Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>\<rbrace>
\<in> set evs;
Notes Spy \<lbrace>na, nb, Key K\<rbrace> \<notin> set evs;
- A \<notin> bad; B \<notin> bad; evs \<in> yahalom |]
- ==> Key K \<notin> analz (knows Spy evs)"
+ A \<notin> bad; B \<notin> bad; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> Key K \<notin> analz (knows Spy evs)"
by (blast dest: secrecy_lemma)
@@ -253,9 +255,9 @@
text\<open>If the encrypted message appears then it originated with the Server\<close>
lemma A_trusts_YM3:
- "[| Crypt (shrK A) \<lbrace>Agent B, Key K, na, nb\<rbrace> \<in> parts (knows Spy evs);
- A \<notin> bad; evs \<in> yahalom |]
- ==> Says Server A
+ "\<lbrakk>Crypt (shrK A) \<lbrace>Agent B, Key K, na, nb\<rbrace> \<in> parts (knows Spy evs);
+ A \<notin> bad; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> Says Server A
\<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, na, nb\<rbrace>,
Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>\<rbrace>
\<in> set evs"
@@ -269,10 +271,10 @@
text\<open>The obvious combination of \<open>A_trusts_YM3\<close> with
\<open>Spy_not_see_encrypted_key\<close>\<close>
lemma A_gets_good_key:
- "[| Crypt (shrK A) \<lbrace>Agent B, Key K, na, nb\<rbrace> \<in> parts (knows Spy evs);
+ "\<lbrakk>Crypt (shrK A) \<lbrace>Agent B, Key K, na, nb\<rbrace> \<in> parts (knows Spy evs);
Notes Spy \<lbrace>na, nb, Key K\<rbrace> \<notin> set evs;
- A \<notin> bad; B \<notin> bad; evs \<in> yahalom |]
- ==> Key K \<notin> analz (knows Spy evs)"
+ A \<notin> bad; B \<notin> bad; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> Key K \<notin> analz (knows Spy evs)"
by (metis A_trusts_YM3 secrecy_lemma)
@@ -281,9 +283,9 @@
text\<open>B knows, by the first part of A's message, that the Server distributed
the key for A and B. But this part says nothing about nonces.\<close>
lemma B_trusts_YM4_shrK:
- "[| Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace> \<in> parts (knows Spy evs);
- B \<notin> bad; evs \<in> yahalom |]
- ==> \<exists>NA NB. Says Server A
+ "\<lbrakk>Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace> \<in> parts (knows Spy evs);
+ B \<notin> bad; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> \<exists>NA NB. Says Server A
\<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K,
Nonce NA, Nonce NB\<rbrace>,
Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>\<rbrace>
@@ -302,19 +304,18 @@
induction formula.\<close>
lemma B_trusts_YM4_newK [rule_format]:
- "[|Crypt K (Nonce NB) \<in> parts (knows Spy evs);
- Nonce NB \<notin> analz (knows Spy evs); evs \<in> yahalom|]
- ==> \<exists>A B NA. Says Server A
+ "\<lbrakk>Crypt K (Nonce NB) \<in> parts (knows Spy evs);
+ Nonce NB \<notin> analz (knows Spy evs); evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> \<exists>A B NA. Says Server A
\<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, Nonce NA, Nonce NB\<rbrace>,
Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>\<rbrace>
\<in> set evs"
apply (erule rev_mp, erule rev_mp)
apply (erule yahalom.induct, force,
frule_tac [6] YM4_parts_knows_Spy)
-apply (analz_mono_contra, simp_all)
-txt\<open>Fake, YM3\<close>
-apply blast
-apply blast
+ apply (analz_mono_contra, simp_all)
+ subgoal --\<open>Fake\<close> by blast
+ subgoal --\<open>YM3\<close> by blast
txt\<open>YM4. A is uncompromised because NB is secure
A's certificate guarantees the existence of the Server message\<close>
apply (blast dest!: Gets_imp_Says Crypt_Spy_analz_bad
@@ -330,7 +331,7 @@
lemma KeyWithNonceI:
"Says Server A
\<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, na, Nonce NB\<rbrace>, X\<rbrace>
- \<in> set evs ==> KeyWithNonce K NB evs"
+ \<in> set evs \<Longrightarrow> KeyWithNonce K NB evs"
by (unfold KeyWithNonce_def, blast)
lemma KeyWithNonce_Says [simp]:
@@ -352,16 +353,16 @@
text\<open>A fresh key cannot be associated with any nonce
(with respect to a given trace).\<close>
lemma fresh_not_KeyWithNonce:
- "Key K \<notin> used evs ==> ~ KeyWithNonce K NB evs"
+ "Key K \<notin> used evs \<Longrightarrow> ~ KeyWithNonce K NB evs"
by (unfold KeyWithNonce_def, blast)
text\<open>The Server message associates K with NB' and therefore not with any
other nonce NB.\<close>
lemma Says_Server_KeyWithNonce:
- "[| Says Server A \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, na, Nonce NB'\<rbrace>, X\<rbrace>
+ "\<lbrakk>Says Server A \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, na, Nonce NB'\<rbrace>, X\<rbrace>
\<in> set evs;
- NB \<noteq> NB'; evs \<in> yahalom |]
- ==> ~ KeyWithNonce K NB evs"
+ NB \<noteq> NB'; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> ~ KeyWithNonce K NB evs"
by (unfold KeyWithNonce_def, blast dest: unique_session_keys)
@@ -373,12 +374,12 @@
text\<open>As with \<open>analz_image_freshK\<close>, we take some pains to express the
property as a logical equivalence so that the simplifier can apply it.\<close>
lemma Nonce_secrecy_lemma:
- "P --> (X \<in> analz (G Un H)) --> (X \<in> analz H) ==>
+ "P --> (X \<in> analz (G Un H)) --> (X \<in> analz H) \<Longrightarrow>
P --> (X \<in> analz (G Un H)) = (X \<in> analz H)"
by (blast intro: analz_mono [THEN subsetD])
lemma Nonce_secrecy:
- "evs \<in> yahalom ==>
+ "evs \<in> yahalom \<Longrightarrow>
(\<forall>KK. KK <= - (range shrK) -->
(\<forall>K \<in> KK. K \<in> symKeys --> ~ KeyWithNonce K NB evs) -->
(Nonce NB \<in> analz (Key`KK Un (knows Spy evs))) =
@@ -396,19 +397,12 @@
@{term Says_Server_KeyWithNonce}, we get @{prop "~ KeyWithNonce K NB
evs"}; then simplification can apply the induction hypothesis with
@{term "KK = {K}"}.\<close>
-txt\<open>Fake\<close>
-apply spy_analz
-txt\<open>YM2\<close>
-apply blast
-txt\<open>YM3\<close>
-apply blast
-txt\<open>YM4\<close>
-apply (erule_tac V = "\<forall>KK. P KK" for P in thin_rl, clarify)
-txt\<open>If @{prop "A \<in> bad"} then @{term NBa} is known, therefore
- @{prop "NBa \<noteq> NB"}. Previous two steps make the next step
- faster.\<close>
-apply (metis A_trusts_YM3 Gets_imp_analz_Spy Gets_imp_knows_Spy KeyWithNonce_def
- Spy_analz_shrK analz.Fst analz.Snd analz_shrK_Decrypt parts.Fst parts.Inj)
+ subgoal --\<open>Fake\<close> by spy_analz
+ subgoal --\<open>YM2\<close> by blast
+ subgoal --\<open>YM3\<close> by blast
+ subgoal --\<open>YM4: If @{prop "A \<in> bad"} then @{term NBa} is known, therefore @{prop "NBa \<noteq> NB"}.\<close>
+ by (metis A_trusts_YM3 Gets_imp_analz_Spy Gets_imp_knows_Spy KeyWithNonce_def
+ Spy_analz_shrK analz.Fst analz.Snd analz_shrK_Decrypt parts.Fst parts.Inj)
done
@@ -416,11 +410,11 @@
it was distributed with that key. The more general form above is required
for the induction to carry through.\<close>
lemma single_Nonce_secrecy:
- "[| Says Server A
+ "\<lbrakk>Says Server A
\<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key KAB, na, Nonce NB'\<rbrace>, X\<rbrace>
\<in> set evs;
- NB \<noteq> NB'; KAB \<notin> range shrK; evs \<in> yahalom |]
- ==> (Nonce NB \<in> analz (insert (Key KAB) (knows Spy evs))) =
+ NB \<noteq> NB'; KAB \<notin> range shrK; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> (Nonce NB \<in> analz (insert (Key KAB) (knows Spy evs))) =
(Nonce NB \<in> analz (knows Spy evs))"
by (simp_all del: image_insert image_Un imp_disjL
add: analz_image_freshK_simps split_ifs
@@ -430,10 +424,10 @@
subsubsection\<open>The Nonce NB uniquely identifies B's message.\<close>
lemma unique_NB:
- "[| Crypt (shrK B) \<lbrace>Agent A, Nonce NA, nb\<rbrace> \<in> parts (knows Spy evs);
+ "\<lbrakk>Crypt (shrK B) \<lbrace>Agent A, Nonce NA, nb\<rbrace> \<in> parts (knows Spy evs);
Crypt (shrK B') \<lbrace>Agent A', Nonce NA', nb\<rbrace> \<in> parts (knows Spy evs);
- evs \<in> yahalom; B \<notin> bad; B' \<notin> bad |]
- ==> NA' = NA & A' = A & B' = B"
+ evs \<in> yahalom; B \<notin> bad; B' \<notin> bad\<rbrakk>
+ \<Longrightarrow> NA' = NA & A' = A & B' = B"
apply (erule rev_mp, erule rev_mp)
apply (erule yahalom.induct, force,
frule_tac [6] YM4_parts_knows_Spy, simp_all)
@@ -445,12 +439,12 @@
text\<open>Variant useful for proving secrecy of NB. Because nb is assumed to be
secret, we no longer must assume B, B' not bad.\<close>
lemma Says_unique_NB:
- "[| Says C S \<lbrace>X, Crypt (shrK B) \<lbrace>Agent A, Nonce NA, nb\<rbrace>\<rbrace>
+ "\<lbrakk>Says C S \<lbrace>X, Crypt (shrK B) \<lbrace>Agent A, Nonce NA, nb\<rbrace>\<rbrace>
\<in> set evs;
Gets S' \<lbrace>X', Crypt (shrK B') \<lbrace>Agent A', Nonce NA', nb\<rbrace>\<rbrace>
\<in> set evs;
- nb \<notin> analz (knows Spy evs); evs \<in> yahalom |]
- ==> NA' = NA & A' = A & B' = B"
+ nb \<notin> analz (knows Spy evs); evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> NA' = NA & A' = A & B' = B"
by (blast dest!: Gets_imp_Says Crypt_Spy_analz_bad
dest: Says_imp_spies unique_NB parts.Inj analz.Inj)
@@ -458,9 +452,9 @@
subsubsection\<open>A nonce value is never used both as NA and as NB\<close>
lemma no_nonce_YM1_YM2:
- "[|Crypt (shrK B') \<lbrace>Agent A', Nonce NB, nb'\<rbrace> \<in> parts(knows Spy evs);
- Nonce NB \<notin> analz (knows Spy evs); evs \<in> yahalom|]
- ==> Crypt (shrK B) \<lbrace>Agent A, na, Nonce NB\<rbrace> \<notin> parts(knows Spy evs)"
+ "\<lbrakk>Crypt (shrK B') \<lbrace>Agent A', Nonce NB, nb'\<rbrace> \<in> parts(knows Spy evs);
+ Nonce NB \<notin> analz (knows Spy evs); evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> Crypt (shrK B) \<lbrace>Agent A, na, Nonce NB\<rbrace> \<notin> parts(knows Spy evs)"
apply (erule rev_mp, erule rev_mp)
apply (erule yahalom.induct, force,
frule_tac [6] YM4_parts_knows_Spy)
@@ -471,64 +465,60 @@
text\<open>The Server sends YM3 only in response to YM2.\<close>
lemma Says_Server_imp_YM2:
- "[| Says Server A \<lbrace>Crypt (shrK A) \<lbrace>Agent B, k, na, nb\<rbrace>, X\<rbrace> \<in> set evs;
- evs \<in> yahalom |]
- ==> Gets Server \<lbrace>Agent B, Crypt (shrK B) \<lbrace>Agent A, na, nb\<rbrace>\<rbrace>
+ "\<lbrakk>Says Server A \<lbrace>Crypt (shrK A) \<lbrace>Agent B, k, na, nb\<rbrace>, X\<rbrace> \<in> set evs;
+ evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> Gets Server \<lbrace>Agent B, Crypt (shrK B) \<lbrace>Agent A, na, nb\<rbrace>\<rbrace>
\<in> set evs"
by (erule rev_mp, erule yahalom.induct, auto)
text\<open>A vital theorem for B, that nonce NB remains secure from the Spy.\<close>
-lemma Spy_not_see_NB :
- "[| Says B Server
+theorem Spy_not_see_NB :
+ "\<lbrakk>Says B Server
\<lbrace>Agent B, Crypt (shrK B) \<lbrace>Agent A, Nonce NA, Nonce NB\<rbrace>\<rbrace>
\<in> set evs;
(\<forall>k. Notes Spy \<lbrace>Nonce NA, Nonce NB, k\<rbrace> \<notin> set evs);
- A \<notin> bad; B \<notin> bad; evs \<in> yahalom |]
- ==> Nonce NB \<notin> analz (knows Spy evs)"
+ A \<notin> bad; B \<notin> bad; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> Nonce NB \<notin> analz (knows Spy evs)"
apply (erule rev_mp, erule rev_mp)
apply (erule yahalom.induct, force,
frule_tac [6] YM4_analz_knows_Spy)
apply (simp_all add: split_ifs pushes new_keys_not_analzd analz_insert_eq
analz_insert_freshK)
-txt\<open>Fake\<close>
-apply spy_analz
-txt\<open>YM1: NB=NA is impossible anyway, but NA is secret because it is fresh!\<close>
-apply blast
-txt\<open>YM2\<close>
-apply blast
-txt\<open>Prove YM3 by showing that no NB can also be an NA\<close>
-apply (blast dest!: no_nonce_YM1_YM2 dest: Gets_imp_Says Says_unique_NB)
-txt\<open>LEVEL 7: YM4 and Oops remain\<close>
-apply (clarify, simp add: all_conj_distrib)
-txt\<open>YM4: key K is visible to Spy, contradicting session key secrecy theorem\<close>
-txt\<open>Case analysis on Aa:bad; PROOF FAILED problems
- use \<open>Says_unique_NB\<close> to identify message components: @{term "Aa=A"}, @{term "Ba=B"}\<close>
-apply (blast dest!: Says_unique_NB analz_shrK_Decrypt
- parts.Inj [THEN parts.Fst, THEN A_trusts_YM3]
- dest: Gets_imp_Says Says_imp_spies Says_Server_imp_YM2
- Spy_not_see_encrypted_key)
-txt\<open>Oops case: if the nonce is betrayed now, show that the Oops event is
- covered by the quantified Oops assumption.\<close>
-apply (clarify, simp add: all_conj_distrib)
-apply (frule Says_Server_imp_YM2, assumption)
-apply (metis Gets_imp_Says Says_Server_not_range Says_unique_NB no_nonce_YM1_YM2 parts.Snd single_Nonce_secrecy spies_partsEs(1))
+ subgoal --\<open>Fake\<close> by spy_analz
+ subgoal --\<open>YM1: NB=NA is impossible anyway, but NA is secret because it is fresh!\<close> by blast
+ subgoal --\<open>YM2\<close> by blast
+ subgoal --\<open>YM3: because no NB can also be an NA\<close>
+ by (blast dest!: no_nonce_YM1_YM2 dest: Gets_imp_Says Says_unique_NB)
+ subgoal --\<open>YM4: key K is visible to Spy, contradicting session key secrecy theorem\<close>
+ --\<open>Case analysis on whether Aa is bad;
+ use \<open>Says_unique_NB\<close> to identify message components: @{term "Aa=A"}, @{term "Ba=B"}\<close>
+ apply clarify
+ apply (blast dest!: Says_unique_NB analz_shrK_Decrypt
+ parts.Inj [THEN parts.Fst, THEN A_trusts_YM3]
+ dest: Gets_imp_Says Says_imp_spies Says_Server_imp_YM2
+ Spy_not_see_encrypted_key)
+ done
+ subgoal --\<open>Oops case: if the nonce is betrayed now, show that the Oops event is
+ covered by the quantified Oops assumption.\<close>
+ apply clarsimp
+ apply (metis Says_Server_imp_YM2 Gets_imp_Says Says_Server_not_range Says_unique_NB no_nonce_YM1_YM2 parts.Snd single_Nonce_secrecy spies_partsEs(1))
+ done
done
-
text\<open>B's session key guarantee from YM4. The two certificates contribute to a
single conclusion about the Server's message. Note that the "Notes Spy"
assumption must quantify over \<open>\<forall>\<close> POSSIBLE keys instead of our particular K.
If this run is broken and the spy substitutes a certificate containing an
old key, B has no means of telling.\<close>
lemma B_trusts_YM4:
- "[| Gets B \<lbrace>Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>,
+ "\<lbrakk>Gets B \<lbrace>Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>,
Crypt K (Nonce NB)\<rbrace> \<in> set evs;
Says B Server
\<lbrace>Agent B, Crypt (shrK B) \<lbrace>Agent A, Nonce NA, Nonce NB\<rbrace>\<rbrace>
\<in> set evs;
\<forall>k. Notes Spy \<lbrace>Nonce NA, Nonce NB, k\<rbrace> \<notin> set evs;
- A \<notin> bad; B \<notin> bad; evs \<in> yahalom |]
- ==> Says Server A
+ A \<notin> bad; B \<notin> bad; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> Says Server A
\<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K,
Nonce NA, Nonce NB\<rbrace>,
Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>\<rbrace>
@@ -541,14 +531,14 @@
text\<open>The obvious combination of \<open>B_trusts_YM4\<close> with
\<open>Spy_not_see_encrypted_key\<close>\<close>
lemma B_gets_good_key:
- "[| Gets B \<lbrace>Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>,
+ "\<lbrakk>Gets B \<lbrace>Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>,
Crypt K (Nonce NB)\<rbrace> \<in> set evs;
Says B Server
\<lbrace>Agent B, Crypt (shrK B) \<lbrace>Agent A, Nonce NA, Nonce NB\<rbrace>\<rbrace>
\<in> set evs;
\<forall>k. Notes Spy \<lbrace>Nonce NA, Nonce NB, k\<rbrace> \<notin> set evs;
- A \<notin> bad; B \<notin> bad; evs \<in> yahalom |]
- ==> Key K \<notin> analz (knows Spy evs)"
+ A \<notin> bad; B \<notin> bad; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> Key K \<notin> analz (knows Spy evs)"
by (metis B_trusts_YM4 Spy_not_see_encrypted_key)
@@ -556,9 +546,9 @@
text\<open>The encryption in message YM2 tells us it cannot be faked.\<close>
lemma B_Said_YM2 [rule_format]:
- "[|Crypt (shrK B) \<lbrace>Agent A, Nonce NA, nb\<rbrace> \<in> parts (knows Spy evs);
- evs \<in> yahalom|]
- ==> B \<notin> bad -->
+ "\<lbrakk>Crypt (shrK B) \<lbrace>Agent A, Nonce NA, nb\<rbrace> \<in> parts (knows Spy evs);
+ evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> B \<notin> bad -->
Says B Server \<lbrace>Agent B, Crypt (shrK B) \<lbrace>Agent A, Nonce NA, nb\<rbrace>\<rbrace>
\<in> set evs"
apply (erule rev_mp, erule yahalom.induct, force,
@@ -569,9 +559,9 @@
text\<open>If the server sends YM3 then B sent YM2\<close>
lemma YM3_auth_B_to_A_lemma:
- "[|Says Server A \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, Nonce NA, nb\<rbrace>, X\<rbrace>
- \<in> set evs; evs \<in> yahalom|]
- ==> B \<notin> bad -->
+ "\<lbrakk>Says Server A \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, Nonce NA, nb\<rbrace>, X\<rbrace>
+ \<in> set evs; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> B \<notin> bad -->
Says B Server \<lbrace>Agent B, Crypt (shrK B) \<lbrace>Agent A, Nonce NA, nb\<rbrace>\<rbrace>
\<in> set evs"
apply (erule rev_mp, erule yahalom.induct, simp_all)
@@ -580,11 +570,11 @@
done
text\<open>If A receives YM3 then B has used nonce NA (and therefore is alive)\<close>
-lemma YM3_auth_B_to_A:
- "[| Gets A \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, Nonce NA, nb\<rbrace>, X\<rbrace>
+theorem YM3_auth_B_to_A:
+ "\<lbrakk>Gets A \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, Nonce NA, nb\<rbrace>, X\<rbrace>
\<in> set evs;
- A \<notin> bad; B \<notin> bad; evs \<in> yahalom |]
- ==> Says B Server \<lbrace>Agent B, Crypt (shrK B) \<lbrace>Agent A, Nonce NA, nb\<rbrace>\<rbrace>
+ A \<notin> bad; B \<notin> bad; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> Says B Server \<lbrace>Agent B, Crypt (shrK B) \<lbrace>Agent A, Nonce NA, nb\<rbrace>\<rbrace>
\<in> set evs"
by (metis A_trusts_YM3 Gets_imp_analz_Spy YM3_auth_B_to_A_lemma analz.Fst
not_parts_not_analz)
@@ -596,9 +586,9 @@
text\<open>Assuming the session key is secure, if both certificates are present then
A has said NB. We can't be sure about the rest of A's message, but only
NB matters for freshness.\<close>
-lemma A_Said_YM3_lemma [rule_format]:
+theorem A_Said_YM3_lemma [rule_format]:
"evs \<in> yahalom
- ==> Key K \<notin> analz (knows Spy evs) -->
+ \<Longrightarrow> Key K \<notin> analz (knows Spy evs) -->
Crypt K (Nonce NB) \<in> parts (knows Spy evs) -->
Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace> \<in> parts (knows Spy evs) -->
B \<notin> bad -->
@@ -606,31 +596,27 @@
apply (erule yahalom.induct, force,
frule_tac [6] YM4_parts_knows_Spy)
apply (analz_mono_contra, simp_all)
-txt\<open>Fake\<close>
-apply blast
-txt\<open>YM3: by \<open>new_keys_not_used\<close>, the message
- @{term "Crypt K (Nonce NB)"} could not exist\<close>
-apply (force dest!: Crypt_imp_keysFor)
-txt\<open>YM4: was @{term "Crypt K (Nonce NB)"} the very last message?
- If not, use the induction hypothesis\<close>
-apply (simp add: ex_disj_distrib)
-txt\<open>yes: apply unicity of session keys\<close>
-apply (blast dest!: Gets_imp_Says A_trusts_YM3 B_trusts_YM4_shrK
- Crypt_Spy_analz_bad
+ subgoal --\<open>Fake\<close> by blast
+ subgoal --\<open>YM3 because the message @{term "Crypt K (Nonce NB)"} could not exist\<close>
+ by (force dest!: Crypt_imp_keysFor)
+ subgoal --\<open>YM4: was @{term "Crypt K (Nonce NB)"} the very last message? If not, use the induction hypothesis,
+ otherwise by unicity of session keys\<close>
+ by (blast dest!: Gets_imp_Says A_trusts_YM3 B_trusts_YM4_shrK Crypt_Spy_analz_bad
dest: Says_imp_knows_Spy [THEN parts.Inj] unique_session_keys)
done
text\<open>If B receives YM4 then A has used nonce NB (and therefore is alive).
Moreover, A associates K with NB (thus is talking about the same run).
Other premises guarantee secrecy of K.\<close>
-lemma YM4_imp_A_Said_YM3 [rule_format]:
- "[| Gets B \<lbrace>Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>,
+theorem YM4_imp_A_Said_YM3 [rule_format]:
+ "\<lbrakk>Gets B \<lbrace>Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>,
Crypt K (Nonce NB)\<rbrace> \<in> set evs;
Says B Server
\<lbrace>Agent B, Crypt (shrK B) \<lbrace>Agent A, Nonce NA, Nonce NB\<rbrace>\<rbrace>
\<in> set evs;
(\<forall>NA k. Notes Spy \<lbrace>Nonce NA, Nonce NB, k\<rbrace> \<notin> set evs);
- A \<notin> bad; B \<notin> bad; evs \<in> yahalom |]
- ==> \<exists>X. Says A B \<lbrace>X, Crypt K (Nonce NB)\<rbrace> \<in> set evs"
+ A \<notin> bad; B \<notin> bad; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> \<exists>X. Says A B \<lbrace>X, Crypt K (Nonce NB)\<rbrace> \<in> set evs"
by (metis A_Said_YM3_lemma B_gets_good_key Gets_imp_analz_Spy YM4_parts_knows_Spy analz.Fst not_parts_not_analz)
+
end
--- a/src/HOL/Auth/Yahalom2.thy Sun Oct 23 16:44:17 2016 +0200
+++ b/src/HOL/Auth/Yahalom2.thy Mon Oct 24 14:31:05 2016 +0100
@@ -26,33 +26,33 @@
(*The spy MAY say anything he CAN say. We do not expect him to
invent new nonces here, but he can also use NS1. Common to
all similar protocols.*)
- | Fake: "[| evsf \<in> yahalom; X \<in> synth (analz (knows Spy evsf)) |]
- ==> Says Spy B X # evsf \<in> yahalom"
+ | Fake: "\<lbrakk>evsf \<in> yahalom; X \<in> synth (analz (knows Spy evsf))\<rbrakk>
+ \<Longrightarrow> Says Spy B X # evsf \<in> yahalom"
(*A message that has been sent can be received by the
intended recipient.*)
- | Reception: "[| evsr \<in> yahalom; Says A B X \<in> set evsr |]
- ==> Gets B X # evsr \<in> yahalom"
+ | Reception: "\<lbrakk>evsr \<in> yahalom; Says A B X \<in> set evsr\<rbrakk>
+ \<Longrightarrow> Gets B X # evsr \<in> yahalom"
(*Alice initiates a protocol run*)
- | YM1: "[| evs1 \<in> yahalom; Nonce NA \<notin> used evs1 |]
- ==> Says A B \<lbrace>Agent A, Nonce NA\<rbrace> # evs1 \<in> yahalom"
+ | YM1: "\<lbrakk>evs1 \<in> yahalom; Nonce NA \<notin> used evs1\<rbrakk>
+ \<Longrightarrow> Says A B \<lbrace>Agent A, Nonce NA\<rbrace> # evs1 \<in> yahalom"
(*Bob's response to Alice's message.*)
- | YM2: "[| evs2 \<in> yahalom; Nonce NB \<notin> used evs2;
- Gets B \<lbrace>Agent A, Nonce NA\<rbrace> \<in> set evs2 |]
- ==> Says B Server
+ | YM2: "\<lbrakk>evs2 \<in> yahalom; Nonce NB \<notin> used evs2;
+ Gets B \<lbrace>Agent A, Nonce NA\<rbrace> \<in> set evs2\<rbrakk>
+ \<Longrightarrow> Says B Server
\<lbrace>Agent B, Nonce NB, Crypt (shrK B) \<lbrace>Agent A, Nonce NA\<rbrace>\<rbrace>
# evs2 \<in> yahalom"
(*The Server receives Bob's message. He responds by sending a
new session key to Alice, with a certificate for forwarding to Bob.
Both agents are quoted in the 2nd certificate to prevent attacks!*)
- | YM3: "[| evs3 \<in> yahalom; Key KAB \<notin> used evs3;
+ | YM3: "\<lbrakk>evs3 \<in> yahalom; Key KAB \<notin> used evs3;
Gets Server \<lbrace>Agent B, Nonce NB,
Crypt (shrK B) \<lbrace>Agent A, Nonce NA\<rbrace>\<rbrace>
- \<in> set evs3 |]
- ==> Says Server A
+ \<in> set evs3\<rbrakk>
+ \<Longrightarrow> Says Server A
\<lbrace>Nonce NB,
Crypt (shrK A) \<lbrace>Agent B, Key KAB, Nonce NA\<rbrace>,
Crypt (shrK B) \<lbrace>Agent A, Agent B, Key KAB, Nonce NB\<rbrace>\<rbrace>
@@ -60,20 +60,20 @@
(*Alice receives the Server's (?) message, checks her Nonce, and
uses the new session key to send Bob his Nonce.*)
- | YM4: "[| evs4 \<in> yahalom;
+ | YM4: "\<lbrakk>evs4 \<in> yahalom;
Gets A \<lbrace>Nonce NB, Crypt (shrK A) \<lbrace>Agent B, Key K, Nonce NA\<rbrace>,
X\<rbrace> \<in> set evs4;
- Says A B \<lbrace>Agent A, Nonce NA\<rbrace> \<in> set evs4 |]
- ==> Says A B \<lbrace>X, Crypt K (Nonce NB)\<rbrace> # evs4 \<in> yahalom"
+ Says A B \<lbrace>Agent A, Nonce NA\<rbrace> \<in> set evs4\<rbrakk>
+ \<Longrightarrow> Says A B \<lbrace>X, Crypt K (Nonce NB)\<rbrace> # evs4 \<in> yahalom"
(*This message models possible leaks of session keys. The nonces
identify the protocol run. Quoting Server here ensures they are
correct. *)
- | Oops: "[| evso \<in> yahalom;
+ | Oops: "\<lbrakk>evso \<in> yahalom;
Says Server A \<lbrace>Nonce NB,
Crypt (shrK A) \<lbrace>Agent B, Key K, Nonce NA\<rbrace>,
- X\<rbrace> \<in> set evso |]
- ==> Notes Spy \<lbrace>Nonce NA, Nonce NB, Key K\<rbrace> # evso \<in> yahalom"
+ X\<rbrace> \<in> set evso\<rbrakk>
+ \<Longrightarrow> Notes Spy \<lbrace>Nonce NA, Nonce NB, Key K\<rbrace> # evso \<in> yahalom"
declare Says_imp_knows_Spy [THEN analz.Inj, dest]
@@ -83,7 +83,7 @@
text\<open>A "possibility property": there are traces that reach the end\<close>
lemma "Key K \<notin> used []
- ==> \<exists>X NB. \<exists>evs \<in> yahalom.
+ \<Longrightarrow> \<exists>X NB. \<exists>evs \<in> yahalom.
Says A B \<lbrace>X, Crypt K (Nonce NB)\<rbrace> \<in> set evs"
apply (intro exI bexI)
apply (rule_tac [2] yahalom.Nil
@@ -95,12 +95,12 @@
done
lemma Gets_imp_Says:
- "[| Gets B X \<in> set evs; evs \<in> yahalom |] ==> \<exists>A. Says A B X \<in> set evs"
+ "\<lbrakk>Gets B X \<in> set evs; evs \<in> yahalom\<rbrakk> \<Longrightarrow> \<exists>A. Says A B X \<in> set evs"
by (erule rev_mp, erule yahalom.induct, auto)
text\<open>Must be proved separately for each protocol\<close>
lemma Gets_imp_knows_Spy:
- "[| Gets B X \<in> set evs; evs \<in> yahalom |] ==> X \<in> knows Spy evs"
+ "\<lbrakk>Gets B X \<in> set evs; evs \<in> yahalom\<rbrakk> \<Longrightarrow> X \<in> knows Spy evs"
by (blast dest!: Gets_imp_Says Says_imp_knows_Spy)
declare Gets_imp_knows_Spy [THEN analz.Inj, dest]
@@ -111,8 +111,8 @@
text\<open>Result for reasoning about the encrypted portion of messages.
Lets us treat YM4 using a similar argument as for the Fake case.\<close>
lemma YM4_analz_knows_Spy:
- "[| Gets A \<lbrace>NB, Crypt (shrK A) Y, X\<rbrace> \<in> set evs; evs \<in> yahalom |]
- ==> X \<in> analz (knows Spy evs)"
+ "\<lbrakk>Gets A \<lbrace>NB, Crypt (shrK A) Y, X\<rbrace> \<in> set evs; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> X \<in> analz (knows Spy evs)"
by blast
lemmas YM4_parts_knows_Spy =
@@ -124,49 +124,45 @@
text\<open>Spy never sees a good agent's shared key!\<close>
lemma Spy_see_shrK [simp]:
- "evs \<in> yahalom ==> (Key (shrK A) \<in> parts (knows Spy evs)) = (A \<in> bad)"
+ "evs \<in> yahalom \<Longrightarrow> (Key (shrK A) \<in> parts (knows Spy evs)) = (A \<in> bad)"
by (erule yahalom.induct, force,
drule_tac [6] YM4_parts_knows_Spy, simp_all, blast+)
lemma Spy_analz_shrK [simp]:
- "evs \<in> yahalom ==> (Key (shrK A) \<in> analz (knows Spy evs)) = (A \<in> bad)"
+ "evs \<in> yahalom \<Longrightarrow> (Key (shrK A) \<in> analz (knows Spy evs)) = (A \<in> bad)"
by auto
lemma Spy_see_shrK_D [dest!]:
- "[|Key (shrK A) \<in> parts (knows Spy evs); evs \<in> yahalom|] ==> A \<in> bad"
+ "\<lbrakk>Key (shrK A) \<in> parts (knows Spy evs); evs \<in> yahalom\<rbrakk> \<Longrightarrow> A \<in> bad"
by (blast dest: Spy_see_shrK)
text\<open>Nobody can have used non-existent keys!
Needed to apply \<open>analz_insert_Key\<close>\<close>
lemma new_keys_not_used [simp]:
- "[|Key K \<notin> used evs; K \<in> symKeys; evs \<in> yahalom|]
- ==> K \<notin> keysFor (parts (spies evs))"
+ "\<lbrakk>Key K \<notin> used evs; K \<in> symKeys; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> K \<notin> keysFor (parts (spies evs))"
apply (erule rev_mp)
apply (erule yahalom.induct, force,
frule_tac [6] YM4_parts_knows_Spy, simp_all)
-txt\<open>Fake\<close>
-apply (force dest!: keysFor_parts_insert)
-txt\<open>YM3\<close>
-apply blast
-txt\<open>YM4\<close>
-apply auto
-apply (blast dest!: Gets_imp_knows_Spy [THEN parts.Inj])
+subgoal --\<open>Fake\<close> by (force dest!: keysFor_parts_insert)
+subgoal --\<open>YM3 \<close>by blast
+subgoal --\<open>YM4\<close> by (fastforce dest!: Gets_imp_knows_Spy [THEN parts.Inj])
done
text\<open>Describes the form of K when the Server sends this message. Useful for
Oops as well as main secrecy property.\<close>
lemma Says_Server_message_form:
- "[| Says Server A \<lbrace>nb', Crypt (shrK A) \<lbrace>Agent B, Key K, na\<rbrace>, X\<rbrace>
- \<in> set evs; evs \<in> yahalom |]
- ==> K \<notin> range shrK"
+ "\<lbrakk>Says Server A \<lbrace>nb', Crypt (shrK A) \<lbrace>Agent B, Key K, na\<rbrace>, X\<rbrace>
+ \<in> set evs; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> K \<notin> range shrK"
by (erule rev_mp, erule yahalom.induct, simp_all)
(****
The following is to prove theorems of the form
- Key K \<in> analz (insert (Key KAB) (knows Spy evs)) ==>
+ Key K \<in> analz (insert (Key KAB) (knows Spy evs)) \<Longrightarrow>
Key K \<in> analz (knows Spy evs)
A more general formula must be proved inductively.
@@ -175,7 +171,7 @@
(** Session keys are not used to encrypt other session keys **)
lemma analz_image_freshK [rule_format]:
- "evs \<in> yahalom ==>
+ "evs \<in> yahalom \<Longrightarrow>
\<forall>K KK. KK <= - (range shrK) -->
(Key K \<in> analz (Key`KK Un (knows Spy evs))) =
(K \<in> KK | Key K \<in> analz (knows Spy evs))"
@@ -185,7 +181,7 @@
done
lemma analz_insert_freshK:
- "[| evs \<in> yahalom; KAB \<notin> range shrK |] ==>
+ "\<lbrakk>evs \<in> yahalom; KAB \<notin> range shrK\<rbrakk> \<Longrightarrow>
(Key K \<in> analz (insert (Key KAB) (knows Spy evs))) =
(K = KAB | Key K \<in> analz (knows Spy evs))"
by (simp only: analz_image_freshK analz_image_freshK_simps)
@@ -193,12 +189,12 @@
text\<open>The Key K uniquely identifies the Server's message\<close>
lemma unique_session_keys:
- "[| Says Server A
+ "\<lbrakk>Says Server A
\<lbrace>nb, Crypt (shrK A) \<lbrace>Agent B, Key K, na\<rbrace>, X\<rbrace> \<in> set evs;
Says Server A'
\<lbrace>nb', Crypt (shrK A') \<lbrace>Agent B', Key K, na'\<rbrace>, X'\<rbrace> \<in> set evs;
- evs \<in> yahalom |]
- ==> A=A' & B=B' & na=na' & nb=nb'"
+ evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> A=A' & B=B' & na=na' & nb=nb'"
apply (erule rev_mp, erule rev_mp)
apply (erule yahalom.induct, simp_all)
txt\<open>YM3, by freshness\<close>
@@ -209,8 +205,8 @@
subsection\<open>Crucial Secrecy Property: Spy Does Not See Key @{term KAB}\<close>
lemma secrecy_lemma:
- "[| A \<notin> bad; B \<notin> bad; evs \<in> yahalom |]
- ==> Says Server A
+ "\<lbrakk>A \<notin> bad; B \<notin> bad; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> Says Server A
\<lbrace>nb, Crypt (shrK A) \<lbrace>Agent B, Key K, na\<rbrace>,
Crypt (shrK B) \<lbrace>Agent A, Agent B, Key K, nb\<rbrace>\<rbrace>
\<in> set evs -->
@@ -225,13 +221,13 @@
text\<open>Final version\<close>
lemma Spy_not_see_encrypted_key:
- "[| Says Server A
+ "\<lbrakk>Says Server A
\<lbrace>nb, Crypt (shrK A) \<lbrace>Agent B, Key K, na\<rbrace>,
Crypt (shrK B) \<lbrace>Agent A, Agent B, Key K, nb\<rbrace>\<rbrace>
\<in> set evs;
Notes Spy \<lbrace>na, nb, Key K\<rbrace> \<notin> set evs;
- A \<notin> bad; B \<notin> bad; evs \<in> yahalom |]
- ==> Key K \<notin> analz (knows Spy evs)"
+ A \<notin> bad; B \<notin> bad; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> Key K \<notin> analz (knows Spy evs)"
by (blast dest: secrecy_lemma Says_Server_message_form)
@@ -244,13 +240,13 @@
other than Fake are trivial, while Fake requires
@{term "Key K \<notin> analz (knows Spy evs)"}.\<close>
lemma Spy_not_know_encrypted_key:
- "[| Says Server A
+ "\<lbrakk>Says Server A
\<lbrace>nb, Crypt (shrK A) \<lbrace>Agent B, Key K, na\<rbrace>,
Crypt (shrK B) \<lbrace>Agent A, Agent B, Key K, nb\<rbrace>\<rbrace>
\<in> set evs;
Notes Spy \<lbrace>na, nb, Key K\<rbrace> \<notin> set evs;
- A \<notin> bad; B \<notin> bad; evs \<in> yahalom |]
- ==> Key K \<notin> knows Spy evs"
+ A \<notin> bad; B \<notin> bad; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> Key K \<notin> knows Spy evs"
by (blast dest: Spy_not_see_encrypted_key)
@@ -259,9 +255,9 @@
text\<open>If the encrypted message appears then it originated with the Server.
May now apply \<open>Spy_not_see_encrypted_key\<close>, subject to its conditions.\<close>
lemma A_trusts_YM3:
- "[| Crypt (shrK A) \<lbrace>Agent B, Key K, na\<rbrace> \<in> parts (knows Spy evs);
- A \<notin> bad; evs \<in> yahalom |]
- ==> \<exists>nb. Says Server A
+ "\<lbrakk>Crypt (shrK A) \<lbrace>Agent B, Key K, na\<rbrace> \<in> parts (knows Spy evs);
+ A \<notin> bad; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> \<exists>nb. Says Server A
\<lbrace>nb, Crypt (shrK A) \<lbrace>Agent B, Key K, na\<rbrace>,
Crypt (shrK B) \<lbrace>Agent A, Agent B, Key K, nb\<rbrace>\<rbrace>
\<in> set evs"
@@ -275,10 +271,10 @@
text\<open>The obvious combination of \<open>A_trusts_YM3\<close> with
\<open>Spy_not_see_encrypted_key\<close>\<close>
theorem A_gets_good_key:
- "[| Crypt (shrK A) \<lbrace>Agent B, Key K, na\<rbrace> \<in> parts (knows Spy evs);
+ "\<lbrakk>Crypt (shrK A) \<lbrace>Agent B, Key K, na\<rbrace> \<in> parts (knows Spy evs);
\<forall>nb. Notes Spy \<lbrace>na, nb, Key K\<rbrace> \<notin> set evs;
- A \<notin> bad; B \<notin> bad; evs \<in> yahalom |]
- ==> Key K \<notin> analz (knows Spy evs)"
+ A \<notin> bad; B \<notin> bad; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> Key K \<notin> analz (knows Spy evs)"
by (blast dest!: A_trusts_YM3 Spy_not_see_encrypted_key)
@@ -287,10 +283,10 @@
text\<open>B knows, by the first part of A's message, that the Server distributed
the key for A and B, and has associated it with NB.\<close>
lemma B_trusts_YM4_shrK:
- "[| Crypt (shrK B) \<lbrace>Agent A, Agent B, Key K, Nonce NB\<rbrace>
+ "\<lbrakk>Crypt (shrK B) \<lbrace>Agent A, Agent B, Key K, Nonce NB\<rbrace>
\<in> parts (knows Spy evs);
- B \<notin> bad; evs \<in> yahalom |]
- ==> \<exists>NA. Says Server A
+ B \<notin> bad; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> \<exists>NA. Says Server A
\<lbrace>Nonce NB,
Crypt (shrK A) \<lbrace>Agent B, Key K, Nonce NA\<rbrace>,
Crypt (shrK B) \<lbrace>Agent A, Agent B, Key K, Nonce NB\<rbrace>\<rbrace>
@@ -309,10 +305,10 @@
text\<open>What can B deduce from receipt of YM4? Stronger and simpler than Yahalom
because we do not have to show that NB is secret.\<close>
lemma B_trusts_YM4:
- "[| Gets B \<lbrace>Crypt (shrK B) \<lbrace>Agent A, Agent B, Key K, Nonce NB\<rbrace>, X\<rbrace>
+ "\<lbrakk>Gets B \<lbrace>Crypt (shrK B) \<lbrace>Agent A, Agent B, Key K, Nonce NB\<rbrace>, X\<rbrace>
\<in> set evs;
- A \<notin> bad; B \<notin> bad; evs \<in> yahalom |]
- ==> \<exists>NA. Says Server A
+ A \<notin> bad; B \<notin> bad; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> \<exists>NA. Says Server A
\<lbrace>Nonce NB,
Crypt (shrK A) \<lbrace>Agent B, Key K, Nonce NA\<rbrace>,
Crypt (shrK B) \<lbrace>Agent A, Agent B, Key K, Nonce NB\<rbrace>\<rbrace>
@@ -323,11 +319,11 @@
text\<open>The obvious combination of \<open>B_trusts_YM4\<close> with
\<open>Spy_not_see_encrypted_key\<close>\<close>
theorem B_gets_good_key:
- "[| Gets B \<lbrace>Crypt (shrK B) \<lbrace>Agent A, Agent B, Key K, Nonce NB\<rbrace>, X\<rbrace>
+ "\<lbrakk>Gets B \<lbrace>Crypt (shrK B) \<lbrace>Agent A, Agent B, Key K, Nonce NB\<rbrace>, X\<rbrace>
\<in> set evs;
\<forall>na. Notes Spy \<lbrace>na, Nonce NB, Key K\<rbrace> \<notin> set evs;
- A \<notin> bad; B \<notin> bad; evs \<in> yahalom |]
- ==> Key K \<notin> analz (knows Spy evs)"
+ A \<notin> bad; B \<notin> bad; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> Key K \<notin> analz (knows Spy evs)"
by (blast dest!: B_trusts_YM4 Spy_not_see_encrypted_key)
@@ -335,9 +331,9 @@
text\<open>The encryption in message YM2 tells us it cannot be faked.\<close>
lemma B_Said_YM2:
- "[| Crypt (shrK B) \<lbrace>Agent A, Nonce NA\<rbrace> \<in> parts (knows Spy evs);
- B \<notin> bad; evs \<in> yahalom |]
- ==> \<exists>NB. Says B Server \<lbrace>Agent B, Nonce NB,
+ "\<lbrakk>Crypt (shrK B) \<lbrace>Agent A, Nonce NA\<rbrace> \<in> parts (knows Spy evs);
+ B \<notin> bad; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> \<exists>NB. Says B Server \<lbrace>Agent B, Nonce NB,
Crypt (shrK B) \<lbrace>Agent A, Nonce NA\<rbrace>\<rbrace>
\<in> set evs"
apply (erule rev_mp)
@@ -350,10 +346,10 @@
text\<open>If the server sends YM3 then B sent YM2, perhaps with a different NB\<close>
lemma YM3_auth_B_to_A_lemma:
- "[| Says Server A \<lbrace>nb, Crypt (shrK A) \<lbrace>Agent B, Key K, Nonce NA\<rbrace>, X\<rbrace>
+ "\<lbrakk>Says Server A \<lbrace>nb, Crypt (shrK A) \<lbrace>Agent B, Key K, Nonce NA\<rbrace>, X\<rbrace>
\<in> set evs;
- B \<notin> bad; evs \<in> yahalom |]
- ==> \<exists>nb'. Says B Server \<lbrace>Agent B, nb',
+ B \<notin> bad; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> \<exists>nb'. Says B Server \<lbrace>Agent B, nb',
Crypt (shrK B) \<lbrace>Agent A, Nonce NA\<rbrace>\<rbrace>
\<in> set evs"
apply (erule rev_mp)
@@ -364,10 +360,10 @@
text\<open>If A receives YM3 then B has used nonce NA (and therefore is alive)\<close>
theorem YM3_auth_B_to_A:
- "[| Gets A \<lbrace>nb, Crypt (shrK A) \<lbrace>Agent B, Key K, Nonce NA\<rbrace>, X\<rbrace>
+ "\<lbrakk>Gets A \<lbrace>nb, Crypt (shrK A) \<lbrace>Agent B, Key K, Nonce NA\<rbrace>, X\<rbrace>
\<in> set evs;
- A \<notin> bad; B \<notin> bad; evs \<in> yahalom |]
- ==> \<exists>nb'. Says B Server
+ A \<notin> bad; B \<notin> bad; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> \<exists>nb'. Says B Server
\<lbrace>Agent B, nb', Crypt (shrK B) \<lbrace>Agent A, Nonce NA\<rbrace>\<rbrace>
\<in> set evs"
by (blast dest!: A_trusts_YM3 YM3_auth_B_to_A_lemma)
@@ -385,16 +381,16 @@
text\<open>This lemma allows a use of \<open>unique_session_keys\<close> in the next proof,
which otherwise is extremely slow.\<close>
lemma secure_unique_session_keys:
- "[| Crypt (shrK A) \<lbrace>Agent B, Key K, na\<rbrace> \<in> analz (spies evs);
+ "\<lbrakk>Crypt (shrK A) \<lbrace>Agent B, Key K, na\<rbrace> \<in> analz (spies evs);
Crypt (shrK A') \<lbrace>Agent B', Key K, na'\<rbrace> \<in> analz (spies evs);
- Key K \<notin> analz (knows Spy evs); evs \<in> yahalom |]
- ==> A=A' & B=B'"
+ Key K \<notin> analz (knows Spy evs); evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> A=A' & B=B'"
by (blast dest!: A_trusts_YM3 dest: unique_session_keys Crypt_Spy_analz_bad)
lemma Auth_A_to_B_lemma [rule_format]:
"evs \<in> yahalom
- ==> Key K \<notin> analz (knows Spy evs) -->
+ \<Longrightarrow> Key K \<notin> analz (knows Spy evs) -->
K \<in> symKeys -->
Crypt K (Nonce NB) \<in> parts (knows Spy evs) -->
Crypt (shrK B) \<lbrace>Agent A, Agent B, Key K, Nonce NB\<rbrace>
@@ -404,14 +400,12 @@
apply (erule yahalom.induct, force,
frule_tac [6] YM4_parts_knows_Spy)
apply (analz_mono_contra, simp_all)
-txt\<open>Fake\<close>
-apply blast
-txt\<open>YM3: by \<open>new_keys_not_used\<close>, the message
- @{term "Crypt K (Nonce NB)"} could not exist\<close>
-apply (force dest!: Crypt_imp_keysFor)
-txt\<open>YM4: was @{term "Crypt K (Nonce NB)"} the very last message? If so,
- apply unicity of session keys; if not, use the induction hypothesis\<close>
-apply (blast dest!: B_trusts_YM4_shrK dest: secure_unique_session_keys)
+ subgoal --\<open>Fake\<close> by blast
+ subgoal --\<open>YM3 because the message @{term "Crypt K (Nonce NB)"} could not exist\<close>
+ by (force dest!: Crypt_imp_keysFor)
+ subgoal --\<open>YM4: was @{term "Crypt K (Nonce NB)"} the very last message? If not, use the induction hypothesis,
+ otherwise by unicity of session keys\<close>
+ by (blast dest!: B_trusts_YM4_shrK dest: secure_unique_session_keys)
done
@@ -419,11 +413,11 @@
Moreover, A associates K with NB (thus is talking about the same run).
Other premises guarantee secrecy of K.\<close>
theorem YM4_imp_A_Said_YM3 [rule_format]:
- "[| Gets B \<lbrace>Crypt (shrK B) \<lbrace>Agent A, Agent B, Key K, Nonce NB\<rbrace>,
+ "\<lbrakk>Gets B \<lbrace>Crypt (shrK B) \<lbrace>Agent A, Agent B, Key K, Nonce NB\<rbrace>,
Crypt K (Nonce NB)\<rbrace> \<in> set evs;
(\<forall>NA. Notes Spy \<lbrace>Nonce NA, Nonce NB, Key K\<rbrace> \<notin> set evs);
- K \<in> symKeys; A \<notin> bad; B \<notin> bad; evs \<in> yahalom |]
- ==> \<exists>X. Says A B \<lbrace>X, Crypt K (Nonce NB)\<rbrace> \<in> set evs"
+ K \<in> symKeys; A \<notin> bad; B \<notin> bad; evs \<in> yahalom\<rbrakk>
+ \<Longrightarrow> \<exists>X. Says A B \<lbrace>X, Crypt K (Nonce NB)\<rbrace> \<in> set evs"
by (blast intro: Auth_A_to_B_lemma
dest: Spy_not_see_encrypted_key B_trusts_YM4_shrK)