src/HOL/Auth/Yahalom2.thy
author paulson <lp15@cam.ac.uk>
Mon, 24 Oct 2016 14:31:05 +0100
changeset 64364 464420ba7f74
parent 61956 38b73f7940af
child 67226 ec32cdaab97b
permissions -rw-r--r--
"subgoal" examples
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37936
1e4c5015a72e updated some headers;
wenzelm
parents: 32960
diff changeset
     1
(*  Title:      HOL/Auth/Yahalom2.thy
2111
81c8d46edfa3 New version of Yahalom, as recommended on p 259 of BAN paper
paulson
parents:
diff changeset
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
81c8d46edfa3 New version of Yahalom, as recommended on p 259 of BAN paper
paulson
parents:
diff changeset
     3
    Copyright   1996  University of Cambridge
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
     4
*)
2111
81c8d46edfa3 New version of Yahalom, as recommended on p 259 of BAN paper
paulson
parents:
diff changeset
     5
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
     6
section\<open>The Yahalom Protocol, Variant 2\<close>
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
     7
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 14207
diff changeset
     8
theory Yahalom2 imports Public begin
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
     9
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
    10
text\<open>
2111
81c8d46edfa3 New version of Yahalom, as recommended on p 259 of BAN paper
paulson
parents:
diff changeset
    11
This version trades encryption of NB for additional explicitness in YM3.
3432
04412cfe6861 Strengthened and streamlined the Yahalom proofs
paulson
parents: 2516
diff changeset
    12
Also in YM3, care is taken to make the two certificates distinct.
2111
81c8d46edfa3 New version of Yahalom, as recommended on p 259 of BAN paper
paulson
parents:
diff changeset
    13
81c8d46edfa3 New version of Yahalom, as recommended on p 259 of BAN paper
paulson
parents:
diff changeset
    14
From page 259 of
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
    15
  Burrows, Abadi and Needham (1989).  A Logic of Authentication.
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
    16
  Proc. Royal Soc. 426
2111
81c8d46edfa3 New version of Yahalom, as recommended on p 259 of BAN paper
paulson
parents:
diff changeset
    17
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
    18
This theory has the prototypical example of a secrecy relation, KeyCryptNonce.
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
    19
\<close>
2111
81c8d46edfa3 New version of Yahalom, as recommended on p 259 of BAN paper
paulson
parents:
diff changeset
    20
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    21
inductive_set yahalom :: "event list set"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    22
  where
2111
81c8d46edfa3 New version of Yahalom, as recommended on p 259 of BAN paper
paulson
parents:
diff changeset
    23
         (*Initial trace is empty*)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    24
   Nil:  "[] \<in> yahalom"
2111
81c8d46edfa3 New version of Yahalom, as recommended on p 259 of BAN paper
paulson
parents:
diff changeset
    25
81c8d46edfa3 New version of Yahalom, as recommended on p 259 of BAN paper
paulson
parents:
diff changeset
    26
         (*The spy MAY say anything he CAN say.  We do not expect him to
81c8d46edfa3 New version of Yahalom, as recommended on p 259 of BAN paper
paulson
parents:
diff changeset
    27
           invent new nonces here, but he can also use NS1.  Common to
81c8d46edfa3 New version of Yahalom, as recommended on p 259 of BAN paper
paulson
parents:
diff changeset
    28
           all similar protocols.*)
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
    29
 | Fake: "\<lbrakk>evsf \<in> yahalom;  X \<in> synth (analz (knows Spy evsf))\<rbrakk>
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
    30
          \<Longrightarrow> Says Spy B X  # evsf \<in> yahalom"
2111
81c8d46edfa3 New version of Yahalom, as recommended on p 259 of BAN paper
paulson
parents:
diff changeset
    31
6335
7e4bffaa2a3e updating both Yahalom protocols to the Gets model
paulson
parents: 5434
diff changeset
    32
         (*A message that has been sent can be received by the
7e4bffaa2a3e updating both Yahalom protocols to the Gets model
paulson
parents: 5434
diff changeset
    33
           intended recipient.*)
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
    34
 | Reception: "\<lbrakk>evsr \<in> yahalom;  Says A B X \<in> set evsr\<rbrakk>
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
    35
               \<Longrightarrow> Gets B X # evsr \<in> yahalom"
