src/HOL/Auth/Yahalom_Bad.thy
author wenzelm
Thu, 15 Feb 2018 12:11:00 +0100
changeset 67613 ce654b0e6d69
parent 61956 38b73f7940af
child 69597 ff784d5a5bfb
permissions -rw-r--r--
more symbols;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37936
1e4c5015a72e updated some headers;
wenzelm
parents: 23746
diff changeset
     1
(*  Title:      HOL/Auth/Yahalom_Bad.thy
6400
1f495d4d922b added new theory Yahalom_Bad
paulson
parents:
diff changeset
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
1f495d4d922b added new theory Yahalom_Bad
paulson
parents:
diff changeset
     3
    Copyright   1996  University of Cambridge
1f495d4d922b added new theory Yahalom_Bad
paulson
parents:
diff changeset
     4
*)
1f495d4d922b added new theory Yahalom_Bad
paulson
parents:
diff changeset
     5
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
     6
section\<open>The Yahalom Protocol: A Flawed Version\<close>
13956
8fe7e12290e1 improved presentation of HOL/Auth theories
paulson
parents: 13926
diff changeset
     7
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 14207
diff changeset
     8
theory Yahalom_Bad 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>
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
    11
Demonstrates of why Oops is necessary.  This protocol can be attacked because
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
    12
it doesn't keep NB secret, but without Oops it can be "verified" anyway.
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
    13
The issues are discussed in lcp's LICS 2000 invited lecture.
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
    14
\<close>
6400
1f495d4d922b added new theory Yahalom_Bad
paulson
parents:
diff changeset
    15
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    16
inductive_set yahalom :: "event list set"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    17
  where
6400
1f495d4d922b added new theory Yahalom_Bad
paulson
parents:
diff changeset
    18
         (*Initial trace is empty*)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    19
   Nil:  "[] \<in> yahalom"
6400
1f495d4d922b added new theory Yahalom_Bad
paulson
parents:
diff changeset
    20
1f495d4d922b added new theory Yahalom_Bad
paulson
parents:
diff changeset
    21
         (*The spy MAY say anything he CAN say.  We do not expect him to
1f495d4d922b added new theory Yahalom_Bad
paulson
parents:
diff changeset
    22
           invent new nonces here, but he can also use NS1.  Common to
1f495d4d922b added new theory Yahalom_Bad
paulson
parents:
diff changeset
    23
           all similar protocols.*)
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    24
 | Fake: "[| evsf \<in> yahalom;  X \<in> synth (analz (knows Spy evsf)) |]
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    25
          ==> Says Spy B X  # evsf \<in> yahalom"
6400
1f495d4d922b added new theory Yahalom_Bad
paulson
parents:
diff changeset
    26
1f495d4d922b added new theory Yahalom_Bad
paulson
parents:
diff changeset
    27
         (*A message that has been sent can be received by the
1f495d4d922b added new theory Yahalom_Bad
paulson
parents:
diff changeset
    28
           intended recipient.*)
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    29
 | Reception: "[| evsr \<in> yahalom;  Says A B X \<in> set evsr |]
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    30
               ==> Gets B X # evsr \<in> yahalom"
6400
1f495d4d922b added new theory Yahalom_Bad
paulson
parents:
diff changeset
    31
1f495d4d922b added new theory Yahalom_Bad
paulson
parents:
diff changeset
    32
         (*Alice initiates a protocol run*)
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    33
 | YM1:  "[| evs1 \<in> yahalom;  Nonce NA \<notin> used evs1 |]
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
    34
          ==> Says A B \<lbrace>Agent A, Nonce NA\<rbrace> # evs1 \<in> yahalom"
6400
1f495d4d922b added new theory Yahalom_Bad
paulson
parents:
diff changeset
    35
1f495d4d922b added new theory Yahalom_Bad
paulson
parents:
diff changeset
    36
         (*Bob's response to Alice's message.*)
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    37
 | YM2:  "[| evs2 \<in> yahalom;  Nonce NB \<notin> used evs2;
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
    38
             Gets B \<lbrace>Agent A, Nonce NA\<rbrace> \<in> set evs2 |]
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    39
          ==> Says B Server
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
    40
                  \<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
    41
                # evs2 \<in> yahalom"
6400
1f495d4d922b added new theory Yahalom_Bad
paulson
parents:
diff changeset
    42
