src/HOL/Auth/Yahalom.thy
author wenzelm
Thu, 10 Dec 2015 21:39:33 +0100
changeset 61830 4f5ab843cf5b
parent 59807 22bc39064290
child 61956 38b73f7940af
permissions -rw-r--r--
isabelle update_cartouches -c -t;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37936
1e4c5015a72e updated some headers;
wenzelm
parents: 35416
diff changeset
     1
(*  Title:      HOL/Auth/Yahalom.thy
1985
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
diff changeset
     2
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
diff changeset
     3
    Copyright   1996  University of Cambridge
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
diff changeset
     4
*)
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
diff changeset
     5
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
     6
section\<open>The Yahalom Protocol\<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 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: 59807
diff changeset
    10
text\<open>From page 257 of
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
    11
  Burrows, Abadi and Needham (1989).  A Logic of Authentication.
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
    12
  Proc. Royal Soc. 426
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
    13
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
    14
This theory has the prototypical example of a secrecy relation, KeyCryptNonce.
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
    15
\<close>
1985
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
diff changeset
    16
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 18570
diff changeset
    17
inductive_set yahalom :: "event list set"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 18570
diff changeset
    18
  where
1985
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
diff changeset
    19
         (*Initial trace is empty*)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    20
   Nil:  "[] \<in> yahalom"
1985
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
diff changeset
    21
2032
1bbf1bdcaf56 Introduction of "lost" argument
paulson
parents: 1995
diff changeset
    22
         (*The spy MAY say anything he CAN say.  We do not expect him to
1985
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
diff changeset
    23
           invent new nonces here, but he can also use NS1.  Common to
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
diff changeset
    24
           all similar protocols.*)
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 18570
diff changeset
    25
 | 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
    26
          ==> Says Spy B X  # evsf \<in> yahalom"
1985
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
diff changeset
    27
6335
7e4bffaa2a3e updating both Yahalom protocols to the Gets model
paulson
parents: 5434
diff changeset
    28
         (*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
    29
           intended recipient.*)
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 18570
diff changeset
    30
 | 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
    31
               ==> Gets B X # evsr \<in> yahalom"
6335
7e4bffaa2a3e updating both Yahalom protocols to the Gets model
paulson
parents: 5434
diff changeset
    32
1985
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
diff changeset
    33
         (*Alice initiates a protocol run*)
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 18570
diff changeset
    34
 | YM1:  "[| evs1 \<in> yahalom;  Nonce NA \<notin> used evs1 |]
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    35
          ==> Says A B {|Agent A, Nonce NA|} # evs1 \<in> yahalom"
1985
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
diff changeset
    36
6335
7e4bffaa2a3e updating both Yahalom protocols to the Gets model
paulson
parents: 5434
diff changeset
    37
         (*Bob's response to Alice's message.*)
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 18570
diff changeset
    38
 | YM2:  "[| evs2 \<in> yahalom;  Nonce NB \<notin> used evs2;
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    39
             Gets B {|Agent A, Nonce NA|} \<in> set evs2 |]
1985
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
diff changeset
    40
          ==> Says B Server 
2516
4d68fbe6378b Now with Andy Gordon's treatment of freshness to replace newN/K
paulson
parents: 2451
diff changeset
    41
                  {|Agent B, Crypt (shrK B) {|Agent A, Nonce NA, Nonce NB|}|}
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    42
                # evs2 \<in> yahalom"
1985
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
diff changeset
    43
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
diff changeset
    44
         (*The Server receives Bob's message.  He responds by sending a
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
diff changeset
    45
            new session key to Alice, with a packet for forwarding to Bob.*)
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 18570
diff changeset
    46
 | YM3:  "[| evs3 \<in> yahalom;  Key KAB \<notin> used evs3;  KAB \<in> symKeys;
6335
7e4bffaa2a3e updating both Yahalom protocols to the Gets model
paulson
parents: 5434
diff changeset
    47
             Gets Server 
2284
80ebd1a213fd Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents: 2156
diff changeset
    48
                  {|Agent B, Crypt (shrK B) {|Agent A, Nonce NA, Nonce NB|}|}
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    49
               \<in> set evs3 |]
1995
c80e58e78d9c Addition of Yahalom protocol
paulson
parents: 1985
diff changeset
    50
          ==> Says Server A
3447
c7c8c0db05b9 Defines KeyWithNonce, which is used to prove the secrecy of NB
paulson
parents: 2516
diff changeset
    51
                   {|Crypt (shrK A) {|Agent B, Key KAB, Nonce NA, Nonce NB|},
c7c8c0db05b9 Defines KeyWithNonce, which is used to prove the secrecy of NB
paulson
parents: 2516
diff changeset
    52
                     Crypt (shrK B) {|Agent A, Key KAB|}|}
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    53
                # evs3 \<in> yahalom"
1985
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
diff changeset
    54
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 18570
diff changeset
    55
 | YM4:  
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
    56
       \<comment>\<open>Alice receives the Server's (?) message, checks her Nonce, and