6335
7e4bffaa2a3e updating both Yahalom protocols to the Gets model
paulson
parents: 5434
diff changeset
    36
2111
81c8d46edfa3 New version of Yahalom, as recommended on p 259 of BAN paper
paulson
parents:
diff changeset
    37
         (*Alice initiates a protocol run*)
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
    38
 | YM1:  "\<lbrakk>evs1 \<in> yahalom;  Nonce NA \<notin> used evs1\<rbrakk>
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
    39
          \<Longrightarrow> Says A B \<lbrace>Agent A, Nonce NA\<rbrace> # evs1 \<in> yahalom"
2111
81c8d46edfa3 New version of Yahalom, as recommended on p 259 of BAN paper
paulson
parents:
diff changeset
    40
6335
7e4bffaa2a3e updating both Yahalom protocols to the Gets model
paulson
parents: 5434
diff changeset
    41
         (*Bob's response to Alice's message.*)
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
    42
 | YM2:  "\<lbrakk>evs2 \<in> yahalom;  Nonce NB \<notin> used evs2;
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
    43
             Gets B \<lbrace>Agent A, Nonce NA\<rbrace> \<in> set evs2\<rbrakk>
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
    44
          \<Longrightarrow> Says B Server
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
    45
                  \<lbrace>Agent B, Nonce NB, Crypt (shrK B) \<lbrace>Agent A, Nonce NA\<rbrace>\<rbrace>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    46
                # evs2 \<in> yahalom"
2111
81c8d46edfa3 New version of Yahalom, as recommended on p 259 of BAN paper
paulson
parents:
diff changeset
    47
81c8d46edfa3 New version of Yahalom, as recommended on p 259 of BAN paper
paulson
parents:
diff changeset
    48
         (*The Server receives Bob's message.  He responds by sending a
3659
eddedfe2f3f8 Renamed "evs" to "evs1", "evs2", etc. in protocol inductive definition
paulson
parents: 3519
diff changeset
    49
           new session key to Alice, with a certificate for forwarding to Bob.
5066
30271d90644f Changed format of Bob's certificate from Nb,K,A to A,B,K,Nb.
paulson
parents: 4537
diff changeset
    50
           Both agents are quoted in the 2nd certificate to prevent attacks!*)
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
    51
 | YM3:  "\<lbrakk>evs3 \<in> yahalom;  Key KAB \<notin> used evs3;
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
    52
             Gets Server \<lbrace>Agent B, Nonce NB,
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
    53
                           Crypt (shrK B) \<lbrace>Agent A, Nonce NA\<rbrace>\<rbrace>
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
    54
               \<in> set evs3\<rbrakk>
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
    55
          \<Longrightarrow> Says Server A
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
    56
               \<lbrace>Nonce NB,
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
    57
                 Crypt (shrK A) \<lbrace>Agent B, Key KAB, Nonce NA\<rbrace>,
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
    58
                 Crypt (shrK B) \<lbrace>Agent A, Agent B, Key KAB, Nonce NB\<rbrace>\<rbrace>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    59
                 # evs3 \<in> yahalom"
2111
81c8d46edfa3 New version of Yahalom, as recommended on p 259 of BAN paper
paulson
parents:
diff changeset
    60
81c8d46edfa3 New version of Yahalom, as recommended on p 259 of BAN paper
paulson
parents:
diff changeset
    61
         (*Alice receives the Server's (?) message, checks her Nonce, and
81c8d46edfa3 New version of Yahalom, as recommended on p 259 of BAN paper
paulson
parents:
diff changeset
    62
           uses the new session key to send Bob his Nonce.*)
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
    63
 | YM4:  "\<lbrakk>evs4 \<in> yahalom;
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
    64
             Gets A \<lbrace>Nonce NB, Crypt (shrK A) \<lbrace>Agent B, Key K, Nonce NA\<rbrace>,
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
    65
                      X\<rbrace>  \<in> set evs4;
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
    66
             Says A B \<lbrace>Agent A, Nonce NA\<rbrace> \<in> set evs4\<rbrakk>
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
    67
          \<Longrightarrow> Says A B \<lbrace>X, Crypt K (Nonce NB)\<rbrace> # evs4 \<in> yahalom"