1f495d4d922b added new theory Yahalom_Bad
paulson
parents:
diff changeset
    43
         (*The Server receives Bob's message.  He responds by sending a
1f495d4d922b added new theory Yahalom_Bad
paulson
parents:
diff changeset
    44
            new session key to Alice, with a packet for forwarding to Bob.*)
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    45
 | YM3:  "[| evs3 \<in> yahalom;  Key KAB \<notin> used evs3;  KAB \<in> symKeys;
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    46
             Gets Server
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
    47
                  \<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
    48
               \<in> set evs3 |]
6400
1f495d4d922b added new theory Yahalom_Bad
paulson
parents:
diff changeset
    49
          ==> Says Server A
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
    50
                   \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key KAB, Nonce NA, Nonce NB\<rbrace>,
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
    51
                     Crypt (shrK B) \<lbrace>Agent A, Key KAB\<rbrace>\<rbrace>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    52
                # evs3 \<in> yahalom"
6400
1f495d4d922b added new theory Yahalom_Bad
paulson
parents:
diff changeset
    53
1f495d4d922b added new theory Yahalom_Bad
paulson
parents:
diff changeset
    54
         (*Alice receives the Server's (?) message, checks her Nonce, and
1f495d4d922b added new theory Yahalom_Bad
paulson
parents:
diff changeset
    55
           uses the new session key to send Bob his Nonce.  The premise
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    56
           A \<noteq> Server is needed to prove Says_Server_not_range.*)
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 16417
diff changeset
    57
 | YM4:  "[| evs4 \<in> yahalom;  A \<noteq> Server;  K \<in> symKeys;
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
    58
             Gets A \<lbrace>Crypt(shrK A) \<lbrace>Agent B, Key K, Nonce NA, Nonce NB\<rbrace>, X\<rbrace>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    59
                \<in> set evs4;
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
    60
             Says A B \<lbrace>Agent A, Nonce NA\<rbrace> \<in> set evs4 |]
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
    61
          ==> Says A B \<lbrace>X, Crypt K (Nonce NB)\<rbrace> # evs4 \<in> yahalom"
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    62
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    63
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    64
declare Says_imp_knows_Spy [THEN analz.Inj, dest]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    65
declare parts.Body  [dest]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    66
declare Fake_parts_insert_in_Un  [dest]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    67
declare analz_into_parts [dest]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    68
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    69
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
    70
text\<open>A "possibility property": there are traces that reach the end\<close>
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
    71
lemma "[| A \<noteq> Server; Key K \<notin> used []; K \<in> symKeys |] 
14200
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 13956
diff changeset
    72
       ==> \<exists>X NB. \<exists>evs \<in> yahalom.
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
    73
              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
    74
apply (intro exI bexI)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    75
apply (rule_tac [2] yahalom.Nil
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    76
                    [THEN yahalom.YM1, THEN yahalom.Reception,
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    77
                     THEN yahalom.YM2, THEN yahalom.Reception,
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    78
                     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
    79
                     THEN yahalom.YM4])
d8598e24f8fa Removal of the Key_supply axiom (affects many possbility proofs) and minor
paulson
parents: 13956
diff changeset
    80
apply (possibility, simp add: used_Cons) 
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    81
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    82
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
    83
subsection\<open>Regularity Lemmas for Yahalom\<close>
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
    84
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    85
lemma Gets_imp_Says:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    86
     "[| Gets B X \<in> set evs; evs \<in> yahalom |] ==> \<exists>A. Says A B X \<in> set evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    87