3961
6a8996fb7d99 Many minor speedups:
paulson
parents: 3683
diff changeset
    57
           uses the new session key to send Bob his Nonce.  The premise
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
    58
           @{term "A \<noteq> Server"} is needed for \<open>Says_Server_not_range\<close>.
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
    59
           Alice can check that K is symmetric by its length.\<close>
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32377
diff changeset
    60
         "[| evs4 \<in> yahalom;  A \<noteq> Server;  K \<in> symKeys;
6335
7e4bffaa2a3e updating both Yahalom protocols to the Gets model
paulson
parents: 5434
diff changeset
    61
             Gets A {|Crypt(shrK A) {|Agent B, Key K, Nonce NA, Nonce NB|}, X|}
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    62
                \<in> set evs4;
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    63
             Says A B {|Agent A, Nonce NA|} \<in> set evs4 |]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    64
          ==> Says A B {|X, Crypt K (Nonce NB)|} # evs4 \<in> yahalom"
1985
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
diff changeset
    65
2110
d01151e66cd4 Addition of Reveal message
paulson
parents: 2032
diff changeset
    66
         (*This message models possible leaks of session keys.  The Nonces
2156
9c361df93bd5 Minor changes to comments
paulson
parents: 2125
diff changeset
    67
           identify the protocol run.  Quoting Server here ensures they are
9c361df93bd5 Minor changes to comments
paulson
parents: 2125
diff changeset
    68
           correct.*)
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 18570
diff changeset
    69
 | Oops: "[| evso \<in> yahalom;  
2284
80ebd1a213fd Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents: 2156
diff changeset
    70
             Says Server A {|Crypt (shrK A)
80ebd1a213fd Swapped arguments of Crypt (for clarity and because it is conventional)
paulson
parents: 2156
diff changeset
    71
                                   {|Agent B, Key K, Nonce NA, Nonce NB|},
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    72
                             X|}  \<in> set evso |]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    73
          ==> Notes Spy {|Nonce NA, Nonce NB, Key K|} # evso \<in> yahalom"
2110
d01151e66cd4 Addition of Reveal message
paulson
parents: 2032
diff changeset
    74
3447
c7c8c0db05b9 Defines KeyWithNonce, which is used to prove the secrecy of NB
paulson
parents: 2516
diff changeset
    75
35416
d8d7d1b785af replaced a couple of constsdefs by definitions (also some old primrecs by modern ones)
haftmann
parents: 32960
diff changeset
    76
definition KeyWithNonce :: "[key, nat, event list] => bool" where
3447
c7c8c0db05b9 Defines KeyWithNonce, which is used to prove the secrecy of NB
paulson
parents: 2516
diff changeset
    77
  "KeyWithNonce K NB evs ==
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    78
     \<exists>A B na X. 
3447
c7c8c0db05b9 Defines KeyWithNonce, which is used to prove the secrecy of NB
paulson
parents: 2516
diff changeset
    79
       Says Server A {|Crypt (shrK A) {|Agent B, Key K, na, Nonce NB|}, X|} 
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    80
         \<in> set evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    81
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    82
18570
ffce25f9aa7f a few more named lemmas
paulson
parents: 17778
diff changeset
    83
declare Says_imp_analz_Spy [dest]
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    84
declare parts.Body  [dest]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    85
declare Fake_parts_insert_in_Un  [dest]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    86
declare analz_into_parts [dest]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    87
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
    88
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
    89
lemma "[| A \<noteq> Server; K \<in> symKeys; Key K \<notin> used [] |]
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
    90
      ==> \<exists>X NB. \<exists>evs \<in> yahalom.
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    91
             Says A B {|X, Crypt K (Nonce NB)|} \<in> set evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    92
apply (intro exI bexI)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    93
apply (rule_tac [2] yahalom.Nil
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
    94
                    [THEN yahalom.YM1, THEN yahalom.Reception,
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
    95
                     THEN yahalom.YM2, THEN yahalom.Reception,
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
    96
                     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
    97
                     THEN yahalom.YM4])
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
    98
apply (possibility, simp add: used_Cons)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    99
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   100
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   101
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   102
subsection\<open>Regularity Lemmas for Yahalom\<close>
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   103
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   104
lemma Gets_imp_Says:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   105
     "[| 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
   106
by (erule rev_mp, erule yahalom.induct, auto)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   107
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   108
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
   109
lemma Gets_imp_knows_Spy:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   110
     "[| 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
   111
by (blast dest!: Gets_imp_Says Says_imp_knows_Spy)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   112
18570
ffce25f9aa7f a few more named lemmas
paulson
parents: 17778
diff changeset
   113
lemmas Gets_imp_analz_Spy = Gets_imp_knows_Spy [THEN analz.Inj]
ffce25f9aa7f a few more named lemmas
paulson
parents: 17778
diff changeset
   114
declare Gets_imp_analz_Spy [dest]
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   115
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   116
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   117
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
   118
lemma YM4_analz_knows_Spy:
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   119
     "[| Gets A {|Crypt (shrK A) Y, X|} \<in> set evs;  evs \<in> yahalom |]
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   120
      ==> X \<in> analz (knows Spy evs)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   121
by blast
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   122
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   123
lemmas YM4_parts_knows_Spy =
45605
a89b4bc311a5 eliminated obsolete "standard";
wenzelm
parents: 38795
diff changeset
   124
       YM4_analz_knows_Spy [THEN analz_into_parts]
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   125
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   126
text\<open>For Oops\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   127
lemma YM4_Key_parts_knows_Spy:
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   128
     "Says Server A {|Crypt (shrK A) {|B,K,NA,NB|}, X|} \<in> set evs
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   129
      ==> K \<in> parts (knows Spy evs)"