2111
81c8d46edfa3 New version of Yahalom, as recommended on p 259 of BAN paper
paulson
parents:
diff changeset
    68
2155
dc85854810eb New version with simpler disambiguation in YM3,
paulson
parents: 2111
diff changeset
    69
         (*This message models possible leaks of session keys.  The nonces
dc85854810eb New version with simpler disambiguation in YM3,
paulson
parents: 2111
diff changeset
    70
           identify the protocol run.  Quoting Server here ensures they are
dc85854810eb New version with simpler disambiguation in YM3,
paulson
parents: 2111
diff changeset
    71
           correct. *)
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
    72
 | Oops: "\<lbrakk>evso \<in> yahalom;
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
    73
             Says Server A \<lbrace>Nonce NB,
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
    74
                             Crypt (shrK A) \<lbrace>Agent B, Key K, Nonce NA\<rbrace>,
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
    75
                             X\<rbrace>  \<in> set evso\<rbrakk>
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
    76
          \<Longrightarrow> Notes Spy \<lbrace>Nonce NA, Nonce NB, Key K\<rbrace> # evso \<in> yahalom"
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    77
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    78
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    79
declare Says_imp_knows_Spy [THEN analz.Inj, dest]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    80
declare parts.Body  [dest]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    81
declare Fake_parts_insert_in_Un  [dest]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    82
declare analz_into_parts [dest]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    83
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
    84
text\<open>A "possibility property": there are traces that reach the end\<close>
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 13956
diff changeset
    85
lemma "Key K \<notin> used []
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
    86
       \<Longrightarrow> \<exists>X NB. \<exists>evs \<in> yahalom.
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
    87
             Says A B \<lbrace>X, Crypt K (Nonce NB)\<rbrace> \<in> set evs"
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    88
apply (intro exI bexI)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    89
apply (rule_tac [2] yahalom.Nil
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    90
                    [THEN yahalom.YM1, THEN yahalom.Reception,
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    91
                     THEN yahalom.YM2, THEN yahalom.Reception,
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    92
                     THEN yahalom.YM3, THEN yahalom.Reception,
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 13956
diff changeset
    93
                     THEN yahalom.YM4])
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
    94
apply (possibility, simp add: used_Cons)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    95
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    96
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    97
lemma Gets_imp_Says:
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
    98
     "\<lbrakk>Gets B X \<in> set evs; evs \<in> yahalom\<rbrakk> \<Longrightarrow> \<exists>A. Says A B X \<in> set evs"
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    99
by (erule rev_mp, erule yahalom.induct, auto)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   100
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   101
text\<open>Must be proved separately for each protocol\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   102
lemma Gets_imp_knows_Spy:
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   103
     "\<lbrakk>Gets B X \<in> set evs; evs \<in> yahalom\<rbrakk>  \<Longrightarrow> X \<in> knows Spy evs"
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   104
by (blast dest!: Gets_imp_Says Says_imp_knows_Spy)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   105
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   106
declare Gets_imp_knows_Spy [THEN analz.Inj, dest]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   107
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   108
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   109
subsection\<open>Inductive Proofs\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   110
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   111
text\<open>Result for reasoning about the encrypted portion of messages.
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   112
Lets us treat YM4 using a similar argument as for the Fake case.\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   113
lemma YM4_analz_knows_Spy:
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   114
     "\<lbrakk>Gets A \<lbrace>NB, Crypt (shrK A) Y, X\<rbrace> \<in> set evs;  evs \<in> yahalom\<rbrakk>
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   115
      \<Longrightarrow> X \<in> analz (knows Spy evs)"
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   116
by blast
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   117
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   118
lemmas YM4_parts_knows_Spy =
45605
a89b4bc311a5 eliminated obsolete "standard";
wenzelm
parents: 37936
diff changeset
   119
       YM4_analz_knows_Spy [THEN analz_into_parts]
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   120
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   121
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   122
(** Theorems of the form X \<notin> parts (knows Spy evs) imply that NOBODY
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   123
    sends messages containing X! **)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   124
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   125
text\<open>Spy never sees a good agent's shared key!\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   126
lemma Spy_see_shrK [simp]:
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   127
     "evs \<in> yahalom \<Longrightarrow> (Key (shrK A) \<in> parts (knows Spy evs)) = (A \<in> bad)"
