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