src/HOL/Auth/Yahalom.thy
author paulson
Sat, 26 Apr 2003 12:38:42 +0200
changeset 13926 6e62e5357a10
parent 13507 febb8e5d2a9d
child 13956 8fe7e12290e1
permissions -rw-r--r--
converting more HOL-Auth to new-style theories
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, 
13507
febb8e5d2a9d tidying of Isar scripts
paulson
parents: 11655
diff changeset
    97
                     THEN yahalom.YM4], possibility)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    98
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
    99
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   100
lemma Gets_imp_Says:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   101
     "[| 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
   102
by (erule rev_mp, erule yahalom.induct, auto)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   103
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   104
(*Must be proved separately for each protocol*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   105
lemma Gets_imp_knows_Spy:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   106
     "[| 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
   107
by (blast dest!: Gets_imp_Says Says_imp_knows_Spy)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   108
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   109
declare Gets_imp_knows_Spy [THEN analz.Inj, dest]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   110
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
(**** Inductive proofs about yahalom ****)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   113
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   114
(*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
   115
lemma YM4_analz_knows_Spy:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   116
     "[| 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
   117
      ==> X \<in> analz (knows Spy evs)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   118
by blast
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   119
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   120
lemmas YM4_parts_knows_Spy = 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   121
       YM4_analz_knows_Spy [THEN analz_into_parts, standard]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   122
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   123
(*For Oops*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   124
lemma YM4_Key_parts_knows_Spy:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   125
     "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
   126
      ==> K \<in> parts (knows Spy evs)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   127
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
   128
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
(** 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
   131
    sends messages containing X! **)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   132
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   133
(*Spy never sees a good agent's shared key!*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   134
lemma Spy_see_shrK [simp]:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   135
     "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
   136
apply (erule yahalom.induct, force, 
13507
febb8e5d2a9d tidying of Isar scripts
paulson
parents: 11655
diff changeset
   137
       drule_tac [6] YM4_parts_knows_Spy, simp_all, blast+)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   138
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   139
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   140
lemma Spy_analz_shrK [simp]:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   141
     "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
   142
by auto
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   143
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   144
lemma Spy_see_shrK_D [dest!]:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   145
     "[|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
   146
by (blast dest: Spy_see_shrK)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   147
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   148
(*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
   149
lemma new_keys_not_used [rule_format, simp]:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   150
 "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
   151
apply (erule yahalom.induct, force, 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   152
       frule_tac [6] YM4_parts_knows_Spy, simp_all)
13926
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   153
txt{*Fake*}
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   154
apply (force dest!: keysFor_parts_insert)
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   155
txt{*YM3, YM4*}
6e62e5357a10 converting more HOL-Auth to new-style theories
paulson
parents: 13507
diff changeset
   156
apply blast+
11251
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"
13507
febb8e5d2a9d tidying of Isar scripts
paulson
parents: 11655
diff changeset
   173
apply (erule rev_mp, erule yahalom.induct, simp_all, blast)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   174
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   175
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
(*For proofs involving analz.
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   178
val analz_knows_Spy_tac = 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   179
    ftac YM4_analz_knows_Spy 7 THEN assume_tac 7
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   180
*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   181
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   182
(****
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   183
 The following is to prove theorems of the form
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   184
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   185
  Key K \<in> analz (insert (Key KAB) (knows Spy evs)) ==>
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   186
  Key K \<in> analz (knows Spy evs)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   187
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   188
 A more general formula must be proved inductively.
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   189
****)
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
(** Session keys are not used to encrypt other session keys **)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   192
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   193
lemma analz_image_freshK [rule_format]:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   194
 "evs \<in> yahalom ==>                                
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   195
   \<forall>K KK. KK <= - (range shrK) -->                  
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   196
          (Key K \<in> analz (Key`KK Un (knows Spy evs))) =   
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   197
          (K \<in> KK | Key K \<in> analz (knows Spy evs))"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   198
apply (erule yahalom.induct, force, 
13507
febb8e5d2a9d tidying of Isar scripts
paulson
parents: 11655
diff changeset
   199
       drule_tac [6] YM4_analz_knows_Spy, analz_freshK, spy_analz)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   200
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
   201
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   202
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   203
lemma analz_insert_freshK:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   204
     "[| evs \<in> yahalom;  KAB \<notin> range shrK |] ==>      
11655
923e4d0d36d5 tuned parentheses in relational expressions;
wenzelm
parents: 11251
diff changeset
   205
      (Key K \<in> analz (insert (Key KAB) (knows Spy evs))) =
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   206
      (K = KAB | Key K \<in> analz (knows Spy evs))"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   207
by (simp only: analz_image_freshK analz_image_freshK_simps)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   208
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   209
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   210
(*** The Key K uniquely identifies the Server's  message. **)
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
lemma unique_session_keys:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   213
     "[| Says Server A                                                  
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   214
          {|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
   215
        Says Server A'                                                 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   216
          {|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
   217
        evs \<in> yahalom |]                                     
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   218
     ==> A=A' & B=B' & na=na' & nb=nb'"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   219
apply (erule rev_mp, erule rev_mp)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   220
apply (erule yahalom.induct, simp_all)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   221
(*YM3, by freshness, and YM4*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   222
apply blast+
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   223
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   224
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   225
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   226
(** 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
   227
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   228
lemma secrecy_lemma:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   229
     "[| A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]                 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   230
      ==> Says Server A                                         
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   231
            {|Crypt (shrK A) {|Agent B, Key K, na, nb|},        
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   232
              Crypt (shrK B) {|Agent A, Key K|}|}               
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   233
           \<in> set evs -->                                        
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   234
          Notes Spy {|na, nb, Key K|} \<notin> set evs -->            
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   235
          Key K \<notin> analz (knows Spy evs)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   236
apply (erule yahalom.induct, force, 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   237
       drule_tac [6] YM4_analz_knows_Spy)
13507
febb8e5d2a9d tidying of Isar scripts
paulson
parents: 11655
diff changeset
   238
apply (simp_all add: pushes analz_insert_eq analz_insert_freshK, spy_analz)  (*Fake*)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   239
apply (blast dest: unique_session_keys)+  (*YM3, Oops*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   240
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   241
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   242
(*Final version*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   243
lemma Spy_not_see_encrypted_key:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   244
     "[| Says Server A                                          
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   245
            {|Crypt (shrK A) {|Agent B, Key K, na, nb|},        
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   246
              Crypt (shrK B) {|Agent A, Key K|}|}               
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   247
           \<in> set evs;                                           
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   248
         Notes Spy {|na, nb, Key K|} \<notin> set evs;                
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   249
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]                 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   250
      ==> Key K \<notin> analz (knows Spy evs)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   251
by (blast dest: secrecy_lemma)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   252
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   253
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   254
(** Security Guarantee for A upon receiving YM3 **)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   255
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   256
(*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
   257
lemma A_trusts_YM3:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   258
     "[| 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
   259
         A \<notin> bad;  evs \<in> yahalom |]                           
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   260
       ==> Says Server A                                             
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   261
            {|Crypt (shrK A) {|Agent B, Key K, na, nb|},             
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   262
              Crypt (shrK B) {|Agent A, Key K|}|}                    
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   263
           \<in> set evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   264
apply (erule rev_mp)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   265
apply (erule yahalom.induct, force, 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   266
       frule_tac [6] YM4_parts_knows_Spy, simp_all)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   267
(*Fake, YM3*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   268
apply blast+
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   269
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   270
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   271
(*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
   272
lemma A_gets_good_key:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   273
     "[| 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
   274
         Notes Spy {|na, nb, Key K|} \<notin> set evs;                
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   275
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]                 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   276
      ==> Key K \<notin> analz (knows Spy evs)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   277
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
   278
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   279
(** Security Guarantees for B upon receiving YM4 **)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   280
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   281
(*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
   282
  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
   283
lemma B_trusts_YM4_shrK:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   284
     "[| 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
   285
         B \<notin> bad;  evs \<in> yahalom |]                                  
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   286
      ==> \<exists>NA NB. Says Server A                                     
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   287
                      {|Crypt (shrK A) {|Agent B, Key K,              
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   288
                                         Nonce NA, Nonce NB|},        
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   289
                        Crypt (shrK B) {|Agent A, Key K|}|}           
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   290
                     \<in> set evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   291
apply (erule rev_mp)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   292
apply (erule yahalom.induct, force, 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   293
       frule_tac [6] YM4_parts_knows_Spy, simp_all)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   294
(*Fake, YM3*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   295
apply blast+
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   296
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   297
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   298
(*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
   299
  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
   300
  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
   301
  be the FIRST antecedent of the induction formula.*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   302
lemma B_trusts_YM4_newK[rule_format]:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   303
     "[|Crypt K (Nonce NB) \<in> parts (knows Spy evs);
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   304
        Nonce NB \<notin> analz (knows Spy evs);  evs \<in> yahalom|]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   305
      ==> \<exists>A B NA. Says Server A                           
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   306
                      {|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
   307
                        Crypt (shrK B) {|Agent A, Key K|}|}   
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   308
                     \<in> set evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   309
apply (erule rev_mp, erule rev_mp)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   310
apply (erule yahalom.induct, force, 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   311
       frule_tac [6] YM4_parts_knows_Spy)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   312
apply (analz_mono_contra, simp_all)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   313
(*Fake, YM3*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   314
apply blast
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   315
apply blast
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   316
(*YM4*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   317
(*A is uncompromised because NB is secure
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   318
  A's certificate guarantees the existence of the Server message*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   319
apply (blast dest!: Gets_imp_Says Crypt_Spy_analz_bad 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   320
             dest: Says_imp_spies 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   321
                   parts.Inj [THEN parts.Fst, THEN A_trusts_YM3])
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   322
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   323
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   324
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   325
(**** Towards proving secrecy of Nonce NB ****)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   326
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   327
(** Lemmas about the predicate KeyWithNonce **)
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
lemma KeyWithNonceI: 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   330
 "Says Server A                                               
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   331
          {|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
   332
        \<in> set evs ==> KeyWithNonce K NB evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   333
by (unfold KeyWithNonce_def, blast)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   334
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   335
lemma KeyWithNonce_Says [simp]: 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   336
   "KeyWithNonce K NB (Says S A X # evs) =                                     
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   337
      (Server = S &
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   338
       (\<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
   339
      | KeyWithNonce K NB evs)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   340
by (simp add: KeyWithNonce_def, blast)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   341
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   342
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   343
lemma KeyWithNonce_Notes [simp]: 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   344
   "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
   345
by (simp add: KeyWithNonce_def)
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_Gets [simp]: 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   348
   "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
   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
(*A fresh key cannot be associated with any nonce 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   352
  (with respect to a given trace). *)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   353
lemma fresh_not_KeyWithNonce: 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   354
 "Key K \<notin> used evs ==> ~ KeyWithNonce K NB evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   355
by (unfold KeyWithNonce_def, blast)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   356
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   357
(*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
   358
  other nonce NB.*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   359
lemma Says_Server_KeyWithNonce: 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   360
 "[| 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
   361
       \<in> set evs;                                                  
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   362
     NB \<noteq> NB';  evs \<in> yahalom |]                                  
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   363
  ==> ~ KeyWithNonce K NB evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   364
by (unfold KeyWithNonce_def, blast dest: unique_session_keys)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   365
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   366
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   367
(*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
   368
  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
   369
  recalls analz_image_freshK, but it is much more complicated.*)
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
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   372
(*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
   373
  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
   374
lemma Nonce_secrecy_lemma:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   375
     "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
   376
      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
   377
by (blast intro: analz_mono [THEN subsetD])
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   378
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   379
lemma Nonce_secrecy:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   380
     "evs \<in> yahalom ==>                                       
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   381
      (\<forall>KK. KK <= - (range shrK) -->                       
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   382
           (\<forall>K \<in> KK. ~ KeyWithNonce K NB evs)   -->         
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   383
           (Nonce NB \<in> analz (Key`KK Un (knows Spy evs))) =      
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   384
           (Nonce NB \<in> analz (knows Spy evs)))"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   385
apply (erule yahalom.induct, force, 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   386
       frule_tac [6] YM4_analz_knows_Spy)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   387
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
   388
apply (simp_all del: image_insert image_Un 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   389
       add: analz_image_freshK_simps split_ifs
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   390
            all_conj_distrib ball_conj_distrib 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   391
            analz_image_freshK fresh_not_KeyWithNonce
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   392
            imp_disj_not1               (*Moves NBa\<noteq>NB to the front*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   393
            Says_Server_KeyWithNonce)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   394
(*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
   395
  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
   396
  induction hypothesis with KK = {K}.*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   397
(*Fake*) 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   398
apply spy_analz
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   399
(*YM4*)  (** LEVEL 6 **)
13507
febb8e5d2a9d tidying of Isar scripts
paulson
parents: 11655
diff changeset
   400
apply (erule_tac V = "\<forall>KK. ?P KK" in thin_rl, clarify)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   401
(*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
   402
  the next step faster.*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   403
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
   404
         dest: analz.Inj
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   405
           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
   406
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   407
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   408
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   409
(*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
   410
  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
   411
  for the induction to carry through.*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   412
lemma single_Nonce_secrecy:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   413
     "[| Says Server A                                                
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   414
          {|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
   415
         \<in> set evs;                                                   
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   416
         NB \<noteq> NB';  KAB \<notin> range shrK;  evs \<in> yahalom |]             
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   417
      ==> (Nonce NB \<in> analz (insert (Key KAB) (knows Spy evs))) =         
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   418
          (Nonce NB \<in> analz (knows Spy evs))"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   419
by (simp_all del: image_insert image_Un imp_disjL
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   420
             add: analz_image_freshK_simps split_ifs
13507
febb8e5d2a9d tidying of Isar scripts
paulson
parents: 11655
diff changeset
   421
                  Nonce_secrecy Says_Server_KeyWithNonce)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   422
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   423
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   424
(*** The Nonce NB uniquely identifies B's message. ***)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   425
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   426
lemma unique_NB:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   427
     "[| 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
   428
         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
   429
        evs \<in> yahalom;  B \<notin> bad;  B' \<notin> bad |]   
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   430
      ==> NA' = NA & A' = A & B' = B"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   431
apply (erule rev_mp, erule rev_mp)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   432
apply (erule yahalom.induct, force, 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   433
       frule_tac [6] YM4_parts_knows_Spy, simp_all)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   434
(*Fake, and YM2 by freshness*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   435
apply blast+
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   436
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   437
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   438
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   439
(*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
   440
  secret, we no longer must assume B, B' not bad.*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   441
lemma Says_unique_NB:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   442
     "[| 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
   443
           \<in> set evs;                           
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   444
         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
   445
           \<in> set evs;                                                    
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   446
         nb \<notin> analz (knows Spy evs);  evs \<in> yahalom |]                  
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   447
      ==> NA' = NA & A' = A & B' = B"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   448
by (blast dest!: Gets_imp_Says Crypt_Spy_analz_bad 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   449
          dest: Says_imp_spies unique_NB parts.Inj analz.Inj)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   450
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   451
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   452
(** 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
   453
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   454
lemma no_nonce_YM1_YM2:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   455
     "[|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
   456
        Nonce NB \<notin> analz (knows Spy evs);  evs \<in> yahalom|]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   457
  ==> 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
   458
apply (erule rev_mp, erule rev_mp)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   459
apply (erule yahalom.induct, force, 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   460
       frule_tac [6] YM4_parts_knows_Spy)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   461
apply (analz_mono_contra, simp_all)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   462
(*Fake, YM2*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   463
apply blast+
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   464
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   465
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   466
(*The Server sends YM3 only in response to YM2.*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   467
lemma Says_Server_imp_YM2:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   468
     "[| 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
   469
         evs \<in> yahalom |]                                              
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   470
      ==> 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
   471
             \<in> set evs"
13507
febb8e5d2a9d tidying of Isar scripts
paulson
parents: 11655
diff changeset
   472
apply (erule rev_mp, erule yahalom.induct, auto)
11251
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   473
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   474
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   475
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   476
(*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
   477
lemma Spy_not_see_NB :
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   478
     "[| Says B Server                                                     
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   479
	        {|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
   480
	   \<in> set evs;
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   481
	 (\<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
   482
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]   
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   483
      ==> Nonce NB \<notin> analz (knows Spy evs)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   484
apply (erule rev_mp, erule rev_mp)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   485
apply (erule yahalom.induct, force, 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   486
       frule_tac [6] YM4_analz_knows_Spy)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   487
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
   488
                     analz_insert_freshK)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   489
(*Fake*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   490
apply spy_analz
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   491
(*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
   492
apply blast
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   493
(*YM2*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   494
apply blast
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   495
(*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
   496
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
   497
(** LEVEL 7: YM4 and Oops remain **)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   498
apply (clarify, simp add: all_conj_distrib)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   499
(*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
   500
(*Case analysis on Aa:bad; PROOF FAILED problems
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   501
  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
   502
apply (blast dest!: Says_unique_NB 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   503
                    parts.Inj [THEN parts.Fst, THEN A_trusts_YM3] 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   504
             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
   505
                   Spy_not_see_encrypted_key)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   506
(*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
   507
  covered by the quantified Oops assumption.*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   508
apply (clarify, simp add: all_conj_distrib)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   509
apply (frule Says_Server_imp_YM2, assumption)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   510
apply (case_tac "NB = NBa")
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   511
(*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
   512
apply (blast dest: Says_unique_NB)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   513
(*case NB \<noteq> NBa*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   514
apply (simp add: single_Nonce_secrecy)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   515
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
   516
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   517
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   518
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   519
(*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
   520
  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
   521
  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
   522
  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
   523
  old key, B has no means of telling.*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   524
lemma B_trusts_YM4:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   525
     "[| Gets B {|Crypt (shrK B) {|Agent A, Key K|},                   
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   526
                  Crypt K (Nonce NB)|} \<in> set evs;                      
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   527
         Says B Server                                                    
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   528
           {|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
   529
           \<in> set evs;                                                     
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   530
         \<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
   531
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]        
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   532
       ==> Says Server A                                                  
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   533
                   {|Crypt (shrK A) {|Agent B, Key K,                     
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   534
                             Nonce NA, Nonce NB|},                        
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   535
                     Crypt (shrK B) {|Agent A, Key K|}|}                  
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   536
             \<in> set evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   537
by (blast dest: Spy_not_see_NB Says_unique_NB 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   538
                Says_Server_imp_YM2 B_trusts_YM4_newK)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   539
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   540
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   541
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   542
(*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
   543
lemma B_gets_good_key:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   544
     "[| Gets B {|Crypt (shrK B) {|Agent A, Key K|},
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   545
                  Crypt K (Nonce NB)|} \<in> set evs;
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   546
         Says B Server                                                    
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   547
           {|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
   548
           \<in> set evs;                                                     
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   549
         \<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
   550
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]                 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   551
      ==> Key K \<notin> analz (knows Spy evs)"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   552
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
   553
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   554
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   555
(*** Authenticating B to A ***)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   556
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   557
(*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
   558
lemma B_Said_YM2 [rule_format]:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   559
     "[|Crypt (shrK B) {|Agent A, Nonce NA, nb|} \<in> parts (knows Spy evs);
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   560
        evs \<in> yahalom|]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   561
      ==> B \<notin> bad -->
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   562
          Says B Server {|Agent B, Crypt (shrK B) {|Agent A, Nonce NA, nb|}|}
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   563
            \<in> set evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   564
apply (erule rev_mp, erule yahalom.induct, force, 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   565
       frule_tac [6] YM4_parts_knows_Spy, simp_all)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   566
(*Fake*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   567
apply blast
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   568
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   569
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   570
(*If the server sends YM3 then B sent YM2*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   571
lemma YM3_auth_B_to_A_lemma:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   572
     "[|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
   573
       \<in> set evs;  evs \<in> yahalom|]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   574
      ==> B \<notin> bad -->                                                         
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   575
          Says B Server {|Agent B, Crypt (shrK B) {|Agent A, Nonce NA, nb|}|}
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   576
            \<in> set evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   577
apply (erule rev_mp, erule yahalom.induct, simp_all)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   578
(*YM3, YM4*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   579
apply (blast dest!: B_Said_YM2)+
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   580
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   581
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   582
(*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
   583
lemma YM3_auth_B_to_A:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   584
     "[| 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
   585
           \<in> set evs;                                                     
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   586
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]                         
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   587
      ==> 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
   588
       \<in> set evs"
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   589
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
   590
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   591
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   592
(*** 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
   593
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   594
(*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
   595
  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
   596
  NB matters for freshness.*)  
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   597
lemma A_Said_YM3_lemma [rule_format]:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   598
     "evs \<in> yahalom
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   599
      ==> Key K \<notin> analz (knows Spy evs) -->
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   600
          Crypt K (Nonce NB) \<in> parts (knows Spy evs) -->
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   601
          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
   602
          B \<notin> bad -->
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   603
          (\<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
   604
apply (erule yahalom.induct, force, 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   605
       frule_tac [6] YM4_parts_knows_Spy)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   606
apply (analz_mono_contra, simp_all)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   607
(*Fake*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   608
apply blast
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   609
(*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
   610
apply (force dest!: Crypt_imp_keysFor)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   611
(*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
   612
apply (simp add: ex_disj_distrib)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   613
(*yes: apply unicity of session keys*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   614
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
   615
                    Crypt_Spy_analz_bad 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   616
             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
   617
done
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   618
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   619
(*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
   620
  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
   621
  Other premises guarantee secrecy of K.*)
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   622
lemma YM4_imp_A_Said_YM3 [rule_format]:
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   623
     "[| Gets B {|Crypt (shrK B) {|Agent A, Key K|},
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   624
                  Crypt K (Nonce NB)|} \<in> set evs;
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   625
         Says B Server
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   626
           {|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
   627
           \<in> set evs;
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   628
         (\<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
   629
         A \<notin> bad;  B \<notin> bad;  evs \<in> yahalom |]
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   630
      ==> \<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
   631
by (blast intro!: A_Said_YM3_lemma 
a6816d47f41d converted many HOL/Auth theories to Isar scripts
paulson
parents: 11185
diff changeset
   632
          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
   633
1985
84cf16192e03 Tidied many proofs, using AddIffs to let equivalences take
paulson
parents:
diff changeset
   634
end