32367
a508148f7c25 Removal of redundant settings of unification trace and search bounds.
paulson
parents: 23746
diff changeset
   130
  by (metis parts.Body parts.Fst parts.Snd  Says_imp_knows_Spy parts.Inj)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   131
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   132
text\<open>Theorems of the form @{term "X \<notin> parts (knows Spy evs)"} imply 
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   133
that NOBODY sends messages containing X!\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   134
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   135
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
   136
lemma Spy_see_shrK [simp]:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   137
     "evs \<in> yahalom ==> (Key (shrK A) \<in> parts (knows Spy evs)) = (A \<in> bad)"
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   138
by (erule yahalom.induct, force,
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   139
    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
   140
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   141
lemma Spy_analz_shrK [simp]:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   142
     "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
   143
by auto
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
lemma Spy_see_shrK_D [dest!]:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   146
     "[|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
   147
by (blast dest: Spy_see_shrK)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   148
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   149
text\<open>Nobody can have used non-existent keys!
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   150
    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
   151
lemma new_keys_not_used [simp]:
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   152
    "[|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
   153
     ==> K \<notin> keysFor (parts (spies evs))"
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   154
apply (erule rev_mp)
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   155
apply (erule yahalom.induct, force,
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   156
       frule_tac [6] YM4_parts_knows_Spy, simp_all)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   157
txt\<open>Fake\<close>
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   158
apply (force dest!: keysFor_parts_insert, auto)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   159
done
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
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   162
text\<open>Earlier, all protocol proofs declared this theorem.
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   163
  But only a few proofs need it, e.g. Yahalom and Kerberos IV.\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   164
lemma new_keys_not_analzd:
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   165
 "[|K \<in> symKeys; evs \<in> yahalom; Key K \<notin> used evs|]
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   166
  ==> K \<notin> keysFor (analz (knows Spy evs))"
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   167
by (blast dest: new_keys_not_used intro: keysFor_mono [THEN subsetD])
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   168
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   169
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   170
text\<open>Describes the form of K when the Server sends this message.  Useful for
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   171
  Oops as well as main secrecy property.\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   172
lemma Says_Server_not_range [simp]:
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   173
     "[| Says Server A {|Crypt (shrK A) {|Agent B, Key K, na, nb|}, X|}
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   174
           \<in> set evs;   evs \<in> yahalom |]
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   175
      ==> K \<notin> range shrK"
17778
93d7e524417a changes due to new neq_simproc in simpdata.ML
nipkow
parents: 17411
diff changeset
   176
by (erule rev_mp, erule yahalom.induct, simp_all)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   177
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   178
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   179
subsection\<open>Secrecy Theorems\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   180
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
 The following is to prove theorems of the form
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   183
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   184
  Key K \<in> analz (insert (Key KAB) (knows Spy evs)) ==>
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   185
  Key K \<in> analz (knows Spy evs)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   186
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   187
 A more general formula must be proved inductively.
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: 59807
diff changeset
   190