13907
2bc462b99e70 tidying
paulson
parents: 13507
diff changeset
   128
by (erule yahalom.induct, force,
2bc462b99e70 tidying
paulson
parents: 13507
diff changeset
   129
    drule_tac [6] YM4_parts_knows_Spy, simp_all, blast+)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   130
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   131
lemma Spy_analz_shrK [simp]:
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   132
     "evs \<in> yahalom \<Longrightarrow> (Key (shrK A) \<in> analz (knows Spy evs)) = (A \<in> bad)"
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   133
by auto
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   134
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   135
lemma Spy_see_shrK_D [dest!]:
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   136
     "\<lbrakk>Key (shrK A) \<in> parts (knows Spy evs);  evs \<in> yahalom\<rbrakk> \<Longrightarrow> A \<in> bad"
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   137
by (blast dest: Spy_see_shrK)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   138
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   139
text\<open>Nobody can have used non-existent keys!  
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   140
    Needed to apply \<open>analz_insert_Key\<close>\<close>
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   141
lemma new_keys_not_used [simp]:
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   142
    "\<lbrakk>Key K \<notin> used evs; K \<in> symKeys; evs \<in> yahalom\<rbrakk>
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   143
     \<Longrightarrow> K \<notin> keysFor (parts (spies evs))"
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   144
apply (erule rev_mp)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   145
apply (erule yahalom.induct, force,
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   146
       frule_tac [6] YM4_parts_knows_Spy, simp_all)
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   147
subgoal --\<open>Fake\<close> by (force dest!: keysFor_parts_insert)
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   148
subgoal --\<open>YM3 \<close>by blast
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   149
subgoal --\<open>YM4\<close> by (fastforce dest!: Gets_imp_knows_Spy [THEN parts.Inj])
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   150
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   151
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   152
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   153
text\<open>Describes the form of K when the Server sends this message.  Useful for
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   154
  Oops as well as main secrecy property.\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   155