by (erule rev_mp, erule yahalom.induct, auto)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    88
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    89
(*Must be proved separately for each protocol*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    90
lemma Gets_imp_knows_Spy:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    91
     "[| Gets B X \<in> set evs; evs \<in> yahalom |]  ==> X \<in> knows Spy evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    92
by (blast dest!: Gets_imp_Says Says_imp_knows_Spy)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    93
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    94
declare Gets_imp_knows_Spy [THEN analz.Inj, dest]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    95
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    96
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
    97
subsection\<open>For reasoning about the encrypted portion of messages\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    98
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
    99
text\<open>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
   100
lemma YM4_analz_knows_Spy:
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   101
     "[| Gets A \<lbrace>Crypt (shrK A) Y, X\<rbrace> \<in> set evs;  evs \<in> yahalom |]
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   102
      ==> X \<in> analz (knows Spy evs)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   103
by blast
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   104
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   105
lemmas YM4_parts_knows_Spy =
45605
a89b4bc311a5 eliminated obsolete "standard";
wenzelm
parents: 37936
diff changeset
   106
       YM4_analz_knows_Spy [THEN analz_into_parts]
11251
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
text\<open>Theorems of the form @{term "X \<notin> parts (knows Spy evs)"} imply 
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   110
            that NOBODY sends messages containing X!\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   111
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   112
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
   113
lemma Spy_see_shrK [simp]:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   114
     "evs \<in> yahalom ==> (Key (shrK A) \<in> parts (knows Spy evs)) = (A \<in> bad)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   115
apply (erule yahalom.induct, force,
13507
febb8e5d2a9d tidying of Isar scripts
paulson
parents: 11655
diff changeset
   116
       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
   117
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   118
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   119
lemma Spy_analz_shrK [simp]:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   120
     "evs \<in> yahalom ==> (Key (shrK A) \<in> analz (knows Spy evs)) = (A \<in> bad)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   121
by auto
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   122
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   123
lemma Spy_see_shrK_D [dest!]:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   124
     "[|Key (shrK A) \<in> parts (knows Spy evs);  evs \<in> yahalom|] ==> A \<in> bad"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   125
by (blast dest: Spy_see_shrK)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   126
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   127
text\<open>Nobody can have used non-existent keys!
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   128
    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
   129
lemma new_keys_not_used [simp]:
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   130
    "[|Key K \<notin> used evs; K \<in> symKeys; evs \<in> yahalom|]
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   131
     ==> K \<notin> keysFor (parts (spies evs))"
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   132
apply (erule rev_mp)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   133
apply (erule yahalom.induct, force,
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   134
       frule_tac [6] YM4_parts_knows_Spy, simp_all)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   135
txt\<open>Fake\<close>
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   136
apply (force dest!: keysFor_parts_insert, auto)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   137
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   138
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   139
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   140
subsection\<open>Secrecy Theorems\<close>
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   141
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   142
(****
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   143
 The following is to prove theorems of the form
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   144
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   145
  Key K \<in> analz (insert (Key KAB) (knows Spy evs)) ==>
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   146
  Key K \<in> analz (knows Spy evs)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   147
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   148
 A more general formula must be proved inductively.
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   149
****)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   150
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   151
subsection\<open>Session keys are not used to encrypt other session keys\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   152
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   153
lemma analz_image_freshK [rule_format]:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   154
 "evs \<in> yahalom ==>
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 61956
diff changeset
   155
   \<forall>K KK. KK \<subseteq> - (range shrK) \<longrightarrow>
ce654b0e6d69 more symbols;
wenzelm
parents: 61956
diff changeset
   156
          (Key K \<in> analz (Key`KK \<union> (knows Spy evs))) =
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   157
          (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
   158
by (erule yahalom.induct, 
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   159
    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
   160
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   161
lemma analz_insert_freshK:
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   162
     "[| evs \<in> yahalom;  KAB \<notin> range shrK |] ==>
11655
923e4d0d36d5 tuned parentheses in relational expressions;
wenzelm
parents: 11251
diff changeset
   163
      (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
   164
      (K = KAB | Key K \<in> analz (knows Spy evs))"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   165
by (simp only: analz_image_freshK analz_image_freshK_simps)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   166
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   167
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   168
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
   169
lemma unique_session_keys:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   170
     "[| Says Server A
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   171
          \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, na, nb\<rbrace>, X\<rbrace> \<in> set evs;
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   172
        Says Server A'
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   173
          \<lbrace>Crypt (shrK A') \<lbrace>Agent B', Key K, na', nb'\<rbrace>, X'\<rbrace> \<in> set evs;
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   174
        evs \<in> yahalom |]
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 61956
diff changeset
   175
     ==> A=A' \<and> B=B' \<and> na=na' \<and> nb=nb'"
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   176
apply (erule rev_mp, erule rev_mp)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   177
apply (erule yahalom.induct, simp_all)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   178
txt\<open>YM3, by freshness, and YM4\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   179
apply blast+
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   180
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   181
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   182
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   183
text\<open>Crucial secrecy property: Spy does not see the keys sent in msg YM3\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   184
lemma secrecy_lemma:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   185
     "[| A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   186
      ==> Says Server A
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   187
            \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, na, nb\<rbrace>,
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   188
              Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>\<rbrace>
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 61956
diff changeset
   189
           \<in> set evs \<longrightarrow>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   190
          Key K \<notin> analz (knows Spy evs)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   191
apply (erule yahalom.induct, force, drule_tac [6] YM4_analz_knows_Spy)
13507
febb8e5d2a9d tidying of Isar scripts
paulson
parents: 11655
diff changeset
   192
apply (simp_all add: pushes analz_insert_eq analz_insert_freshK, spy_analz)  (*Fake*)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   193
apply (blast dest: unique_session_keys)  (*YM3*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   194
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   195
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   196
text\<open>Final version\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   197
lemma Spy_not_see_encrypted_key:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   198
     "[| Says Server A
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   199
            \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, na, nb\<rbrace>,
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   200
              Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>\<rbrace>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   201
           \<in> set evs;
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   202
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   203
      ==> Key K \<notin> analz (knows Spy evs)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   204
by (blast dest: secrecy_lemma)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   205
6400
1f495d4d922b added new theory Yahalom_Bad
paulson
parents:
diff changeset
   206
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   207
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
   208
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   209
text\<open>If the encrypted message appears then it originated with the Server\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   210
lemma A_trusts_YM3:
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   211
     "[| Crypt (shrK A) \<lbrace>Agent B, Key K, na, nb\<rbrace> \<in> parts (knows Spy evs);
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   212
         A \<notin> bad;  evs \<in> yahalom |]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   213
       ==> Says Server A
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   214
            \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, na, nb\<rbrace>,
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   215
              Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>\<rbrace>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   216
           \<in> set evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   217
apply (erule rev_mp)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   218
apply (erule yahalom.induct, force,
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   219
       frule_tac [6] YM4_parts_knows_Spy, simp_all)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   220
txt\<open>Fake, YM3\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   221
apply blast+
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   222
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   223
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   224
text\<open>The obvious combination of \<open>A_trusts_YM3\<close> with
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   225
  \<open>Spy_not_see_encrypted_key\<close>\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   226
lemma A_gets_good_key:
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   227
     "[| Crypt (shrK A) \<lbrace>Agent B, Key K, na, nb\<rbrace> \<in> parts (knows Spy evs);
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   228
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   229
      ==> Key K \<notin> analz (knows Spy evs)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   230
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
   231
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   232
subsection\<open>Security Guarantees for B upon receiving YM4\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   233
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   234
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
   235
  the key for A and B.  But this part says nothing about nonces.\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   236
lemma B_trusts_YM4_shrK:
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   237
     "[| Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace> \<in> parts (knows Spy evs);
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   238
         B \<notin> bad;  evs \<in> yahalom |]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   239
      ==> \<exists>NA NB. Says Server A
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   240
                      \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, Nonce NA, Nonce NB\<rbrace>,
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   241
                        Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>\<rbrace>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   242
                     \<in> set evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   243
apply (erule rev_mp)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   244
apply (erule yahalom.induct, force,
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   245
       frule_tac [6] YM4_parts_knows_Spy, simp_all)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   246
txt\<open>Fake, YM3\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   247
apply blast+
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   248
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   249
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   250
subsection\<open>The Flaw in the Model\<close>
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   251
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   252
text\<open>Up to now, the reasoning is similar to standard Yahalom.  Now the
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   253
    doubtful reasoning occurs.  We should not be assuming that an unknown
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   254
    key is secure, but the model allows us to: there is no Oops rule to
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   255
    let session keys become compromised.\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   256
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   257
text\<open>B knows, by the second part of A's message, that the Server distributed
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   258
  the key quoting nonce NB.  This part says nothing about agent names.
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   259
  Secrecy of K is assumed; the valid Yahalom proof uses (and later proves)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   260
  the secrecy of NB.\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   261
lemma B_trusts_YM4_newK [rule_format]:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   262
     "[|Key K \<notin> analz (knows Spy evs);  evs \<in> yahalom|]
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 61956
diff changeset
   263
      ==> Crypt K (Nonce NB) \<in> parts (knows Spy evs) \<longrightarrow>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   264
          (\<exists>A B NA. Says Server A
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   265
                      \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K,
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   266
                                Nonce NA, Nonce NB\<rbrace>,
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   267
                        Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>\<rbrace>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   268
                     \<in> set evs)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   269
apply (erule rev_mp)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   270
apply (erule yahalom.induct, force,
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   271
       frule_tac [6] YM4_parts_knows_Spy)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   272
apply (analz_mono_contra, simp_all)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   273
txt\<open>Fake\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   274
apply blast
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   275
txt\<open>YM3\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   276
apply blast
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   277
txt\<open>A is uncompromised because NB is secure
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   278
  A's certificate guarantees the existence of the Server message\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   279
apply (blast dest!: Gets_imp_Says Crypt_Spy_analz_bad
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   280
             dest: Says_imp_spies
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   281
                   parts.Inj [THEN parts.Fst, THEN A_trusts_YM3])
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   282
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   283
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   284
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   285
text\<open>B's session key guarantee from YM4.  The two certificates contribute to a
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   286
  single conclusion about the Server's message.\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   287
lemma B_trusts_YM4:
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   288
     "[| Gets B \<lbrace>Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>,
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   289
                  Crypt K (Nonce NB)\<rbrace> \<in> set evs;
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   290
         Says B Server
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   291
           \<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
   292
           \<in> set evs;
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   293
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   294
       ==> \<exists>na nb. Says Server A
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   295
                   \<lbrace>Crypt (shrK A) \<lbrace>Agent B, Key K, na, nb\<rbrace>,
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   296
                     Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>\<rbrace>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   297
             \<in> set evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   298
by (blast dest: B_trusts_YM4_newK B_trusts_YM4_shrK Spy_not_see_encrypted_key
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   299
                unique_session_keys)
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>The obvious combination of \<open>B_trusts_YM4\<close> with 
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   303
  \<open>Spy_not_see_encrypted_key\<close>\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   304
lemma B_gets_good_key:
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   305
     "[| Gets B \<lbrace>Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>,
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   306
                  Crypt K (Nonce NB)\<rbrace> \<in> set evs;
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   307
         Says B Server
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   308
           \<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
   309
           \<in> set evs;
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   310
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   311
      ==> Key K \<notin> analz (knows Spy evs)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   312
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
   313
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   314
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   315
(*** Authenticating B to A: these proofs are not considered.
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   316
     They are irrelevant to showing the need for Oops. ***)
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
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   319
(*** Authenticating A to B using the certificate Crypt K (Nonce NB) ***)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   320
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   321
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
   322
  A has said NB.  We can't be sure about the rest of A's message, but only
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   323
  NB matters for freshness.\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   324
lemma A_Said_YM3_lemma [rule_format]:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   325
     "evs \<in> yahalom
67613
ce654b0e6d69 more symbols;
wenzelm
parents: 61956
diff changeset
   326
      ==> Key K \<notin> analz (knows Spy evs) \<longrightarrow>
ce654b0e6d69 more symbols;
wenzelm
parents: 61956
diff changeset
   327
          Crypt K (Nonce NB) \<in> parts (knows Spy evs) \<longrightarrow>
ce654b0e6d69 more symbols;
wenzelm
parents: 61956
diff changeset
   328
          Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace> \<in> parts (knows Spy evs) \<longrightarrow>
ce654b0e6d69 more symbols;
wenzelm
parents: 61956
diff changeset
   329
          B \<notin> bad \<longrightarrow>
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   330
          (\<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
   331
apply (erule yahalom.induct, force,
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   332
       frule_tac [6] YM4_parts_knows_Spy)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   333
apply (analz_mono_contra, simp_all)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   334
txt\<open>Fake\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   335
apply blast
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   336
txt\<open>YM3: by \<open>new_keys_not_used\<close>, the message
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   337
   @{term "Crypt K (Nonce NB)"} could not exist\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   338
apply (force dest!: Crypt_imp_keysFor)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   339
txt\<open>YM4: was @{term "Crypt K (Nonce NB)"} the very last message?
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   340
    If not, use the induction hypothesis\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   341
apply (simp add: ex_disj_distrib)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   342
txt\<open>yes: apply unicity of session keys\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   343
apply (blast dest!: Gets_imp_Says A_trusts_YM3 B_trusts_YM4_shrK
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   344
                    Crypt_Spy_analz_bad
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   345
             dest: Says_imp_knows_Spy [THEN parts.Inj] unique_session_keys)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   346
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   347
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 58889
diff changeset
   348
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
   349
  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
   350
  Other premises guarantee secrecy of K.\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   351
lemma YM4_imp_A_Said_YM3 [rule_format]:
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   352
     "[| Gets B \<lbrace>Crypt (shrK B) \<lbrace>Agent A, Key K\<rbrace>,
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   353
                  Crypt K (Nonce NB)\<rbrace> \<in> set evs;
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   354
         Says B Server
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   355
           \<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
   356
           \<in> set evs;
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   357
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
61956
38b73f7940af more symbols;
wenzelm
parents: 61830
diff changeset
   358
      ==> \<exists>X. Says A B \<lbrace>X, Crypt K (Nonce NB)\<rbrace> \<in> set evs"
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   359
by (blast intro!: A_Said_YM3_lemma
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   360
          dest: Spy_not_see_encrypted_key B_trusts_YM4 Gets_imp_Says)
6400
1f495d4d922b added new theory Yahalom_Bad
paulson
parents:
diff changeset
   361
1f495d4d922b added new theory Yahalom_Bad
paulson
parents:
diff changeset
   362
end