text\<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
   191
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   192
lemma analz_image_freshK [rule_format]:
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   193
 "evs \<in> yahalom ==>
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   194
   \<forall>K KK. KK <= - (range shrK) -->
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   195
          (Key K \<in> analz (Key`KK Un (knows Spy evs))) =
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   196
          (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
   197
apply (erule yahalom.induct,
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   198
       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
   199
apply (simp only: Says_Server_not_range analz_image_freshK_simps)
38795
848be46708dc formerly unnamed infix conjunction and disjunction now named HOL.conj and HOL.disj
haftmann
parents: 37936
diff changeset
   200
apply safe
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   201
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   202
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   203
lemma analz_insert_freshK:
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   204
     "[| evs \<in> yahalom;  KAB \<notin> range shrK |] ==>
11655
923e4d0d36d5 tuned parentheses in relational expressions;
wenzelm
parents: 11251
diff changeset
   205
      (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
   206
      (K = KAB | Key K \<in> analz (knows Spy evs))"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   207
by (simp only: analz_image_freshK analz_image_freshK_simps)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   208
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   209
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   210
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
   211
lemma unique_session_keys:
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   212
     "[| Says Server A
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   213
          {|Crypt (shrK A) {|Agent B, Key K, na, nb|}, X|} \<in> set evs;
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   214
        Says Server A'
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   215
          {|Crypt (shrK A') {|Agent B', Key K, na', nb'|}, X'|} \<in> set evs;
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   216
        evs \<in> yahalom |]
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   217
     ==> A=A' & B=B' & na=na' & nb=nb'"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   218
apply (erule rev_mp, erule rev_mp)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   219
apply (erule yahalom.induct, simp_all)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   220
txt\<open>YM3, by freshness, and YM4\<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
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   224
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   225
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
   226
lemma secrecy_lemma:
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   227
     "[| A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   228
      ==> Says Server A
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   229
            {|Crypt (shrK A) {|Agent B, Key K, na, nb|},
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   230
              Crypt (shrK B) {|Agent A, Key K|}|}
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   231
           \<in> set evs -->
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   232
          Notes Spy {|na, nb, Key K|} \<notin> set evs -->
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   233
          Key K \<notin> analz (knows Spy evs)"
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   234
apply (erule yahalom.induct, force,
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   235
       drule_tac [6] YM4_analz_knows_Spy)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   236
apply (simp_all add: pushes analz_insert_eq analz_insert_freshK, spy_analz)   \<comment>\<open>Fake\<close>
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   237
apply (blast dest: unique_session_keys)+  \<comment>\<open>YM3, Oops\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   238
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   239
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   240
text\<open>Final version\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   241
lemma Spy_not_see_encrypted_key:
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   242
     "[| Says Server A
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   243
            {|Crypt (shrK A) {|Agent B, Key K, na, nb|},
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   244
              Crypt (shrK B) {|Agent A, Key K|}|}
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   245
           \<in> set evs;
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   246
         Notes Spy {|na, nb, Key K|} \<notin> set evs;
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   247
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   248
      ==> Key K \<notin> analz (knows Spy evs)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   249
by (blast dest: secrecy_lemma)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   250
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   251
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   252
subsubsection\<open>Security Guarantee for A upon receiving YM3\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   253
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   254
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
   255
lemma A_trusts_YM3:
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   256
     "[| Crypt (shrK A) {|Agent B, Key K, na, nb|} \<in> parts (knows Spy evs);
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   257
         A \<notin> bad;  evs \<in> yahalom |]
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   258
       ==> Says Server A
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   259
            {|Crypt (shrK A) {|Agent B, Key K, na, nb|},
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   260
              Crypt (shrK B) {|Agent A, Key K|}|}
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   261
           \<in> set evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   262
apply (erule rev_mp)
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   263
apply (erule yahalom.induct, force,
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   264
       frule_tac [6] YM4_parts_knows_Spy, simp_all)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   265
txt\<open>Fake, YM3\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   266
apply blast+
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   267
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   268
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   269
text\<open>The obvious combination of \<open>A_trusts_YM3\<close> with
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   270
  \<open>Spy_not_see_encrypted_key\<close>\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   271
lemma A_gets_good_key:
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   272
     "[| Crypt (shrK A) {|Agent B, Key K, na, nb|} \<in> parts (knows Spy evs);
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   273
         Notes Spy {|na, nb, Key K|} \<notin> set evs;
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   274
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   275
      ==> Key K \<notin> analz (knows Spy evs)"
32367
a508148f7c25 Removal of redundant settings of unification trace and search bounds.
paulson
parents: 23746
diff changeset
   276
  by (metis A_trusts_YM3 secrecy_lemma)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   277
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   278
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   279
subsubsection\<open>Security Guarantees for B upon receiving YM4\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   280
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   281
text\<open>B knows, by the first part of A's message, that the Server distributed
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   282
  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
   283
lemma B_trusts_YM4_shrK:
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   284
     "[| Crypt (shrK B) {|Agent A, Key K|} \<in> parts (knows Spy evs);
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   285
         B \<notin> bad;  evs \<in> yahalom |]
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   286
      ==> \<exists>NA NB. Says Server A
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   287
                      {|Crypt (shrK A) {|Agent B, Key K,
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   288
                                         Nonce NA, Nonce NB|},
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   289
                        Crypt (shrK B) {|Agent A, Key K|}|}
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   290
                     \<in> set evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   291
apply (erule rev_mp)
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   292
apply (erule yahalom.induct, force,
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   293
       frule_tac [6] YM4_parts_knows_Spy, simp_all)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   294
txt\<open>Fake, YM3\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   295
apply blast+
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   296
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   297
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   298
text\<open>B knows, by the second part of A's message, that the Server
17411
664434175578 fixed document;
wenzelm
parents: 16417
diff changeset
   299
  distributed the key quoting nonce NB.  This part says nothing about
664434175578 fixed document;
wenzelm
parents: 16417
diff changeset
   300
  agent names.  Secrecy of NB is crucial.  Note that @{term "Nonce NB
664434175578 fixed document;
wenzelm
parents: 16417
diff changeset
   301
  \<notin> analz(knows Spy evs)"} must be the FIRST antecedent of the
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   302
  induction formula.\<close>
17411
664434175578 fixed document;
wenzelm
parents: 16417
diff changeset
   303
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   304
lemma B_trusts_YM4_newK [rule_format]:
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   305
     "[|Crypt K (Nonce NB) \<in> parts (knows Spy evs);
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   306
        Nonce NB \<notin> analz (knows Spy evs);  evs \<in> yahalom|]
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   307
      ==> \<exists>A B NA. Says Server A
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   308
                      {|Crypt (shrK A) {|Agent B, Key K, Nonce NA, Nonce NB|},
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   309
                        Crypt (shrK B) {|Agent A, Key K|}|}
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   310
                     \<in> set evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   311
apply (erule rev_mp, erule rev_mp)
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   312
apply (erule yahalom.induct, force,
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   313
       frule_tac [6] YM4_parts_knows_Spy)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   314
apply (analz_mono_contra, simp_all)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   315
txt\<open>Fake, YM3\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   316
apply blast
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   317
apply blast
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   318
txt\<open>YM4.  A is uncompromised because NB is secure
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   319
  A's certificate guarantees the existence of the Server message\<close>
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   320
apply (blast dest!: Gets_imp_Says Crypt_Spy_analz_bad
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   321
             dest: Says_imp_spies
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   322
                   parts.Inj [THEN parts.Fst, THEN A_trusts_YM3])
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   323
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   324
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   325
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   326
subsubsection\<open>Towards proving secrecy of Nonce NB\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   327
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   328
text\<open>Lemmas about the predicate KeyWithNonce\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   329
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   330
lemma KeyWithNonceI:
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   331
 "Says Server A
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   332
          {|Crypt (shrK A) {|Agent B, Key K, na, Nonce NB|}, X|}
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   333
        \<in> set evs ==> KeyWithNonce K NB evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   334
by (unfold KeyWithNonce_def, blast)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   335
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   336
lemma KeyWithNonce_Says [simp]:
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   337
   "KeyWithNonce K NB (Says S A X # evs) =
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   338
      (Server = S &
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   339
       (\<exists>B n X'. X = {|Crypt (shrK A) {|Agent B, Key K, n, Nonce NB|}, X'|})
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   340
      | KeyWithNonce K NB evs)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   341
by (simp add: KeyWithNonce_def, blast)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   342
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   343
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   344
lemma KeyWithNonce_Notes [simp]:
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   345
   "KeyWithNonce K NB (Notes A X # evs) = KeyWithNonce K NB evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   346
by (simp add: KeyWithNonce_def)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   347
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   348
lemma KeyWithNonce_Gets [simp]:
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   349
   "KeyWithNonce K NB (Gets A X # evs) = KeyWithNonce K NB evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   350
by (simp add: KeyWithNonce_def)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   351
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   352
text\<open>A fresh key cannot be associated with any nonce
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   353
  (with respect to a given trace).\<close>
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   354
lemma fresh_not_KeyWithNonce:
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   355
     "Key K \<notin> used evs ==> ~ KeyWithNonce K NB evs"
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   356
by (unfold KeyWithNonce_def, blast)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   357
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   358
text\<open>The Server message associates K with NB' and therefore not with any
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   359
  other nonce NB.\<close>
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   360
lemma Says_Server_KeyWithNonce:
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   361
 "[| Says Server A {|Crypt (shrK A) {|Agent B, Key K, na, Nonce NB'|}, X|}
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   362
       \<in> set evs;
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   363
     NB \<noteq> NB';  evs \<in> yahalom |]
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   364
  ==> ~ KeyWithNonce K NB evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   365
by (unfold KeyWithNonce_def, blast dest: unique_session_keys)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   366
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   367
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   368
text\<open>The only nonces that can be found with the help of session keys are
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   369
  those distributed as nonce NB by the Server.  The form of the theorem
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   370
  recalls \<open>analz_image_freshK\<close>, but it is much more complicated.\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   371
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   372
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   373
text\<open>As with \<open>analz_image_freshK\<close>, we take some pains to express the 
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   374
  property as a logical equivalence so that the simplifier can apply it.\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   375
lemma Nonce_secrecy_lemma:
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   376
     "P --> (X \<in> analz (G Un H)) --> (X \<in> analz H)  ==>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   377
      P --> (X \<in> analz (G Un H)) = (X \<in> analz H)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   378
by (blast intro: analz_mono [THEN subsetD])
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   379
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   380
lemma Nonce_secrecy:
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   381
     "evs \<in> yahalom ==>
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   382
      (\<forall>KK. KK <= - (range shrK) -->
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   383
           (\<forall>K \<in> KK. K \<in> symKeys --> ~ KeyWithNonce K NB evs)   -->
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   384
           (Nonce NB \<in> analz (Key`KK Un (knows Spy evs))) =
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   385
           (Nonce NB \<in> analz (knows Spy evs)))"
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   386
apply (erule yahalom.induct,
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   387
       frule_tac [7] YM4_analz_knows_Spy)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   388