lemma Says_Server_message_form:
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   156
     "\<lbrakk>Says Server A \<lbrace>nb', Crypt (shrK A) \<lbrace>Agent B, Key K, na\<rbrace>, X\<rbrace>
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   157
          \<in> set evs;  evs \<in> yahalom\<rbrakk>
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   158
      \<Longrightarrow> K \<notin> range shrK"
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   159
by (erule rev_mp, erule yahalom.induct, simp_all)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   160
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   161
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   162
(****
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   163
 The following is to prove theorems of the form
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   164
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   165
          Key K \<in> analz (insert (Key KAB) (knows Spy evs)) \<Longrightarrow>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   166
          Key K \<in> analz (knows Spy evs)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   167
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   168
 A more general formula must be proved inductively.
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   169
****)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   170
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   171
(** Session keys are not used to encrypt other session keys **)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   172
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   173
lemma analz_image_freshK [rule_format]:
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   174
 "evs \<in> yahalom \<Longrightarrow>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   175
   \<forall>K KK. KK <= - (range shrK) -->
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   176
          (Key K \<in> analz (Key`KK Un (knows Spy evs))) =
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   177
          (K \<in> KK | Key K \<in> analz (knows Spy evs))"
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   178
apply (erule yahalom.induct)
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   179
apply (frule_tac [8] Says_Server_message_form)
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   180
apply (drule_tac [7] YM4_analz_knows_Spy, analz_freshK, spy_analz, blast)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   181
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   182
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   183
lemma analz_insert_freshK:
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   184
     "\<lbrakk>evs \<in> yahalom;  KAB \<notin> range shrK\<rbrakk> \<Longrightarrow>
11655
923e4d0d36d5 tuned parentheses in relational expressions;
wenzelm
parents: 11251
diff changeset
   185
      (Key K \<in> analz (insert (Key KAB) (knows Spy evs))) =
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   186
      (K = KAB | Key K \<in> analz (knows Spy evs))"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   187
by (simp only: analz_image_freshK analz_image_freshK_simps)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   188
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   189
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   190
text\<open>The Key K uniquely identifies the Server's  message\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   191
lemma unique_session_keys:
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   192
     "\<lbrakk>Says Server A
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   193
          \<lbrace>nb, Crypt (shrK A) \<lbrace>Agent B, Key K, na\<rbrace>, X\<rbrace> \<in> set evs;
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   194
        Says Server A'
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   195
          \<lbrace>nb', Crypt (shrK A') \<lbrace>Agent B', Key K, na'\<rbrace>, X'\<rbrace> \<in> set evs;
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   196
        evs \<in> yahalom\<rbrakk>
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   197
     \<Longrightarrow> A=A' & B=B' & na=na' & nb=nb'"
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   198
apply (erule rev_mp, erule rev_mp)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   199
apply (erule yahalom.induct, simp_all)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   200
txt\<open>YM3, by freshness\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   201
apply blast
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   202
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   203
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   204
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   205
subsection\<open>Crucial Secrecy Property: Spy Does Not See Key @{term KAB}\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   206
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   207
lemma secrecy_lemma:
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   208
     "\<lbrakk>A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom\<rbrakk>
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   209
      \<Longrightarrow> Says Server A
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   210
            \<lbrace>nb, Crypt (shrK A) \<lbrace>Agent B, Key K, na\<rbrace>,
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   211
                  Crypt (shrK B) \<lbrace>Agent A, Agent B, Key K, nb\<rbrace>\<rbrace>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   212
           \<in> set evs -->
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   213
          Notes Spy \<lbrace>na, nb, Key K\<rbrace> \<notin> set evs -->
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   214
          Key K \<notin> analz (knows Spy evs)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   215
apply (erule yahalom.induct, force, frule_tac [7] Says_Server_message_form,
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   216
       drule_tac [6] YM4_analz_knows_Spy)
13907
2bc462b99e70 tidying
paulson
parents: 13507
diff changeset
   217
apply (simp_all add: pushes analz_insert_eq analz_insert_freshK, spy_analz)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   218
apply (blast dest: unique_session_keys)+  (*YM3, Oops*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   219
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   220
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   221
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   222
text\<open>Final version\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   223
lemma Spy_not_see_encrypted_key:
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   224
     "\<lbrakk>Says Server A
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   225
            \<lbrace>nb, Crypt (shrK A) \<lbrace>Agent B, Key K, na\<rbrace>,
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   226
                  Crypt (shrK B) \<lbrace>Agent A, Agent B, Key K, nb\<rbrace>\<rbrace>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   227
         \<in> set evs;
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   228
         Notes Spy \<lbrace>na, nb, Key K\<rbrace> \<notin> set evs;
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   229
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom\<rbrakk>
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   230
      \<Longrightarrow> Key K \<notin> analz (knows Spy evs)"
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   231
by (blast dest: secrecy_lemma Says_Server_message_form)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   232
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   233
13907
2bc462b99e70 tidying
paulson
parents: 13507
diff changeset
   234
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   235
text\<open>This form is an immediate consequence of the previous result.  It is
13907
2bc462b99e70 tidying
paulson
parents: 13507
diff changeset
   236
similar to the assertions established by other methods.  It is equivalent
2bc462b99e70 tidying
paulson
parents: 13507
diff changeset
   237
to the previous result in that the Spy already has @{term analz} and
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   238
@{term synth} at his disposal.  However, the conclusion
13907
2bc462b99e70 tidying
paulson
parents: 13507
diff changeset
   239
@{term "Key K \<notin> knows Spy evs"} appears not to be inductive: all the cases
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   240
other than Fake are trivial, while Fake requires
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   241
@{term "Key K \<notin> analz (knows Spy evs)"}.\<close>
13907
2bc462b99e70 tidying
paulson
parents: 13507
diff changeset
   242
lemma Spy_not_know_encrypted_key:
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   243
     "\<lbrakk>Says Server A
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   244
            \<lbrace>nb, Crypt (shrK A) \<lbrace>Agent B, Key K, na\<rbrace>,
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   245
                  Crypt (shrK B) \<lbrace>Agent A, Agent B, Key K, nb\<rbrace>\<rbrace>
13907
2bc462b99e70 tidying
paulson
parents: 13507
diff changeset
   246
         \<in> set evs;
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   247
         Notes Spy \<lbrace>na, nb, Key K\<rbrace> \<notin> set evs;
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   248
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom\<rbrakk>
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   249
      \<Longrightarrow> Key K \<notin> knows Spy evs"
13907
2bc462b99e70 tidying
paulson
parents: 13507
diff changeset
   250
by (blast dest: Spy_not_see_encrypted_key)
2bc462b99e70 tidying
paulson
parents: 13507
diff changeset
   251
2bc462b99e70 tidying
paulson
parents: 13507
diff changeset
   252
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   253
subsection\<open>Security Guarantee for A upon receiving YM3\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   254
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   255
text\<open>If the encrypted message appears then it originated with the Server.
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   256
  May now apply \<open>Spy_not_see_encrypted_key\<close>, subject to its conditions.\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   257
lemma A_trusts_YM3:
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   258
     "\<lbrakk>Crypt (shrK A) \<lbrace>Agent B, Key K, na\<rbrace> \<in> parts (knows Spy evs);
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   259
         A \<notin> bad;  evs \<in> yahalom\<rbrakk>
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   260
      \<Longrightarrow> \<exists>nb. Says Server A
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   261
                    \<lbrace>nb, Crypt (shrK A) \<lbrace>Agent B, Key K, na\<rbrace>,
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   262
                          Crypt (shrK B) \<lbrace>Agent A, Agent B, Key K, nb\<rbrace>\<rbrace>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   263
                  \<in> set evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   264
apply (erule rev_mp)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   265
apply (erule yahalom.induct, force,
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   266
       frule_tac [6] YM4_parts_knows_Spy, simp_all)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   267
txt\<open>Fake, YM3\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   268
apply blast+
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   269
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   270
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   271
text\<open>The obvious combination of \<open>A_trusts_YM3\<close> with 
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   272
\<open>Spy_not_see_encrypted_key\<close>\<close>
13907
2bc462b99e70 tidying
paulson
parents: 13507
diff changeset
   273
theorem A_gets_good_key:
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   274
     "\<lbrakk>Crypt (shrK A) \<lbrace>Agent B, Key K, na\<rbrace> \<in> parts (knows Spy evs);
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   275
         \<forall>nb. Notes Spy \<lbrace>na, nb, Key K\<rbrace> \<notin> set evs;
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   276
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom\<rbrakk>
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   277
      \<Longrightarrow> Key K \<notin> analz (knows Spy evs)"
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   278
by (blast dest!: A_trusts_YM3 Spy_not_see_encrypted_key)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   279
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   280
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   281
subsection\<open>Security Guarantee for B upon receiving YM4\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   282
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   283
text\<open>B knows, by the first part of A's message, that the Server distributed
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   284
  the key for A and B, and has associated it with NB.\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   285
lemma B_trusts_YM4_shrK:
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   286
     "\<lbrakk>Crypt (shrK B) \<lbrace>Agent A, Agent B, Key K, Nonce NB\<rbrace>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   287
           \<in> parts (knows Spy evs);
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   288
         B \<notin> bad;  evs \<in> yahalom\<rbrakk>
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   289
  \<Longrightarrow> \<exists>NA. Says Server A
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   290
             \<lbrace>Nonce NB,
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   291
               Crypt (shrK A) \<lbrace>Agent B, Key K, Nonce NA\<rbrace>,
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   292
               Crypt (shrK B) \<lbrace>Agent A, Agent B, Key K, Nonce NB\<rbrace>\<rbrace>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   293
             \<in> set evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   294
apply (erule rev_mp)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   295
apply (erule yahalom.induct, force,
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   296
       frule_tac [6] YM4_parts_knows_Spy, simp_all)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   297
txt\<open>Fake, YM3\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   298
apply blast+
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   299
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   300
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   301
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   302
text\<open>With this protocol variant, we don't need the 2nd part of YM4 at all:
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   303
  Nonce NB is available in the first part.\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   304
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   305
text\<open>What can B deduce from receipt of YM4?  Stronger and simpler than Yahalom
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   306
  because we do not have to show that NB is secret.\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   307
lemma B_trusts_YM4:
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   308
     "\<lbrakk>Gets B \<lbrace>Crypt (shrK B) \<lbrace>Agent A, Agent B, Key K, Nonce NB\<rbrace>,  X\<rbrace>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   309
           \<in> set evs;
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   310
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom\<rbrakk>
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   311
  \<Longrightarrow> \<exists>NA. Says Server A
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   312
             \<lbrace>Nonce NB,
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   313
               Crypt (shrK A) \<lbrace>Agent B, Key K, Nonce NA\<rbrace>,
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   314
               Crypt (shrK B) \<lbrace>Agent A, Agent B, Key K, Nonce NB\<rbrace>\<rbrace>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   315
            \<in> set evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   316
by (blast dest!: B_trusts_YM4_shrK)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   317
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   318
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   319
text\<open>The obvious combination of \<open>B_trusts_YM4\<close> with 
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   320
\<open>Spy_not_see_encrypted_key\<close>\<close>
13907
2bc462b99e70 tidying
paulson
parents: 13507
diff changeset
   321
theorem B_gets_good_key:
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   322
     "\<lbrakk>Gets B \<lbrace>Crypt (shrK B) \<lbrace>Agent A, Agent B, Key K, Nonce NB\<rbrace>, X\<rbrace>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   323
           \<in> set evs;
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   324
         \<forall>na. Notes Spy \<lbrace>na, Nonce NB, Key K\<rbrace> \<notin> set evs;
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   325
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom\<rbrakk>
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   326
      \<Longrightarrow> Key K \<notin> analz (knows Spy evs)"
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   327
by (blast dest!: B_trusts_YM4 Spy_not_see_encrypted_key)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   328
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   329
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   330
subsection\<open>Authenticating B to A\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   331
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   332
text\<open>The encryption in message YM2 tells us it cannot be faked.\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   333
lemma B_Said_YM2:
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   334
     "\<lbrakk>Crypt (shrK B) \<lbrace>Agent A, Nonce NA\<rbrace> \<in> parts (knows Spy evs);
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   335
         B \<notin> bad;  evs \<in> yahalom\<rbrakk>
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   336
      \<Longrightarrow> \<exists>NB. Says B Server \<lbrace>Agent B, Nonce NB,
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   337
                               Crypt (shrK B) \<lbrace>Agent A, Nonce NA\<rbrace>\<rbrace>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   338
                      \<in> set evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   339
apply (erule rev_mp)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   340
apply (erule yahalom.induct, force,
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   341
       frule_tac [6] YM4_parts_knows_Spy, simp_all)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   342
txt\<open>Fake, YM2\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   343
apply blast+
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   344
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   345
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   346
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   347
text\<open>If the server sends YM3 then B sent YM2, perhaps with a different NB\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   348
lemma YM3_auth_B_to_A_lemma:
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   349
     "\<lbrakk>Says Server A \<lbrace>nb, Crypt (shrK A) \<lbrace>Agent B, Key K, Nonce NA\<rbrace>, X\<rbrace>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   350
           \<in> set evs;
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   351
         B \<notin> bad;  evs \<in> yahalom\<rbrakk>
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   352
      \<Longrightarrow> \<exists>nb'. Says B Server \<lbrace>Agent B, nb',
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   353
                                   Crypt (shrK B) \<lbrace>Agent A, Nonce NA\<rbrace>\<rbrace>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   354
                       \<in> set evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   355
apply (erule rev_mp)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   356
apply (erule yahalom.induct, simp_all)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   357
txt\<open>Fake, YM2, YM3\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   358
apply (blast dest!: B_Said_YM2)+
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   359
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   360
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   361
text\<open>If A receives YM3 then B has used nonce NA (and therefore is alive)\<close>
13907
2bc462b99e70 tidying
paulson
parents: 13507
diff changeset
   362
theorem YM3_auth_B_to_A:
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   363
     "\<lbrakk>Gets A \<lbrace>nb, Crypt (shrK A) \<lbrace>Agent B, Key K, Nonce NA\<rbrace>, X\<rbrace>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   364
           \<in> set evs;
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   365
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom\<rbrakk>
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   366
 \<Longrightarrow> \<exists>nb'. Says B Server
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   367
                  \<lbrace>Agent B, nb', Crypt (shrK B) \<lbrace>Agent A, Nonce NA\<rbrace>\<rbrace>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   368
               \<in> set evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   369
by (blast dest!: A_trusts_YM3 YM3_auth_B_to_A_lemma)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   370
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   371
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   372
subsection\<open>Authenticating A to B\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   373
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   374
text\<open>using the certificate @{term "Crypt K (Nonce NB)"}\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   375
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   376
text\<open>Assuming the session key is secure, if both certificates are present then
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   377
  A has said NB.  We can't be sure about the rest of A's message, but only
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   378
  NB matters for freshness.  Note that @{term "Key K \<notin> analz (knows Spy evs)"}
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   379
  must be the FIRST antecedent of the induction formula.\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   380
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   381
text\<open>This lemma allows a use of \<open>unique_session_keys\<close> in the next proof,
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   382
  which otherwise is extremely slow.\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   383
lemma secure_unique_session_keys:
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   384
     "\<lbrakk>Crypt (shrK A) \<lbrace>Agent B, Key K, na\<rbrace> \<in> analz (spies evs);
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   385
         Crypt (shrK A') \<lbrace>Agent B', Key K, na'\<rbrace> \<in> analz (spies evs);
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   386
         Key K \<notin> analz (knows Spy evs);  evs \<in> yahalom\<rbrakk>
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   387
     \<Longrightarrow> A=A' & B=B'"
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   388
by (blast dest!: A_trusts_YM3 dest: unique_session_keys Crypt_Spy_analz_bad)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   389
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   390
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   391
lemma Auth_A_to_B_lemma [rule_format]:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   392
     "evs \<in> yahalom
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   393
      \<Longrightarrow> Key K \<notin> analz (knows Spy evs) -->
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   394
          K \<in> symKeys -->
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   395
          Crypt K (Nonce NB) \<in> parts (knows Spy evs) -->
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   396
          Crypt (shrK B) \<lbrace>Agent A, Agent B, Key K, Nonce NB\<rbrace>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   397
            \<in> parts (knows Spy evs) -->
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   398
          B \<notin> bad -->
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   399
          (\<exists>X. Says A B \<lbrace>X, Crypt K (Nonce NB)\<rbrace> \<in> set evs)"
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   400
apply (erule yahalom.induct, force,
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   401
       frule_tac [6] YM4_parts_knows_Spy)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   402
apply (analz_mono_contra, simp_all)
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   403
  subgoal --\<open>Fake\<close> by blast
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   404
  subgoal --\<open>YM3 because the message @{term "Crypt K (Nonce NB)"} could not exist\<close>
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   405
    by (force dest!: Crypt_imp_keysFor)
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   406
  subgoal --\<open>YM4: was @{term "Crypt K (Nonce NB)"} the very last message? If not, use the induction hypothesis,
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   407
             otherwise by unicity of session keys\<close>
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   408
    by (blast dest!: B_trusts_YM4_shrK dest: secure_unique_session_keys)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   409
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   410
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   411
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   412
text\<open>If B receives YM4 then A has used nonce NB (and therefore is alive).
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   413
  Moreover, A associates K with NB (thus is talking about the same run).
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   414
  Other premises guarantee secrecy of K.\<close>
13907
2bc462b99e70 tidying
paulson
parents: 13507
diff changeset
   415
theorem YM4_imp_A_Said_YM3 [rule_format]:
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   416
     "\<lbrakk>Gets B \<lbrace>Crypt (shrK B) \<lbrace>Agent A, Agent B, Key K, Nonce NB\<rbrace>,
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   417
                  Crypt K (Nonce NB)\<rbrace> \<in> set evs;
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   418
         (\<forall>NA. Notes Spy \<lbrace>Nonce NA, Nonce NB, Key K\<rbrace> \<notin> set evs);
64364
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   419
         K \<in> symKeys;  A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom\<rbrakk>
464420ba7f74 "subgoal" examples
paulson <lp15@cam.ac.uk>
parents: 61956
diff changeset
   420
      \<Longrightarrow> \<exists>X. Says A B \<lbrace>X, Crypt K (Nonce NB)\<rbrace> \<in> set evs"
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   421
by (blast intro: Auth_A_to_B_lemma
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   422
          dest: Spy_not_see_encrypted_key B_trusts_YM4_shrK)
2111
81c8d46edfa3 New version of Yahalom, as recommended on p 259 of BAN paper
paulson
parents:
diff changeset
   423
81c8d46edfa3 New version of Yahalom, as recommended on p 259 of BAN paper
paulson
parents:
diff changeset
   424
end