apply (safe del: allI impI intro!: Nonce_secrecy_lemma [THEN impI, THEN allI])
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   389
apply (simp_all del: image_insert image_Un
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   390
       add: analz_image_freshK_simps split_ifs
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   391
            all_conj_distrib ball_conj_distrib
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   392
            analz_image_freshK fresh_not_KeyWithNonce
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   393
            imp_disj_not1               (*Moves NBa\<noteq>NB to the front*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   394
            Says_Server_KeyWithNonce)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   395
txt\<open>For Oops, simplification proves @{prop "NBa\<noteq>NB"}.  By
17411
664434175578 fixed document;
wenzelm
parents: 16417
diff changeset
   396
  @{term Says_Server_KeyWithNonce}, we get @{prop "~ KeyWithNonce K NB
664434175578 fixed document;
wenzelm
parents: 16417
diff changeset
   397
  evs"}; then simplification can apply the induction hypothesis with
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   398
  @{term "KK = {K}"}.\<close>
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   399
txt\<open>Fake\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   400
apply spy_analz
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   401
txt\<open>YM2\<close>
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   402
apply blast
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   403
txt\<open>YM3\<close>
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   404
apply blast
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   405
txt\<open>YM4\<close>
59807
22bc39064290 prefer local fixes;
wenzelm
parents: 58889
diff changeset
   406
apply (erule_tac V = "\<forall>KK. P KK" for P in thin_rl, clarify)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   407
txt\<open>If @{prop "A \<in> bad"} then @{term NBa} is known, therefore
17411
664434175578 fixed document;
wenzelm
parents: 16417
diff changeset
   408
  @{prop "NBa \<noteq> NB"}.  Previous two steps make the next step
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   409
  faster.\<close>
32367
a508148f7c25 Removal of redundant settings of unification trace and search bounds.
paulson
parents: 23746
diff changeset
   410
apply (metis A_trusts_YM3 Gets_imp_analz_Spy Gets_imp_knows_Spy KeyWithNonce_def
a508148f7c25 Removal of redundant settings of unification trace and search bounds.
paulson
parents: 23746
diff changeset
   411
      Spy_analz_shrK analz.Fst analz.Snd analz_shrK_Decrypt parts.Fst parts.Inj)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   412
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   413
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   414
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   415
text\<open>Version required below: if NB can be decrypted using a session key then
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   416
   it was distributed with that key.  The more general form above is required
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   417
   for the induction to carry through.\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   418
lemma single_Nonce_secrecy:
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   419
     "[| Says Server A
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   420
          {|Crypt (shrK A) {|Agent B, Key KAB, na, Nonce NB'|}, X|}
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   421
         \<in> set evs;
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   422
         NB \<noteq> NB';  KAB \<notin> range shrK;  evs \<in> yahalom |]
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   423
      ==> (Nonce NB \<in> analz (insert (Key KAB) (knows Spy evs))) =
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   424
          (Nonce NB \<in> analz (knows Spy evs))"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   425
by (simp_all del: image_insert image_Un imp_disjL
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   426
             add: analz_image_freshK_simps split_ifs
13507
febb8e5d2a9d tidying of Isar scripts
paulson
parents: 11655
diff changeset
   427
                  Nonce_secrecy Says_Server_KeyWithNonce)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   428
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   429
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   430
subsubsection\<open>The Nonce NB uniquely identifies B's message.\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   431
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   432
lemma unique_NB:
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   433
     "[| Crypt (shrK B) {|Agent A, Nonce NA, nb|} \<in> parts (knows Spy evs);
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   434
         Crypt (shrK B') {|Agent A', Nonce NA', nb|} \<in> parts (knows Spy evs);
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   435
        evs \<in> yahalom;  B \<notin> bad;  B' \<notin> bad |]
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   436
      ==> NA' = NA & A' = A & B' = B"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   437
apply (erule rev_mp, erule rev_mp)
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   438
apply (erule yahalom.induct, force,
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   439
       frule_tac [6] YM4_parts_knows_Spy, simp_all)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   440
txt\<open>Fake, and YM2 by freshness\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   441
apply blast+
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   442
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   443
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   444
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   445
text\<open>Variant useful for proving secrecy of NB.  Because nb is assumed to be
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   446
  secret, we no longer must assume B, B' not bad.\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   447
lemma Says_unique_NB:
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   448
     "[| Says C S   {|X,  Crypt (shrK B) {|Agent A, Nonce NA, nb|}|}
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   449
           \<in> set evs;
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   450
         Gets S' {|X', Crypt (shrK B') {|Agent A', Nonce NA', nb|}|}
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   451
           \<in> set evs;
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   452
         nb \<notin> analz (knows Spy evs);  evs \<in> yahalom |]
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   453
      ==> NA' = NA & A' = A & B' = B"
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   454
by (blast dest!: Gets_imp_Says Crypt_Spy_analz_bad
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   455
          dest: Says_imp_spies unique_NB parts.Inj analz.Inj)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   456
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   457
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   458
subsubsection\<open>A nonce value is never used both as NA and as NB\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   459
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   460
lemma no_nonce_YM1_YM2:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   461
     "[|Crypt (shrK B') {|Agent A', Nonce NB, nb'|} \<in> parts(knows Spy evs);
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   462
        Nonce NB \<notin> analz (knows Spy evs);  evs \<in> yahalom|]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   463
  ==> Crypt (shrK B)  {|Agent A, na, Nonce NB|} \<notin> parts(knows Spy evs)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   464
apply (erule rev_mp, erule rev_mp)
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   465
apply (erule yahalom.induct, force,
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   466
       frule_tac [6] YM4_parts_knows_Spy)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   467
apply (analz_mono_contra, simp_all)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   468
txt\<open>Fake, YM2\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   469
apply blast+
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   470
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   471
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   472
text\<open>The Server sends YM3 only in response to YM2.\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   473
lemma Says_Server_imp_YM2:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   474
     "[| Says Server A {|Crypt (shrK A) {|Agent B, k, na, nb|}, X|} \<in> set evs;
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   475
         evs \<in> yahalom |]
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   476
      ==> Gets Server {| Agent B, Crypt (shrK B) {|Agent A, na, nb|} |}
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   477
             \<in> set evs"
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   478
by (erule rev_mp, erule yahalom.induct, auto)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   479
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   480
text\<open>A vital theorem for B, that nonce NB remains secure from the Spy.\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   481
lemma Spy_not_see_NB :
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   482
     "[| Says B Server
32960
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32377
diff changeset
   483
                {|Agent B, Crypt (shrK B) {|Agent A, Nonce NA, Nonce NB|}|}
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32377
diff changeset
   484
           \<in> set evs;
69916a850301 eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents: 32377
diff changeset
   485
         (\<forall>k. Notes Spy {|Nonce NA, Nonce NB, k|} \<notin> set evs);
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   486
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   487
      ==> Nonce NB \<notin> analz (knows Spy evs)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   488
apply (erule rev_mp, erule rev_mp)
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   489
apply (erule yahalom.induct, force,
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   490
       frule_tac [6] YM4_analz_knows_Spy)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   491
apply (simp_all add: split_ifs pushes new_keys_not_analzd analz_insert_eq
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   492
                     analz_insert_freshK)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   493
txt\<open>Fake\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   494
apply spy_analz
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   495
txt\<open>YM1: NB=NA is impossible anyway, but NA is secret because it is fresh!\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   496
apply blast
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   497
txt\<open>YM2\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   498
apply blast
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   499
txt\<open>Prove YM3 by showing that no NB can also be an NA\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   500
apply (blast dest!: no_nonce_YM1_YM2 dest: Gets_imp_Says Says_unique_NB)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   501
txt\<open>LEVEL 7: YM4 and Oops remain\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   502
apply (clarify, simp add: all_conj_distrib)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   503
txt\<open>YM4: key K is visible to Spy, contradicting session key secrecy theorem\<close>
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   504
txt\<open>Case analysis on Aa:bad; PROOF FAILED problems
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   505
  use \<open>Says_unique_NB\<close> to identify message components: @{term "Aa=A"}, @{term "Ba=B"}\<close>
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   506
apply (blast dest!: Says_unique_NB analz_shrK_Decrypt
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   507
                    parts.Inj [THEN parts.Fst, THEN A_trusts_YM3]
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   508
             dest: Gets_imp_Says Says_imp_spies Says_Server_imp_YM2
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   509
                   Spy_not_see_encrypted_key)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   510
txt\<open>Oops case: if the nonce is betrayed now, show that the Oops event is
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   511
  covered by the quantified Oops assumption.\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   512
apply (clarify, simp add: all_conj_distrib)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   513
apply (frule Says_Server_imp_YM2, assumption)
32367
a508148f7c25 Removal of redundant settings of unification trace and search bounds.
paulson
parents: 23746
diff changeset
   514
apply (metis Gets_imp_Says Says_Server_not_range Says_unique_NB no_nonce_YM1_YM2 parts.Snd single_Nonce_secrecy spies_partsEs(1))
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   515
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   516
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   517
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   518
text\<open>B's session key guarantee from YM4.  The two certificates contribute to a
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   519
  single conclusion about the Server's message.  Note that the "Notes Spy"
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   520
  assumption must quantify over \<open>\<forall>\<close> POSSIBLE keys instead of our particular K.
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   521
  If this run is broken and the spy substitutes a certificate containing an
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   522
  old key, B has no means of telling.\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   523
lemma B_trusts_YM4:
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   524
     "[| Gets B {|Crypt (shrK B) {|Agent A, Key K|},
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   525
                  Crypt K (Nonce NB)|} \<in> set evs;
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   526
         Says B Server
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   527
           {|Agent B, Crypt (shrK B) {|Agent A, Nonce NA, Nonce NB|}|}
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   528
           \<in> set evs;
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   529
         \<forall>k. Notes Spy {|Nonce NA, Nonce NB, k|} \<notin> set evs;
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   530
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   531
       ==> Says Server A
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   532
                   {|Crypt (shrK A) {|Agent B, Key K,
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   533
                             Nonce NA, Nonce NB|},
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   534
                     Crypt (shrK B) {|Agent A, Key K|}|}
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   535
             \<in> set evs"
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   536
by (blast dest: Spy_not_see_NB Says_unique_NB
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   537
                Says_Server_imp_YM2 B_trusts_YM4_newK)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   538
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   539
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   540
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   541
text\<open>The obvious combination of \<open>B_trusts_YM4\<close> with 
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   542
  \<open>Spy_not_see_encrypted_key\<close>\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   543
lemma B_gets_good_key:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   544
     "[| Gets B {|Crypt (shrK B) {|Agent A, Key K|},
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   545
                  Crypt K (Nonce NB)|} \<in> set evs;
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   546
         Says B Server
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   547
           {|Agent B, Crypt (shrK B) {|Agent A, Nonce NA, Nonce NB|}|}
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   548
           \<in> set evs;
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   549
         \<forall>k. Notes Spy {|Nonce NA, Nonce NB, k|} \<notin> set evs;
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   550
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   551
      ==> Key K \<notin> analz (knows Spy evs)"
32367
a508148f7c25 Removal of redundant settings of unification trace and search bounds.
paulson
parents: 23746
diff changeset
   552
  by (metis B_trusts_YM4 Spy_not_see_encrypted_key)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   553
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   554
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   555
subsection\<open>Authenticating B to A\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   556
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   557
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
   558
lemma B_Said_YM2 [rule_format]:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   559
     "[|Crypt (shrK B) {|Agent A, Nonce NA, nb|} \<in> parts (knows Spy evs);
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   560
        evs \<in> yahalom|]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   561
      ==> B \<notin> bad -->
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   562
          Says B Server {|Agent B, Crypt (shrK B) {|Agent A, Nonce NA, nb|}|}
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   563
            \<in> set evs"
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   564
apply (erule rev_mp, erule yahalom.induct, force,
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   565
       frule_tac [6] YM4_parts_knows_Spy, simp_all)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   566
txt\<open>Fake\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   567
apply blast
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   568
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   569
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   570
text\<open>If the server sends YM3 then B sent YM2\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   571
lemma YM3_auth_B_to_A_lemma:
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   572
     "[|Says Server A {|Crypt (shrK A) {|Agent B, Key K, Nonce NA, nb|}, X|}
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   573
       \<in> set evs;  evs \<in> yahalom|]
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   574
      ==> B \<notin> bad -->
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   575
          Says B Server {|Agent B, Crypt (shrK B) {|Agent A, Nonce NA, nb|}|}
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   576
            \<in> set evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   577
apply (erule rev_mp, erule yahalom.induct, simp_all)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   578
txt\<open>YM3, YM4\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   579
apply (blast dest!: B_Said_YM2)+
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   580
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   581
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   582
text\<open>If A receives YM3 then B has used nonce NA (and therefore is alive)\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   583
lemma YM3_auth_B_to_A:
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   584
     "[| Gets A {|Crypt (shrK A) {|Agent B, Key K, Nonce NA, nb|}, X|}
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   585
           \<in> set evs;
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   586
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   587
      ==> Says B Server {|Agent B, Crypt (shrK B) {|Agent A, Nonce NA, nb|}|}
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   588
       \<in> set evs"
32367
a508148f7c25 Removal of redundant settings of unification trace and search bounds.
paulson
parents: 23746
diff changeset
   589
  by (metis A_trusts_YM3 Gets_imp_analz_Spy YM3_auth_B_to_A_lemma analz.Fst
a508148f7c25 Removal of redundant settings of unification trace and search bounds.
paulson
parents: 23746
diff changeset
   590
         not_parts_not_analz)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   591
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   592
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   593
subsection\<open>Authenticating A to B using the certificate 
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   594
  @{term "Crypt K (Nonce NB)"}\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   595
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   596
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
   597
  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: 59807
diff changeset
   598
  NB matters for freshness.\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   599
lemma A_Said_YM3_lemma [rule_format]:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   600
     "evs \<in> yahalom
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   601
      ==> Key K \<notin> analz (knows Spy evs) -->
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   602
          Crypt K (Nonce NB) \<in> parts (knows Spy evs) -->
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   603
          Crypt (shrK B) {|Agent A, Key K|} \<in> parts (knows Spy evs) -->
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   604
          B \<notin> bad -->
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   605
          (\<exists>X. Says A B {|X, Crypt K (Nonce NB)|} \<in> set evs)"
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   606
apply (erule yahalom.induct, force,
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   607
       frule_tac [6] YM4_parts_knows_Spy)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   608
apply (analz_mono_contra, simp_all)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   609
txt\<open>Fake\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   610
apply blast
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   611
txt\<open>YM3: by \<open>new_keys_not_used\<close>, the message
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   612
   @{term "Crypt K (Nonce NB)"} could not exist\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   613
apply (force dest!: Crypt_imp_keysFor)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   614
txt\<open>YM4: was @{term "Crypt K (Nonce NB)"} the very last message?
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   615
    If not, use the induction hypothesis\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   616
apply (simp add: ex_disj_distrib)
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   617
txt\<open>yes: apply unicity of session keys\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   618
apply (blast dest!: Gets_imp_Says A_trusts_YM3 B_trusts_YM4_shrK
14207
f20fbb141673 Conversion of all main protocols from "Shared" to "Public".
paulson
parents: 14200
diff changeset
   619
                    Crypt_Spy_analz_bad
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   620
             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
   621
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   622
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   623
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
   624
  Moreover, A associates K with NB (thus is talking about the same run).
61830
4f5ab843cf5b isabelle update_cartouches -c -t;
wenzelm
parents: 59807
diff changeset
   625
  Other premises guarantee secrecy of K.\<close>
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   626
lemma YM4_imp_A_Said_YM3 [rule_format]:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   627
     "[| Gets B {|Crypt (shrK B) {|Agent A, Key K|},
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   628
                  Crypt K (Nonce NB)|} \<in> set evs;
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   629
         Says B Server
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   630
           {|Agent B, Crypt (shrK B) {|Agent A, Nonce NA, Nonce NB|}|}
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   631
           \<in> set evs;
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   632
         (\<forall>NA k. Notes Spy {|Nonce NA, Nonce NB, k|} \<notin> set evs);
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   633
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   634
      ==> \<exists>X. Says A B {|X, Crypt K (Nonce NB)|} \<in> set evs"
32367
a508148f7c25 Removal of redundant settings of unification trace and search bounds.
paulson
parents: 23746
diff changeset
   635
by (metis A_Said_YM3_lemma B_gets_good_key Gets_imp_analz_Spy YM4_parts_knows_Spy analz.Fst not_parts_not_analz)
1985
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
diff changeset
   636
end